#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(int);
void printi(int i) {
  int a = i;
  if (i < 0) {
    putchar('-');
    a = -(a % 10);
    printi(-(i / 10));
  }
  if (i > 9) {
    printi(i / 10);
    a = i % 10;
  }
  putchar('0' + a);
}


x86 assembly (clang, -O0):
<printi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    116b <printi+0x4b>
mov    $0x2d,%edi
call   1040 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
sub    %edx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
xor    %edi,%edi
sub    %eax,%edi
call   1030 <printi@plt>
cmpl   $0x9,-0x4(%rbp)
jle    1195 <printi+0x75>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <printi@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%edi
add    $0x30,%edi
call   1040 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printi>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
js     1152 <printi+0x32>
cmp    $0xa,%ebx
jb     1178 <printi+0x58>
mov    %ebx,%eax
mov    $0xcccccccd,%r14d
imul   %rax,%r14
shr    $0x23,%r14
mov    %r14d,%edi
call   1030 <printi@plt>
add    %r14d,%r14d
lea    (%r14,%r14,4),%eax
sub    %eax,%ebx
jmp    1178 <printi+0x58>
mov    $0x2d,%edi
call   1040 <putchar@plt>
neg    %ebx
mov    $0xcccccccd,%edi
imul   %rbx,%rdi
shr    $0x23,%rdi
lea    (%rdi,%rdi,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
call   1030 <printi@plt>
add    $0x30,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <putchar@plt>

LLVM IR (-O0):
define void @printi(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
store i32 %4, i32* %3
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = call i32 @putchar(i32 45)
%9 = load i32, i32* %3
%10 = srem i32 %9, 10
%11 = sub nsw i32 0, %10
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 10
%14 = sub nsw i32 0, %13
br label %15
15: ; preds = %7, %1
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 9
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 10
%21 = load i32, i32* %2
%22 = srem i32 %21, 10
store i32 %22, i32* %3
br label %23
23: ; preds = %18, %15
%24 = load i32, i32* %3
%25 = add nsw i32 48, %24
%26 = call i32 @putchar(i32 %25)
ret void
}

LLVM IR (-O2):
define void @printi(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = tail call i32 @putchar(i32 45)
%5 = sub i32 0, %0
%6 = urem i32 %5, 10
%7 = udiv i32 %5, 10
tail call void @printi(i32 %7)
br label %13
8: ; preds = %1
%9 = icmp ugt i32 %0, 9
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = udiv i32 %0, 10
tail call void @printi(i32 %11)
%12 = urem i32 %0, 10
br label %13
13: ; preds = %3, %10, %8
%14 = phi i32 [ %12, %10 ], [ %0, %8 ], [ %6, %3 ]
%15 = add nuw nsw i32 %14, 48
%16 = tail call i32 @putchar(i32 %15)
ret void
}