#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);
void PrintNumber(int number) {
  long long num, denom, quot;
  if (number < 1000) {
    printf("%d", (int)number);
    return;
  }
  denom = 1;
  num = number;
  while (num >= 1000) {
    num /= 1000;
    denom *= 1000;
  }
  printf("%d,", (int)num);
  num = (number - num * denom);
  denom /= 1000;
  while (denom > 1) {
    quot = (num / denom);
    printf("%03d,", (int)quot);
    num -= (quot * denom);
    denom /= 1000;
  }
  printf("%03d", (int)num);
}


x86 assembly (clang, -O0):
<PrintNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    113c <PrintNumber+0x2c>
mov    -0x4(%rbp),%esi
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    121d <PrintNumber+0x10d>
movq   $0x1,-0x18(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x3e8,-0x10(%rbp)
jl     117d <PrintNumber+0x6d>
mov    -0x10(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
imul   $0x3e8,-0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    114c <PrintNumber+0x3c>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
movslq -0x4(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
jle    120b <PrintNumber+0xfb>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rcx
imul   -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    11b5 <PrintNumber+0xa5>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintNumber>:
mov    %edi,%esi
cmp    $0x3e7,%edi
jg     1126 <PrintNumber+0x16>
lea    0xedf(%rip),%rdi
jmp    1030 <printf@plt>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r15d
mov    $0x1,%r13d
movabs $0x20c49ba5e353f7cf,%r12
9b c4 20
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rcx
mov    %rbx,%rax
shr    $0x3,%rax
mul    %r12
mov    %rdx,%rbx
shr    $0x4,%rbx
imul   $0x3e8,%r13,%r13
cmp    $0xf423f,%rcx
ja     1150 <PrintNumber+0x40>
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
imul   %r13,%rbx
sub    %rbx,%r15
cmp    $0x7d0,%r13
jb     11ed <PrintNumber+0xdd>
lea    0xe6e(%rip),%r14
jmp    11c2 <PrintNumber+0xb2>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rax
cqto
idiv   %rbx
mov    %rax,%rsi
mov    %rdx,%r15
mov    %r14,%rdi
call   1030 <printf@plt>
cmp    $0x1e847f,%r13
mov    %rbx,%r13
jbe    11ed <PrintNumber+0xdd>
mov    %r13,%rax
shr    $0x3,%rax
mul    %r12
mov    %rdx,%rbx
shr    $0x4,%rbx
mov    %r15,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    11a0 <PrintNumber+0x90>
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%esi
mov    %edx,%r15d
jmp    11ae <PrintNumber+0x9e>
lea    0xe19(%rip),%rdi
mov    %r15d,%esi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d,\00"
@.str.2 = [6 x i8] c"%03d,\00"
@.str.3 = [5 x i8] c"%03d\00"
define void @PrintNumber(i32 %0) {
%2 = icmp slt i32 %0, 1000
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %33
5: ; preds = %1
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ %10, %7 ], [ %6, %5 ]
%9 = phi i64 [ %11, %7 ], [ 1, %5 ]
%10 = udiv i64 %8, 1000
%11 = mul nsw i64 %9, 1000
%12 = icmp ugt i64 %8, 999999
br i1 %12, label %7, label %13
13: ; preds = %7
%14 = trunc i64 %10 to i32
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = mul nsw i64 %10, %11
%17 = sub nsw i64 %6, %16
%18 = icmp ugt i64 %11, 1999
br i1 %18, label %19, label %29
19: ; preds = %13, %19
%20 = phi i64 [ %22, %19 ], [ %11, %13 ]
%21 = phi i64 [ %27, %19 ], [ %17, %13 ]
%22 = udiv i64 %20, 1000
%23 = sdiv i64 %21, %22
%24 = trunc i64 %23 to i32
%25 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = mul nsw i64 %23, %22
%27 = srem i64 %21, %22
%28 = icmp ugt i64 %20, 1999999
br i1 %28, label %19, label %29
29: ; preds = %19, %13
%30 = phi i64 [ %17, %13 ], [ %27, %19 ]
%31 = trunc i64 %30 to i32
%32 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %3
ret void
}