#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*/ strcat(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void printLongInt(long int number, char *buffer) {
  char output[11] = {0};
  int length = 0;
  while (number != 0) {
    output[length] = (char)((number - (((int)(number / 10)) * 10)) + 48);
    length++;
    number /= 10;
  }
  int x;
  for (x = length; x > -1; x--) {
    strncat(buffer, &output[x], 1);
  }
  strcat(buffer, "\0");
}


x86 assembly (clang, -O0):
<printLongInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1030 <memset@plt>
movl   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11b6 <printLongInt+0x86>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
imul   $0xa,%ecx,%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
add    $0x30,%rax
mov    %al,%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x1b(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
jmp    1157 <printLongInt+0x27>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jle    11ed <printLongInt+0xbd>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
lea    -0x1b(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <printLongInt+0x8c>
mov    -0x10(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1050 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLongInt>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
movl   $0x0,0xf(%rsp)
movq   $0x0,0x8(%rsp)
xor    %ecx,%ecx
test   %rdi,%rdi
je     1197 <printLongInt+0x77>
movabs $0x6666666666666667,%rsi
66 66 66
nopl   0x0(%rax)
mov    %rdi,%rax
imul   %rsi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
mov    %rdx,%rax
shl    $0x21,%rax
lea    (%rax,%rax,4),%rax
shr    $0x20,%rax
mov    %edi,%ebx
sub    %eax,%ebx
add    $0x30,%bl
mov    %bl,0x8(%rsp,%rcx,1)
add    $0x1,%rcx
add    $0x9,%rdi
cmp    $0x13,%rdi
mov    %rdx,%rdi
jae    1150 <printLongInt+0x30>
test   $0x80000000,%ecx
jne    11bb <printLongInt+0x9b>
mov    %ecx,%ebx
nopl   0x0(%rax)
lea    (%rsp,%rbx,1),%rsi
add    $0x8,%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1030 <strncat@plt>
add    $0xffffffffffffffff,%rbx
jb     11a0 <printLongInt+0x80>
lea    0xe3e(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] zeroinitializer
define void @printLongInt(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca [11 x i8]
%6 = alloca i32
%7 = alloca i32
store i64 %0, i64* %3
store i8* %1, i8** %4
%8 = bitcast [11 x i8]* %5 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %12, %2
%10 = load i64, i64* %3
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load i64, i64* %3
%14 = load i64, i64* %3
%15 = sdiv i64 %14, 10
%16 = trunc i64 %15 to i32
%17 = mul nsw i32 %16, 10
%18 = sext i32 %17 to i64
%19 = sub nsw i64 %13, %18
%20 = add nsw i64 %19, 48
%21 = trunc i64 %20 to i8
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 %23
store i8 %21, i8* %24
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
%27 = load i64, i64* %3
%28 = sdiv i64 %27, 10
store i64 %28, i64* %3
br label %9
29: ; preds = %9
%30 = load i32, i32* %6
store i32 %30, i32* %7
br label %31
31: ; preds = %40, %29
%32 = load i32, i32* %7
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i8*, i8** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 %37
%39 = call i32 @strncat(i8* %35, i8* %38, i32 1)
br label %40
40: ; preds = %34
%41 = load i32, i32* %7
%42 = add nsw i32 %41, -1
store i32 %42, i32* %7
br label %31
43: ; preds = %31
%44 = load i8*, i8** %4
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] zeroinitializer
define void @printLongInt(i64 %0, i8* %1) {
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = icmp eq i64 %0, 0
br i1 %5, label %9, label %12
6: ; preds = %12
%7 = and i64 %22, 2147483648
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %2, %6
%10 = phi i64 [ %22, %6 ], [ 0, %2 ]
%11 = and i64 %10, 4294967295
br label %25
12: ; preds = %2, %12
%13 = phi i64 [ %22, %12 ], [ 0, %2 ]
%14 = phi i64 [ %15, %12 ], [ %0, %2 ]
%15 = sdiv i64 %14, 10
%16 = mul i64 %15, 42949672960
%17 = lshr exact i64 %16, 32
%18 = sub i64 %14, %17
%19 = trunc i64 %18 to i8
%20 = add i8 %19, 48
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 %13
store i8 %20, i8* %21
%22 = add nuw i64 %13, 1
%23 = add i64 %14, 9
%24 = icmp ult i64 %23, 19
br i1 %24, label %6, label %12
25: ; preds = %9, %25
%26 = phi i64 [ %11, %9 ], [ %29, %25 ]
%27 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 %26
%28 = call i32 @strncat(i8* %1, i8* %27, i32 1)
%29 = add nsw i64 %26, -1
%30 = icmp eq i64 %26, 0
br i1 %30, label %31, label %25
31: ; preds = %25, %6
%32 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}