#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*/ LLdiv10(unsigned long long, unsigned long long *, int *);
int /*<<< orphan*/ write_char(int);
int write_llint(long long lld) {
  int buf[100];
  int p = 0, ret;
  unsigned long long llu;
  if (lld < 0) {
    write_char('-');
    lld = -lld;
  }
  llu = lld;
  do {
    LLdiv10(llu, &llu, &buf[p++]);
  } while (llu > 0);
  ret = p;
  while (p > 0)
    write_char('0' + buf[--p]);
  return ret;
}


x86 assembly (clang, -O0):
<write_llint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1a4(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    1158 <write_llint+0x38>
mov    $0x2d,%edi
call   1030 <write_char@plt>
xor    %eax,%eax
sub    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rdi
mov    -0x1a4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1a4(%rbp)
cltq
lea    -0x1a0(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    -0x1b0(%rbp),%rsi
call   1040 <LLdiv10@plt>
cmpq   $0x0,-0x1b0(%rbp)
ja     1163 <write_llint+0x43>
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
cmpl   $0x0,-0x1a4(%rbp)
jle    11e3 <write_llint+0xc3>
mov    -0x1a4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a4(%rbp)
cltq
mov    -0x1a0(%rbp,%rax,4),%edi
add    $0x30,%edi
call   1030 <write_char@plt>
jmp    11b1 <write_llint+0x91>
mov    -0x1a8(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_llint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a0,%rsp
mov    %rdi,%r15
test   %rdi,%rdi
jns    1144 <write_llint+0x24>
mov    $0x2d,%edi
call   1030 <write_char@plt>
neg    %r15
mov    %r15,0x8(%rsp)
xor    %r14d,%r14d
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <LLdiv10@plt>
mov    0x8(%rsp),%r15
add    $0x1,%r14d
add    $0x4,%rbx
test   %r15,%r15
jne    1160 <write_llint+0x40>
mov    %r14d,%ebx
add    $0xffffffffffffffff,%rbx
lea    0x1(%r14),%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
mov    0x10(%rsp,%rax,4),%edi
add    $0x30,%edi
call   1030 <write_char@plt>
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%ebp
jg     1190 <write_llint+0x70>
mov    %r14d,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @write_llint(i64 %0) {
%2 = alloca [100 x i32]
%3 = alloca i64
%4 = bitcast [100 x i32]* %2 to i8*
%5 = bitcast i64* %3 to i8*
%6 = icmp slt i64 %0, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @write_char(i32 45)
%9 = sub nsw i64 0, %0
br label %10
10: ; preds = %7, %1
%11 = phi i64 [ %9, %7 ], [ %0, %1 ]
store i64 %11, i64* %3
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ %18, %12 ], [ %11, %10 ]
%14 = phi i64 [ %15, %12 ], [ 0, %10 ]
%15 = add nuw i64 %14, 1
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %14
%17 = call i32 @LLdiv10(i64 %13, i64* %3, i32* %16)
%18 = load i64, i64* %3
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = and i64 %15, 4294967295
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ %21, %20 ], [ %24, %22 ]
%24 = add nsw i64 %23, -1
%25 = and i64 %24, 4294967295
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 48
%29 = call i32 @write_char(i32 %28)
%30 = trunc i64 %23 to i32
%31 = icmp sgt i32 %30, 1
br i1 %31, label %22, label %32
32: ; preds = %22
%33 = trunc i64 %15 to i32
ret i32 %33
}