#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 libc_write(int, char *, size_t);
int /*<<< orphan*/ writeString(char *, int);
void writeLongint(long int i) {
  char ch;
  int j;
  if (i < 0) {
    writeString((char *)"-", 1);
    writeLongint(-i);
  } else if (i >= 10) {
    writeLongint(i / 10);
    writeLongint(i % 10);
  } else if (i < 10) {
    ch = ((char)(((unsigned int)('0')) + ((unsigned int)(i))));
    j = libc_write(1, &ch, (size_t)1);
  }
}


x86 assembly (clang, -O0):
<writeLongint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    116a <writeLongint+0x3a>
lea    0xeb2(%rip),%rdi
mov    $0x1,%esi
call   1040 <writeString@plt>
xor    %eax,%eax
mov    %eax,%edi
sub    -0x8(%rbp),%rdi
call   1030 <writeLongint@plt>
jmp    11db <writeLongint+0xab>
cmpq   $0xa,-0x8(%rbp)
jl     11a6 <writeLongint+0x76>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <writeLongint@plt>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,%rdi
call   1030 <writeLongint@plt>
jmp    11d6 <writeLongint+0xa6>
cmpq   $0xa,-0x8(%rbp)
jge    11d1 <writeLongint+0xa1>
mov    -0x8(%rbp),%rax
add    $0x30,%eax
mov    %al,-0x9(%rbp)
mov    $0x1,%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1050 <libc_write@plt>
mov    %eax,-0x10(%rbp)
jmp    11d6 <writeLongint+0xa6>
jmp    11db <writeLongint+0xab>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeLongint>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %rdi,%rdi
js     116d <writeLongint+0x3d>
cmp    $0xa,%rbx
jb     1190 <writeLongint+0x60>
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%r14
shr    $0x3,%r14
mov    %r14,%rdi
call   1030 <writeLongint@plt>
add    %r14,%r14
lea    (%r14,%r14,4),%rax
sub    %rax,%rbx
jmp    1181 <writeLongint+0x51>
lea    0xe8c(%rip),%rdi
mov    $0x1,%esi
call   1040 <writeString@plt>
neg    %rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <writeLongint@plt>
add    $0x30,%bl
mov    %bl,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%edi
call   1050 <libc_write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define void @writeLongint(i64 %0) {
%2 = alloca i64
%3 = alloca i8
%4 = alloca i32
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = load i64, i64* %2
%10 = sub nsw i64 0, %9
br label %30
11: ; preds = %1
%12 = load i64, i64* %2
%13 = icmp sge i64 %12, 10
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i64, i64* %2
%16 = sdiv i64 %15, 10
%17 = load i64, i64* %2
%18 = srem i64 %17, 10
br label %29
19: ; preds = %11
%20 = load i64, i64* %2
%21 = icmp slt i64 %20, 10
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i64, i64* %2
%24 = trunc i64 %23 to i32
%25 = add i32 48, %24
%26 = trunc i32 %25 to i8
store i8 %26, i8* %3
%27 = call i32 @libc_write(i32 1, i8* %3, i64 1)
store i32 %27, i32* %4
br label %28
28: ; preds = %22, %19
br label %29
29: ; preds = %28, %14
br label %30
30: ; preds = %29, %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define void @writeLongint(i64 %0) {
%2 = alloca i8
%3 = icmp slt i64 %0, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @writeString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%6 = sub nsw i64 0, %0
tail call void @writeLongint(i64 %6)
br label %16
7: ; preds = %1
%8 = icmp ugt i64 %0, 9
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = udiv i64 %0, 10
tail call void @writeLongint(i64 %10)
%11 = urem i64 %0, 10
tail call void @writeLongint(i64 %11)
br label %16
12: ; preds = %7
%13 = trunc i64 %0 to i8
%14 = add nuw nsw i8 %13, 48
store i8 %14, i8* %2
%15 = call i32 @libc_write(i32 1, i8* %2, i64 1)
br label %16
16: ; preds = %9, %12, %4
ret void
}