#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 printInt(int number) {
  char output[12] = {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--) {
    write(2, &output[x], 1);
  }
}


x86 assembly (clang, -O0):
<printInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1190 <printInt+0x70>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   $0xa,%ecx,%ecx
sub    %ecx,%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1142 <printInt+0x22>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jle    11c8 <printInt+0xa8>
movslq -0x18(%rbp),%rax
lea    -0x10(%rbp),%rsi
add    %rax,%rsi
mov    $0x2,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1196 <printInt+0x76>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printInt>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
xor    %eax,%eax
test   %edi,%edi
je     116c <printInt+0x5c>
nopl   0x0(%rax,%rax,1)
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rdi
mov    %rdi,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rdi
add    %edx,%edi
lea    (%rdi,%rdi,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
add    $0x30,%sil
mov    %sil,(%rsp,%rax,1)
add    $0x1,%rax
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    1130 <printInt+0x20>
test   $0x80000000,%eax
jne    1189 <printInt+0x79>
mov    %eax,%ebx
xchg   %ax,%ax
lea    (%rsp,%rbx,1),%rsi
mov    $0x2,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0xffffffffffffffff,%rbx
jb     1170 <printInt+0x60>
add    $0x10,%rsp
pop    %rbx
ret

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