#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(char);
void print(int n) {
  if (n < 0) {
    n = -n;
    putchar('-');
  }
  int i = 10;
  char o[10];
  do {
    o[--i] = (n % 10) + '0';
    n /= 10;
  } while (n);
  do {
    putchar(o[i]);
  } while (++i < 10);
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1137 <print+0x27>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x2d,%edi
call   1030 <putchar@plt>
movl   $0xa,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cltq
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113e <print+0x2e>
jmp    117a <print+0x6a>
movslq -0x8(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
jl     117a <print+0x6a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
test   %edi,%edi
jns    112b <print+0x1b>
neg    %ebx
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0xfffffff7,%r8d
mov    $0xa,%ecx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movslq %ebx,%rsi
imul   $0x66666667,%rsi,%rbx
mov    %rbx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rbx
add    %edi,%ebx
lea    (%rbx,%rbx,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %esi,%eax
sub    %edi,%eax
add    $0x30,%al
mov    %al,0xf(%rsp,%rdx,1)
add    $0x9,%esi
add    $0x1,%r8d
add    $0xffffffff,%ecx
add    $0xffffffffffffffff,%rdx
cmp    $0x12,%esi
ja     1140 <print+0x30>
add    $0xa,%edx
movslq %edx,%rax
lea    (%rsp,%rax,1),%r14
add    $0x6,%r14
cmp    $0xa,%ecx
mov    $0x9,%r15d
cmovge %ecx,%r15d
add    %r8d,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    11a0 <print+0x90>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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