#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int C(int, int);
int Combination(int n, int m) {
  int ans = 1;
  int a, b;
  while (m || n) {
    a = n % 10007;
    b = m % 10007;
    n /= 10007;
    m /= 10007;
    ans = (ans * C(a, b)) % 10007;
  }
  return ans;
}


x86 assembly (clang, -O0):
<Combination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x15(%rbp)
jne    113e <Combination+0x2e>
cmpl   $0x0,-0x4(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    114e <Combination+0x3e>
jmp    11af <Combination+0x9f>
mov    -0x4(%rbp),%eax
mov    $0x2717,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2717,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2717,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2717,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <C@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
mov    $0x2717,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
jmp    1125 <Combination+0x15>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Combination>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%eax
or     %edi,%eax
je     11c8 <Combination+0xb8>
mov    %esi,%r14d
mov    %edi,%r13d
mov    $0x1,%r15d
nop
movslq %r13d,%r12
imul   $0x68c8c4ad,%r12,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x2c,%r13
add    %eax,%r13d
imul   $0x2717,%r13d,%eax
mov    %r12d,%edi
sub    %eax,%edi
movslq %r14d,%rbx
imul   $0x68c8c4ad,%rbx,%r14
mov    %r14,%rax
shr    $0x3f,%rax
sar    $0x2c,%r14
add    %eax,%r14d
imul   $0x2717,%r14d,%eax
mov    %ebx,%esi
sub    %eax,%esi
call   1030 <C@plt>
imul   %r15d,%eax
movslq %eax,%r15
imul   $0x68c8c4ad,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2717,%eax,%eax
sub    %eax,%r15d
add    $0xffffd8e9,%ebx
add    $0xffffd8e9,%r12d
cmp    $0xffffb1d3,%ebx
jb     1130 <Combination+0x20>
cmp    $0xffffb1d3,%r12d
jb     1130 <Combination+0x20>
jmp    11ce <Combination+0xbe>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @Combination(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 1, i32* %5
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ true, %8 ], [ %13, %11 ]
br i1 %15, label %16, label %31
16: ; preds = %14
%17 = load i32, i32* %3
%18 = srem i32 %17, 10007
store i32 %18, i32* %6
%19 = load i32, i32* %4
%20 = srem i32 %19, 10007
store i32 %20, i32* %7
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 10007
store i32 %22, i32* %3
%23 = load i32, i32* %4
%24 = sdiv i32 %23, 10007
store i32 %24, i32* %4
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = call i32 @C(i32 %26, i32 %27)
%29 = mul nsw i32 %25, %28
%30 = srem i32 %29, 10007
store i32 %30, i32* %5
br label %8
31: ; preds = %14
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @Combination(i32 %0, i32 %1) {
%3 = or i32 %1, %0
%4 = icmp eq i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2, %5
%6 = phi i32 [ %11, %5 ], [ %0, %2 ]
%7 = phi i32 [ %12, %5 ], [ %1, %2 ]
%8 = phi i32 [ %15, %5 ], [ 1, %2 ]
%9 = srem i32 %6, 10007
%10 = srem i32 %7, 10007
%11 = sdiv i32 %6, 10007
%12 = sdiv i32 %7, 10007
%13 = tail call i32 @C(i32 %9, i32 %10)
%14 = mul nsw i32 %13, %8
%15 = srem i32 %14, 10007
%16 = add i32 %7, -10007
%17 = icmp ult i32 %16, -20013
%18 = add i32 %6, -10007
%19 = icmp ult i32 %18, -20013
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %5, label %21
21: ; preds = %5, %2
%22 = phi i32 [ 1, %2 ], [ %15, %5 ]
ret i32 %22
}