#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*/ reverse(char *);
int /*<<< orphan*/ sprintf(char *, char *, long);
int /*<<< orphan*/ strcpy(char *, char *);
const char *cents2money(long cents) {
  static char buff[64];
  int idx = 0;
  char *d = buff;
  if (cents == 0) {
    strcpy(buff, "0.00");
  } else if (cents < 100) {
    sprintf(buff, "0.%2.2ld", cents);
  } else {
    while (cents > 0) {
      *d++ = '0' + (cents % 10);
      cents = cents / 10;
      if (idx == 1) {
        *d++ = '.';
      } else if (cents > 0 && (idx - 1) % 3 == 0) {
        *d++ = ',';
      }
      idx++;
    }
    *d++ = 0;
    reverse(buff);
  }
  return (buff);
}


x86 assembly (clang, -O0):
<cents2money>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0x2f06(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1171 <cents2money+0x41>
lea    0x2ef0(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcpy@plt>
jmp    126a <cents2money+0x13a>
cmpq   $0x64,-0x8(%rbp)
jge    1198 <cents2money+0x68>
mov    -0x8(%rbp),%rdx
lea    0x2ec9(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1050 <sprintf@plt>
jmp    1265 <cents2money+0x135>
jmp    119d <cents2money+0x6d>
cmpq   $0x0,-0x8(%rbp)
jle    1247 <cents2money+0x117>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1200 <cents2money+0xd0>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2e,(%rax)
jmp    1239 <cents2money+0x109>
cmpq   $0x0,-0x8(%rbp)
jle    1234 <cents2money+0x104>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1234 <cents2money+0x104>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2c,(%rax)
jmp    1239 <cents2money+0x109>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119d <cents2money+0x6d>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
lea    0x2df0(%rip),%rdi
call   1030 <reverse@plt>
jmp    126a <cents2money+0x13a>
lea    0x2ddf(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cents2money>:
push   %rax
test   %rdi,%rdi
je     115a <cents2money+0x2a>
mov    %rdi,%rcx
cmp    $0x64,%rdi
jge    1172 <cents2money+0x42>
lea    0x2f0a(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    %rcx,%rdx
call   1050 <sprintf@plt>
jmp    12a1 <cents2money+0x171>
lea    0x2eef(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1040 <strcpy@plt>
jmp    12a1 <cents2money+0x171>
movabs $0xcccccccccccccccd,%r8
cc cc cc
mov    %rcx,%rax
mul    %r8
mov    %rdx,%rsi
shr    $0x3,%rsi
lea    (%rsi,%rsi,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%edx
sub    %eax,%edx
or     $0x30,%dl
mov    %dl,0x2eb4(%rip)
mov    %rsi,%rax
mul    %r8
shr    $0x2,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%eax
sub    %eax,%esi
or     $0x30,%sil
mov    %rcx,%rax
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rdx
c2 f5 28
mul    %rdx
mov    %rdx,%rdi
mov    %sil,0x2e82(%rip)
shr    $0x2,%rdi
mov    %rdi,%rax
mul    %r8
movb   $0x2e,0x2e72(%rip)
shr    $0x2,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%eax
sub    %eax,%edi
or     $0x30,%dil
mov    %dil,0x2e5d(%rip)
cmp    $0x3e8,%rcx
jb     128b <cents2money+0x15b>
shr    $0x3,%rcx
movabs $0x20c49ba5e353f7cf,%rdx
9b c4 20
mov    %rcx,%rax
mul    %rdx
mov    %rdx,%r11
shr    $0x4,%r11
lea    0x2e2e(%rip),%r9
lea    0x2e28(%rip),%rax
mov    $0xffffffff,%edi
mov    $0x1,%esi
mov    $0xaaaaaaab,%r10d
jmp    1275 <cents2money+0x145>
xchg   %ax,%ax
add    $0x2,%r9
movb   $0x2c,(%rax)
mov    %r11,%rax
mul    %r8
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %r11d,%ecx
sub    %eax,%ecx
or     $0x30,%cl
lea    0x1(%r9),%rax
mov    %cl,(%r9)
add    $0xffffffff,%edi
add    $0x1,%esi
cmp    $0x9,%r11
mov    %rdx,%r11
jbe    1292 <cents2money+0x162>
mov    %esi,%edx
imul   %r10,%rdx
shr    $0x21,%rdx
lea    (%rdx,%rdx,2),%edx
add    %edi,%edx
je     1240 <cents2money+0x110>
mov    %rax,%r9
jmp    1247 <cents2money+0x117>
lea    0x2dc2(%rip),%rax
movb   $0x0,(%rax)
lea    0x2db4(%rip),%rdi
call   1030 <reverse@plt>
lea    0x2da8(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@cents2money.buff = internal global [64 x i8] zeroinitializer
@.str = [5 x i8] c"0.00\00"
@.str.1 = [9 x i8] c"0.%2.2ld\00"
define i8* @cents2money(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i8*
store i64 %0, i64* %2
store i32 0, i32* %3
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0), i8** %4
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %53
9: ; preds = %1
%10 = load i64, i64* %2
%11 = icmp slt i64 %10, 100
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i64, i64* %2
%14 = call i32 @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 %13)
br label %52
15: ; preds = %9
br label %16
16: ; preds = %45, %15
%17 = load i64, i64* %2
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %48
19: ; preds = %16
%20 = load i64, i64* %2
%21 = srem i64 %20, 10
%22 = add nsw i64 48, %21
%23 = trunc i64 %22 to i8
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
store i8 %23, i8* %24
%26 = load i64, i64* %2
%27 = sdiv i64 %26, 10
store i64 %27, i64* %2
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %19
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
store i8 46, i8* %31
br label %45
33: ; preds = %19
%34 = load i64, i64* %2
%35 = icmp sgt i64 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i32, i32* %3
%38 = sub nsw i32 %37, 1
%39 = srem i32 %38, 3
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %4
store i8 44, i8* %42
br label %44
44: ; preds = %41, %36, %33
br label %45
45: ; preds = %44, %30
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %16
48: ; preds = %16
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %4
store i8 0, i8* %49
%51 = call i32 @reverse(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0))
br label %52
52: ; preds = %48, %12
br label %53
53: ; preds = %52, %7
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0)
}

LLVM IR (-O2):
@cents2money.buff = internal global [64 x i8] zeroinitializer
@.str = [5 x i8] c"0.00\00"
@.str.1 = [9 x i8] c"0.%2.2ld\00"
define i8* @cents2money(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %46
5: ; preds = %1
%6 = icmp slt i64 %0, 100
br i1 %6, label %22, label %7
7: ; preds = %5
%8 = urem i64 %0, 10
%9 = trunc i64 %8 to i8
%10 = or i8 %9, 48
store i8 %10, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0)
%11 = udiv i64 %0, 10
%12 = urem i64 %11, 10
%13 = trunc i64 %12 to i8
%14 = or i8 %13, 48
store i8 %14, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 1)
%15 = udiv i64 %0, 100
store i8 46, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 2)
%16 = urem i64 %15, 10
%17 = trunc i64 %16 to i8
%18 = or i8 %17, 48
store i8 %18, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 3)
%19 = icmp ugt i64 %0, 999
br i1 %19, label %20, label %43
20: ; preds = %7
%21 = udiv i64 %0, 1000
br label %24
22: ; preds = %5
%23 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 %0)
br label %46
24: ; preds = %20, %34
%25 = phi i64 [ %21, %20 ], [ %41, %34 ]
%26 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 4), %20 ], [ %40, %34 ]
%27 = phi i32 [ 2, %20 ], [ %36, %34 ]
%28 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 3), %20 ], [ %35, %34 ]
%29 = add nsw i32 %27, -1
%30 = urem i32 %29, 3
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = getelementptr inbounds i8, i8* %28, i64 2
store i8 44, i8* %26
br label %34
34: ; preds = %24, %32
%35 = phi i8* [ %33, %32 ], [ %26, %24 ]
%36 = add nuw nsw i32 %27, 1
%37 = urem i64 %25, 10
%38 = trunc i64 %37 to i8
%39 = or i8 %38, 48
%40 = getelementptr inbounds i8, i8* %35, i64 1
store i8 %39, i8* %35
%41 = udiv i64 %25, 10
%42 = icmp ugt i64 %25, 9
br i1 %42, label %24, label %43
43: ; preds = %34, %7
%44 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 4), %7 ], [ %40, %34 ]
store i8 0, i8* %44
%45 = tail call i32 @reverse(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0))
br label %46
46: ; preds = %22, %43, %3
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @cents2money.buff, i64 0, i64 0)
}