11 mov eax,[ebp + 8] ; eax = a (0 <= a <= 2^31 - 1)
12 mov ebx,[ebp + 12] ; ebx = b (0 <= b <= 2^31 - 1)
15 bsf ecx,ecx ; greatest common power of 2 of a and b
17 mov eax,1 ; if a = 0 and b = 0, return 1
23 mov eax,ebx ; if a = 0, return b
27 jz done ; if b = 0, return a
28 bsf ecx,eax ; "simplify" a as much as possible
30 bsf ecx,ebx ; "simplify" b as much as possible
35 sbb edx,edx ; edx = 0 if b >= a or -1 if a > b
36 and ecx,edx ; ecx = 0 if b >= a or b - a if a > b
37 add eax,ecx ; a-new = min(a,b)
38 sub ebx,ecx ; b-new = max(a,b)
39 sub ebx,eax ; the difference is >= 0
40 bsf ecx,eax ; "simplify" as much as possible by 2
42 bsf ecx,ebx ; "simplify" as much as possible by 2
44 jnz mainLoop ; keep looping until ebx = 0
45 mov ecx,edi ; shift back with common power of 2