#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*/ put(char);
void prn(int n) {
  char c[11];
  char *p;
  char sign;
  if (n < 0) {
    n = -n;
    sign = '-';
  } else {
    sign = '\0';
  }
  p = c;
  while (n > 0) {
    *p++ = n % 10 + '0';
    n /= 10;
  }
  if (sign != '\0')
    put(sign);
  while (p >= c) {
    put(*--p);
  }
}


x86 assembly (clang, -O0):
<prn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1136 <prn+0x26>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movb   $0x2d,-0x19(%rbp)
jmp    113a <prn+0x2a>
movb   $0x0,-0x19(%rbp)
lea    -0xf(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1180 <prn+0x70>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1142 <prn+0x32>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     1196 <prn+0x86>
movsbl -0x19(%rbp),%edi
call   1030 <put@plt>
jmp    119b <prn+0x8b>
mov    -0x18(%rbp),%rax
lea    -0xf(%rbp),%rcx
cmp    %rcx,%rax
jb     11c9 <prn+0xb9>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movsbl -0x1(%rax),%edi
call   1030 <put@plt>
jmp    119b <prn+0x8b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prn>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ecx
neg    %ecx
cmovs  %edi,%ecx
lea    0xd(%rsp),%rbx
test   %ecx,%ecx
je     1153 <prn+0x43>
mov    $0xcccccccd,%r8d
nopl   (%rax)
mov    %ecx,%edx
imul   %r8,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %ecx,%eax
sub    %esi,%eax
or     $0x30,%al
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    $0x9,%ecx
mov    %edx,%ecx
ja     1130 <prn+0x20>
test   %edi,%edi
jns    1167 <prn+0x57>
sar    $0x1f,%edi
and    $0x2d,%dil
movzbl %dil,%edi
call   1030 <put@plt>
lea    0xd(%rsp),%r14
cmp    %r14,%rbx
jb     1192 <prn+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1030 <put@plt>
cmp    %r14,%rbx
jae    1180 <prn+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @prn(i32 %0) {
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%4 = icmp slt i32 %0, 0
%5 = sub nsw i32 0, %0
%6 = select i1 %4, i32 %5, i32 %0
%7 = select i1 %4, i8 45, i8 0
%8 = icmp eq i32 %6, 0
br i1 %8, label %18, label %9
9: ; preds = %1, %9
%10 = phi i8* [ %15, %9 ], [ %3, %1 ]
%11 = phi i32 [ %16, %9 ], [ %6, %1 ]
%12 = urem i32 %11, 10
%13 = trunc i32 %12 to i8
%14 = or i8 %13, 48
%15 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %14, i8* %10
%16 = udiv i32 %11, 10
%17 = icmp ult i32 %11, 10
br i1 %17, label %18, label %9
18: ; preds = %9, %1
%19 = phi i8* [ %3, %1 ], [ %15, %9 ]
br i1 %4, label %20, label %22
20: ; preds = %18
%21 = tail call i32 @put(i8 signext %7)
br label %22
22: ; preds = %20, %18
%23 = icmp ult i8* %19, %3
br i1 %23, label %30, label %24
24: ; preds = %22, %24
%25 = phi i8* [ %26, %24 ], [ %19, %22 ]
%26 = getelementptr inbounds i8, i8* %25, i64 -1
%27 = load i8, i8* %26
%28 = call i32 @put(i8 signext %27)
%29 = icmp ult i8* %26, %3
br i1 %29, label %30, label %24
30: ; preds = %24, %22
ret void
}