#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 */
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printfcomma(uint64_t n) {
  if (n < 0) {
    printf("N/A");
    return;
  }
  if (n < 1000) {
    printf("%lu", n);
    return;
  }
  printfcomma(n / 1000);
  printf(",%03lu", n % 1000);
}


x86 assembly (clang, -O0):
<printfcomma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1148 <printfcomma+0x28>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <printfcomma+0x78>
cmpl   $0x3e8,-0x4(%rbp)
jge    116b <printfcomma+0x4b>
mov    -0x4(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <printfcomma+0x78>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <printfcomma@plt>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printfcomma>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     113b <printfcomma+0x1b>
mov    %edi,%ebx
cmp    $0x3e7,%edi
ja     1150 <printfcomma+0x30>
lea    0xecb(%rip),%rdi
jmp    1175 <printfcomma+0x55>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
mov    %ebx,%eax
imul   $0x10624dd3,%rax,%r14
shr    $0x26,%r14
mov    %r14d,%edi
call   1040 <printfcomma@plt>
imul   $0x3e8,%r14d,%eax
sub    %eax,%ebx
lea    0xe93(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"N/A\00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [7 x i8] c",%03lu\00"
define void @printfcomma(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %19
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 1000
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %19
13: ; preds = %7
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 1000
%16 = load i32, i32* %2
%17 = srem i32 %16, 1000
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13, %10, %5
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"N/A\00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [7 x i8] c",%03lu\00"
define void @printfcomma(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %9
5: ; preds = %1
%6 = icmp ult i32 %0, 1000
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %3, %7, %10
ret void
10: ; preds = %5
%11 = udiv i32 %0, 1000
tail call void @printfcomma(i32 %11)
%12 = urem i32 %0, 1000
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %9
}