#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 /*<<< orphan*/ printf(char *, int, int);
int main(int argc, char *argv[]) {
  int fact[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
  int n = 1000000, i;
  int t, dig = 9, count = 0;
  int pos = 0;
  int num[10] = {0};
  for (count = 9; count >= 0 && n >= 0; count--) {
    printf("%d, %d\n", n / fact[count] + 1, (n / fact[count]) * fact[count]);
    n = n % fact[count];
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0xf4240,-0x44(%rbp)
movl   $0x9,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x9,-0x54(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x54(%rbp)
mov    %al,-0x81(%rbp)
jl     11b0 <main+0x80>
cmpl   $0x0,-0x44(%rbp)
setge  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    11c3 <main+0x93>
jmp    1214 <main+0xe4>
mov    -0x44(%rbp),%eax
movslq -0x54(%rbp),%rcx
cltd
idivl  -0x40(%rbp,%rcx,4)
mov    %eax,%esi
add    $0x1,%esi
mov    -0x44(%rbp),%eax
movslq -0x54(%rbp),%rcx
cltd
idivl  -0x40(%rbp,%rcx,4)
mov    %eax,%edx
movslq -0x54(%rbp),%rax
imul   -0x40(%rbp,%rax,4),%edx
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
movslq -0x54(%rbp),%rcx
cltd
idivl  -0x40(%rbp,%rcx,4)
mov    %edx,-0x44(%rbp)
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
jmp    1191 <main+0x61>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xf4240,%ebp
mov    $0x9,%ebx
lea    0xed8(%rip),%r15
lea    0xef9(%rip),%r14
nop
mov    (%r15,%rbx,4),%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
lea    0x1(%rax),%esi
imul   %eax,%ecx
mov    %edx,%ebp
mov    %r14,%rdi
mov    %ecx,%edx
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
jb     1130 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.fact = [10 x i32] [i32 1, i32 1, i32 2, i32 6, i32 24, i32 120, i32 720, i32 5040, i32 40320, i32 362880]
@.str = [8 x i8] c"%d, %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [10 x i32]* %6 to i8*
store i32 1000000, i32* %7
store i32 9, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%15 = bitcast [10 x i32]* %13 to i8*
store i32 9, i32* %11
br label %16
16: ; preds = %50, %2
%17 = load i32, i32* %11
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %7
%21 = icmp sge i32 %20, 0
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ false, %16 ], [ %21, %19 ]
br i1 %23, label %24, label %53
24: ; preds = %22
%25 = load i32, i32* %7
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = sdiv i32 %25, %29
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %7
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = sdiv i32 %32, %36
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = mul nsw i32 %37, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %42)
%44 = load i32, i32* %7
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = srem i32 %44, %48
store i32 %49, i32* %7
br label %50
50: ; preds = %24
%51 = load i32, i32* %11
%52 = add nsw i32 %51, -1
store i32 %52, i32* %11
br label %16
53: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@__const.main.fact = [10 x i32] [i32 1, i32 1, i32 2, i32 6, i32 24, i32 120, i32 720, i32 5040, i32 40320, i32 362880]
@.str = [8 x i8] c"%d, %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 9, %2 ], [ %13, %3 ]
%5 = phi i32 [ 1000000, %2 ], [ %12, %3 ]
%6 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.main.fact, i64 0, i64 %4
%7 = load i32, i32* %6
%8 = sdiv i32 %5, %7
%9 = add nsw i32 %8, 1
%10 = mul nsw i32 %8, %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = srem i32 %5, %7
%13 = add nsw i64 %4, -1
%14 = icmp eq i64 %4, 0
br i1 %14, label %15, label %3
15: ; preds = %3
ret i32 0
}