#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);
int /*<<< orphan*/ write_int_(int, int);
void write_int(int fd, int n) {
  if (n == 0) {
    write(fd, "0", 1);
  } else {
    if (n < 0) {
      write(fd, "-", 1);
      write_int_(fd, -n);
    } else {
      write_int_(fd, n);
    }
  }
}


x86 assembly (clang, -O0):
<write_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1151 <write_int+0x31>
mov    -0x4(%rbp),%edi
lea    0xebe(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    1191 <write_int+0x71>
cmpl   $0x0,-0x8(%rbp)
jge    1181 <write_int+0x61>
mov    -0x4(%rbp),%edi
lea    0xe9d(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
sub    -0x8(%rbp),%esi
call   1040 <write_int_@plt>
jmp    118c <write_int+0x6c>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <write_int_@plt>
jmp    1191 <write_int+0x71>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_int>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
test   %esi,%esi
je     1151 <write_int+0x31>
mov    %esi,%ebp
jns    1142 <write_int+0x22>
lea    0xece(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
neg    %ebp
mov    %ebx,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <write_int_@plt>
lea    0xea8(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <write@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"-\00"
define void @write_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* %3
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %25
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %3
%15 = call i32 @write(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = sub nsw i32 0, %17
%19 = call i32 @write_int_(i32 %16, i32 %18)
br label %24
20: ; preds = %10
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @write_int_(i32 %21, i32 %22)
br label %24
24: ; preds = %20, %13
br label %25
25: ; preds = %24, %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"-\00"
define void @write_int(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %14
6: ; preds = %2
%7 = icmp slt i32 %1, 0
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = sub nsw i32 0, %1
%11 = tail call i32 @write_int_(i32 %0, i32 %10)
br label %14
12: ; preds = %6
%13 = tail call i32 @write_int_(i32 %0, i32 %1)
br label %14
14: ; preds = %8, %12, %4
ret void
}