#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*/ putchar_unlocked(char);
void printint(long long n) {
  if (n == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
  } else if (n == -1) {
    putchar_unlocked('-');
    putchar_unlocked('1');
    putchar_unlocked('\n');
  } else {
    char buf[11];
    buf[10] = '\n';
    int i = 9;
    while (n) {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar_unlocked(buf[++i]);
  }
}


x86 assembly (clang, -O0):
<printint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1140 <printint+0x30>
mov    $0x30,%edi
call   1030 <putchar_unlocked@plt>
mov    $0xa,%edi
call   1030 <putchar_unlocked@plt>
jmp    11fb <printint+0xeb>
cmpq   $0xffffffffffffffff,-0x8(%rbp)
jne    116e <printint+0x5e>
mov    $0x2d,%edi
call   1030 <putchar_unlocked@plt>
mov    $0x31,%edi
call   1030 <putchar_unlocked@plt>
mov    $0xa,%edi
call   1030 <putchar_unlocked@plt>
jmp    11f6 <printint+0xe6>
movb   $0xa,-0x9(%rbp)
movl   $0x9,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c0 <printint+0xb0>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x13(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
jmp    1179 <printint+0x69>
jmp    11c5 <printint+0xb5>
movslq -0x18(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11f1 <printint+0xe1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cltq
movsbl -0x13(%rbp,%rax,1),%edi
call   1030 <putchar_unlocked@plt>
jmp    11c5 <printint+0xb5>
jmp    11f6 <printint+0xe6>
jmp    11fb <printint+0xeb>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printint>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
cmp    $0xffffffffffffffff,%rdi
je     1128 <printint+0x18>
test   %rdi,%rdi
jne    114c <printint+0x3c>
mov    $0x30,%edi
jmp    1137 <printint+0x27>
mov    $0x2d,%edi
call   1030 <putchar_unlocked@plt>
mov    $0x31,%edi
call   1030 <putchar_unlocked@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar_unlocked@plt>
movb   $0xa,0x17(%rsp)
mov    $0x9,%ecx
movabs $0x900000000,%rsi
movabs $0x6666666666666667,%r8
66 66 66
movabs $0xffffffff00000000,%rbx
ff ff ff
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rdi,%rax
imul   %r8
add    %rbx,%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,%ebp
sub    %eax,%ebp
add    $0x30,%bpl
mov    %bpl,0xd(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rcx
add    $0x9,%rdi
cmp    $0x13,%rdi
mov    %rdx,%rdi
jae    1180 <printint+0x70>
sar    $0x20,%rsi
cmpb   $0xa,0xd(%rsp,%rsi,1)
je     11f3 <printint+0xe3>
movslq %ecx,%rax
lea    (%rsp,%rax,1),%rbx
add    $0xe,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%ebp
mov    %ebp,%edi
call   1030 <putchar_unlocked@plt>
add    $0x1,%rbx
cmp    $0xa,%ebp
jne    11e0 <printint+0xd0>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @printint(i64 %0) {
%2 = alloca [11 x i8]
switch i64 %0, label %10 [
i64 0, label %3
i64 -1, label %6
]
3: ; preds = %1
%4 = tail call i32 @putchar_unlocked(i8 signext 48)
%5 = tail call i32 @putchar_unlocked(i8 signext 10)
br label %38
6: ; preds = %1
%7 = tail call i32 @putchar_unlocked(i8 signext 45)
%8 = tail call i32 @putchar_unlocked(i8 signext 49)
%9 = tail call i32 @putchar_unlocked(i8 signext 10)
br label %38
10: ; preds = %1
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 10
store i8 10, i8* %12
br label %19
13: ; preds = %19
%14 = shl i64 %25, 32
%15 = ashr exact i64 %14, 32
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
br i1 %18, label %37, label %30
19: ; preds = %10, %19
%20 = phi i64 [ 9, %10 ], [ %25, %19 ]
%21 = phi i64 [ %0, %10 ], [ %27, %19 ]
%22 = srem i64 %21, 10
%23 = trunc i64 %22 to i8
%24 = add nsw i8 %23, 48
%25 = add i64 %20, -1
%26 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %20
store i8 %24, i8* %26
%27 = sdiv i64 %21, 10
%28 = add i64 %21, 9
%29 = icmp ult i64 %28, 19
br i1 %29, label %13, label %19
30: ; preds = %13, %30
%31 = phi i64 [ %32, %30 ], [ %15, %13 ]
%32 = add i64 %31, 1
%33 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = tail call i32 @putchar_unlocked(i8 signext %34)
%36 = icmp eq i8 %34, 10
br i1 %36, label %37, label %30
37: ; preds = %30, %13
br label %38
38: ; preds = %6, %37, %3
ret void
}