Combination lock counter

CJam, 52 39 bytes

q~[3X0].{@40,m<1$({(+W%}&:T*T@#)T<)}e_p

Try it online in the CJam interpreter.

How it works

q~      e# Read and evaluate all input. This pushes the initial position
        e# as an integer and the combination as an array.
[3X0]   e# Push [3 1 0]. This encodes the respective numbers of full turns
.{      e# For each number in the combination (N) and the corresponding 
        e# number of full turns (F):
  @     e#   Rotate the initial position on top of the stack.
  40,m< e#   Push [0 ... 39] and rotate it that many units to the left.
        e#   For position P, this pushes [P P+1 ... 39 0 ... P-2 P-1].
  1$(   e#   Copy F and subtract 1.
  {     e#   If the result is non-zero:
    (+  e#     Rotate the array of length 40 one unit to the left.
    W%  e#     Reverse it.
  }&    e#   For position P, this pushes [P P-1 ... 0 39 ... P+2 P+1].
  :T*   e#   Save in T and repeat the array F.
  T@    e#   Push T. Rotate N on top of the stack.
  #)    e#   Find the index of N in T and add 1 to it.
  T<    e#   Keep that many elements from the beginning of T.
  )     e#   Pop the last element of the result (N).
}       e# N is the new initial position.
e_p     e# Flatten the resulting array and print it.