#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*/ write(int, char *, int);
void printLong(long number) {
  char output[20] = {0};
  int length = 0;
  while (number != 0) {
    output[length] = (char)((number - (((long)(number / 10)) * 10)) + 48);
    length++;
    number /= 10;
  }
  for (int x = length; x > -1; x--) {
    write(2, &output[x], 1);
  }
}


x86 assembly (clang, -O0):
<printLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11a0 <printLong+0x80>
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,%rcx,%rcx
sub    %rcx,%rax
add    $0x30,%rax
mov    %al,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
jmp    1143 <printLong+0x23>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jle    11d8 <printLong+0xb8>
movslq -0x28(%rbp),%rax
lea    -0x20(%rbp),%rsi
add    %rax,%rsi
mov    $0x2,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    11a6 <printLong+0x86>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLong>:
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
xor    %ecx,%ecx
test   %rdi,%rdi
je     117d <printLong+0x6d>
movabs $0x6666666666666667,%rsi
66 66 66
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdi,%rax
imul   %rsi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%ebx
sub    %eax,%ebx
add    $0x30,%bl
mov    %bl,(%rsp,%rcx,1)
add    $0x1,%rcx
add    $0x9,%rdi
cmp    $0x13,%rdi
mov    %rdx,%rdi
jae    1140 <printLong+0x30>
test   $0x80000000,%ecx
jne    1199 <printLong+0x89>
mov    %ecx,%ebx
nop
lea    (%rsp,%rbx,1),%rsi
mov    $0x2,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0xffffffffffffffff,%rbx
jb     1180 <printLong+0x70>
add    $0x20,%rsp
pop    %rbx
ret

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

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