#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 *place_commas_in_unsigned_int(unsigned int);
int /*<<< orphan*/ printf(char *, char *);
void test_commas_in_integer(void) {
  unsigned int i;
  i = 116;
  printf("Should be 116 is: %s\n", place_commas_in_unsigned_int(i));
  i = 7116;
  printf("Should be 7,116 is: %s\n", place_commas_in_unsigned_int(i));
  i = 87116;
  printf("Should be 87,116 is: %s\n", place_commas_in_unsigned_int(i));
  i = 987116;
  printf("Should be 987,116 is: %s\n", place_commas_in_unsigned_int(i));
  i = 2987116;
  printf("Should be 2,987,116 is: %s\n", place_commas_in_unsigned_int(i));
}


x86 assembly (clang, -O0):
<test_commas_in_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x74,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <place_commas_in_unsigned_int@plt>
mov    %rax,%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1bcc,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <place_commas_in_unsigned_int@plt>
mov    %rax,%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1544c,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <place_commas_in_unsigned_int@plt>
mov    %rax,%rsi
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
movl   $0xf0fec,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <place_commas_in_unsigned_int@plt>
mov    %rax,%rsi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2d946c,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <place_commas_in_unsigned_int@plt>
mov    %rax,%rsi
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_commas_in_integer>:
push   %rax
mov    $0x74,%edi
call   1040 <place_commas_in_unsigned_int@plt>
lea    0xece(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    $0x1bcc,%edi
call   1040 <place_commas_in_unsigned_int@plt>
lea    0xecb(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    $0x1544c,%edi
call   1040 <place_commas_in_unsigned_int@plt>
lea    0xeca(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    $0xf0fec,%edi
call   1040 <place_commas_in_unsigned_int@plt>
lea    0xeca(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    $0x2d946c,%edi
call   1040 <place_commas_in_unsigned_int@plt>
lea    0xecb(%rip),%rdi
mov    %rax,%rsi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Should be 116 is: %s\0A\00"
@.str.1 = [24 x i8] c"Should be 7,116 is: %s\0A\00"
@.str.2 = [25 x i8] c"Should be 87,116 is: %s\0A\00"
@.str.3 = [26 x i8] c"Should be 987,116 is: %s\0A\00"
@.str.4 = [28 x i8] c"Should be 2,987,116 is: %s\0A\00"
define void @test_commas_in_integer() {
%1 = alloca i32
store i32 116, i32* %1
%2 = load i32, i32* %1
%3 = call i8* @place_commas_in_unsigned_int(i32 %2)
%4 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
store i32 7116, i32* %1
%5 = load i32, i32* %1
%6 = call i8* @place_commas_in_unsigned_int(i32 %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %6)
store i32 87116, i32* %1
%8 = load i32, i32* %1
%9 = call i8* @place_commas_in_unsigned_int(i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %9)
store i32 987116, i32* %1
%11 = load i32, i32* %1
%12 = call i8* @place_commas_in_unsigned_int(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %12)
store i32 2987116, i32* %1
%14 = load i32, i32* %1
%15 = call i8* @place_commas_in_unsigned_int(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %15)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Should be 116 is: %s\0A\00"
@.str.1 = [24 x i8] c"Should be 7,116 is: %s\0A\00"
@.str.2 = [25 x i8] c"Should be 87,116 is: %s\0A\00"
@.str.3 = [26 x i8] c"Should be 987,116 is: %s\0A\00"
@.str.4 = [28 x i8] c"Should be 2,987,116 is: %s\0A\00"
define void @test_commas_in_integer() {
%1 = tail call i8* @place_commas_in_unsigned_int(i32 116)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = tail call i8* @place_commas_in_unsigned_int(i32 7116)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = tail call i8* @place_commas_in_unsigned_int(i32 87116)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = tail call i8* @place_commas_in_unsigned_int(i32 987116)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = tail call i8* @place_commas_in_unsigned_int(i32 2987116)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %9)
ret void
}