#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 */
char *strcpy(char *, char *);
char *nice_number(long number) {
  static char str[32], *p;
  int i, neg;
  if (number == 0)
    return strcpy(str, "0");
  neg = number < 0;
  if (neg)
    number = -number;
  p = str + 31;
  *p = 0;
  for (i = 0; number; i++) {
    if ((i & 3) == 3) {
      *(--p) = ',';
      ++i;
    }
    *(--p) = (number % 10) + '0';
    number /= 10;
  }
  if (neg)
    *(--p) = '-';
  return p;
}


x86 assembly (clang, -O0):
<nice_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <nice_number+0x33>
lea    0x2f12(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x8(%rbp)
jmp    1240 <nice_number+0x130>
cmpq   $0x0,-0x10(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1167 <nice_number+0x57>
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0x2ed2(%rip),%rax
add    $0x1f,%rax
mov    %rax,0x2ee7(%rip)
mov    0x2ee0(%rip),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1212 <nice_number+0x102>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    11c6 <nice_number+0xb6>
mov    0x2eb5(%rip),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x2ea7(%rip)
movb   $0x2c,-0x1(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    0x2e7f(%rip),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,0x2e71(%rip)
mov    %cl,-0x1(%rax)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118a <nice_number+0x7a>
cmpl   $0x0,-0x18(%rbp)
je     1235 <nice_number+0x125>
mov    0x2e3d(%rip),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x2e2f(%rip)
movb   $0x2d,-0x1(%rax)
mov    0x2e24(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nice_number>:
test   %rdi,%rdi
je     118c <nice_number+0x8c>
movb   $0x0,0x2f3f(%rip)
lea    0x2f38(%rip),%rax
mov    %rdi,%rcx
neg    %rcx
cmovs  %rdi,%rcx
xor    %r10d,%r10d
movabs $0x6666666666666667,%r8
66 66 66
jmp    116e <nice_number+0x6e>
mov    %rax,%r9
mov    %rcx,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%esi
sub    %eax,%esi
add    $0x30,%sil
lea    -0x1(%r9),%rax
mov    %sil,-0x1(%r9)
add    $0x1,%r10d
add    $0x9,%rcx
cmp    $0x12,%rcx
mov    %rdx,%rcx
jbe    1186 <nice_number+0x86>
mov    %r10d,%edx
not    %edx
test   $0x3,%dl
jne    1130 <nice_number+0x30>
movb   $0x2c,-0x1(%rax)
add    $0xffffffffffffffff,%rax
add    $0x1,%r10d
jmp    1130 <nice_number+0x30>
test   %rdi,%rdi
js     119d <nice_number+0x9d>
ret
movw   $0x30,0x2e9b(%rip)
lea    0x2e94(%rip),%rax
ret
movb   $0x2d,-0x2(%r9)
add    $0xfffffffffffffffe,%r9
mov    %r9,%rax
ret

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

LLVM IR (-O2):
@nice_number.str = internal global [32 x i8] zeroinitializer
define i8* @nice_number(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %4
3: ; preds = %1
store i16 48, i16* bitcast ([32 x i8]* @nice_number.str to i16*)
br label %31
4: ; preds = %1
%5 = icmp slt i64 %0, 0
%6 = sub nsw i64 0, %0
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nice_number.str, i64 0, i64 31)
%7 = select i1 %5, i64 %6, i64 %0
br label %8
8: ; preds = %4, %17
%9 = phi i32 [ %25, %17 ], [ 0, %4 ]
%10 = phi i64 [ %24, %17 ], [ %7, %4 ]
%11 = phi i8* [ %23, %17 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @nice_number.str, i64 0, i64 31), %4 ]
%12 = and i32 %9, 3
%13 = icmp eq i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = getelementptr inbounds i8, i8* %11, i64 -1
store i8 44, i8* %15
%16 = add nsw i32 %9, 1
br label %17
17: ; preds = %14, %8
%18 = phi i8* [ %15, %14 ], [ %11, %8 ]
%19 = phi i32 [ %16, %14 ], [ %9, %8 ]
%20 = srem i64 %10, 10
%21 = trunc i64 %20 to i8
%22 = add nsw i8 %21, 48
%23 = getelementptr inbounds i8, i8* %18, i64 -1
store i8 %22, i8* %23
%24 = sdiv i64 %10, 10
%25 = add nsw i32 %19, 1
%26 = add i64 %10, 9
%27 = icmp ult i64 %26, 19
br i1 %27, label %28, label %8
28: ; preds = %17
br i1 %5, label %29, label %31
29: ; preds = %28
%30 = getelementptr inbounds i8, i8* %18, i64 -2
store i8 45, i8* %30
br label %31
31: ; preds = %28, %29, %3
%32 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @nice_number.str, i64 0, i64 0), %3 ], [ %30, %29 ], [ %23, %28 ]
ret i8* %32
}