#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 */
scalar_t__ naive_isdigit(char);
scalar_t__ read_char(char *);
int /*<<< orphan*/ read_space();
int /*<<< orphan*/ unread_char(char);
int read_llint(long long *lldp) {
  int flag = 0;
  long long lld = 0;
  int f = 0;
  char c = '\0';
  read_space();
  read_char(&c);
  if (c == '-')
    f = 1;
  else
    unread_char(c);
  while (read_char(&c) && naive_isdigit(c)) {
    lld = lld * 10 + (c - '0');
    flag = 1;
  }
  if (c)
    unread_char(c);
  if (flag)
    *lldp = f ? -lld : lld;
  if (!flag && f)
    unread_char('-');
  return flag;
}


x86 assembly (clang, -O0):
<read_llint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x1d(%rbp)
mov    $0x0,%al
call   1040 <read_space@plt>
lea    -0x1d(%rbp),%rdi
call   1050 <read_char@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x2d,%eax
jne    118f <read_llint+0x4f>
movl   $0x1,-0x1c(%rbp)
jmp    1198 <read_llint+0x58>
movsbl -0x1d(%rbp),%edi
call   1060 <unread_char@plt>
jmp    119d <read_llint+0x5d>
lea    -0x1d(%rbp),%rdi
call   1050 <read_char@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1e(%rbp)
je     11cb <read_llint+0x8b>
movsbl -0x1d(%rbp),%edi
call   1030 <naive_isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    11db <read_llint+0x9b>
jmp    11fd <read_llint+0xbd>
imul   $0xa,-0x18(%rbp),%rax
movsbl -0x1d(%rbp),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    119d <read_llint+0x5d>
cmpb   $0x0,-0x1d(%rbp)
je     1210 <read_llint+0xd0>
movsbl -0x1d(%rbp),%edi
call   1060 <unread_char@plt>
cmpl   $0x0,-0xc(%rbp)
je     1246 <read_llint+0x106>
cmpl   $0x0,-0x1c(%rbp)
je     1233 <read_llint+0xf3>
xor    %eax,%eax
sub    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    123b <read_llint+0xfb>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x0,-0xc(%rbp)
jne    1264 <read_llint+0x124>
cmpl   $0x0,-0x1c(%rbp)
je     1264 <read_llint+0x124>
mov    $0x2d,%edi
call   1060 <unread_char@plt>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_llint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
movb   $0x0,0xf(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <read_space@plt>
lea    0xf(%rsp),%rdi
call   1050 <read_char@plt>
mov    0xf(%rsp),%r12b
cmp    $0x2d,%r12b
je     117b <read_llint+0x3b>
movsbl %r12b,%edi
call   1060 <unread_char@plt>
lea    0xf(%rsp),%rdi
call   1050 <read_char@plt>
mov    $0x1,%r15b
test   %rax,%rax
je     11f1 <read_llint+0xb1>
movsbl 0xf(%rsp),%edi
call   1030 <naive_isdigit@plt>
test   %rax,%rax
je     11ef <read_llint+0xaf>
xor    %ebp,%ebp
lea    0xf(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x0(,%rbp,4),%rax
add    %rbp,%rax
movsbq 0xf(%rsp),%rcx
lea    (%rcx,%rax,2),%rbp
add    $0xffffffffffffffd0,%rbp
mov    %r15,%rdi
call   1050 <read_char@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     11ea <read_llint+0xaa>
movsbl 0xf(%rsp),%edi
call   1030 <naive_isdigit@plt>
test   %rax,%rax
jne    11b0 <read_llint+0x70>
xor    %r15d,%r15d
jmp    11f3 <read_llint+0xb3>
xor    %ebx,%ebx
xor    %ebp,%ebp
mov    0xf(%rsp),%al
test   %al,%al
je     1203 <read_llint+0xc3>
movsbl %al,%edi
call   1060 <unread_char@plt>
test   %r15b,%r15b
je     121a <read_llint+0xda>
cmp    $0x2d,%r12b
jne    122b <read_llint+0xeb>
mov    $0x2d,%edi
call   1060 <unread_char@plt>
jmp    122b <read_llint+0xeb>
mov    %rbp,%rax
neg    %rax
cmp    $0x2d,%r12b
cmovne %rbp,%rax
mov    %rax,(%r14)
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_llint(i64* %0) {
%2 = alloca i64*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8
store i64* %0, i64** %2
store i32 0, i32* %3
store i64 0, i64* %4
store i32 0, i32* %5
store i8 0, i8* %6
%7 = call i32 (...) @read_space()
%8 = call i64 @read_char(i8* %6)
%9 = load i8, i8* %6
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 1, i32* %5
br label %16
13: ; preds = %1
%14 = load i8, i8* %6
%15 = call i32 @unread_char(i8 signext %14)
br label %16
16: ; preds = %13, %12
br label %17
17: ; preds = %26, %16
%18 = call i64 @read_char(i8* %6)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i8, i8* %6
%22 = call i64 @naive_isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %34
26: ; preds = %24
%27 = load i64, i64* %4
%28 = mul nsw i64 %27, 10
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 48
%32 = sext i32 %31 to i64
%33 = add nsw i64 %28, %32
store i64 %33, i64* %4
store i32 1, i32* %3
br label %17
34: ; preds = %24
%35 = load i8, i8* %6
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i8, i8* %6
%39 = call i32 @unread_char(i8 signext %38)
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %3
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %40
%44 = load i32, i32* %5
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i64, i64* %4
%48 = sub nsw i64 0, %47
br label %51
49: ; preds = %43
%50 = load i64, i64* %4
br label %51
51: ; preds = %49, %46
%52 = phi i64 [ %48, %46 ], [ %50, %49 ]
%53 = load i64*, i64** %2
store i64 %52, i64* %53
br label %54
54: ; preds = %51, %40
%55 = load i32, i32* %3
%56 = icmp ne i32 %55, 0
br i1 %56, label %62, label %57
57: ; preds = %54
%58 = load i32, i32* %5
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @unread_char(i8 signext 45)
br label %62
62: ; preds = %60, %57, %54
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
define i32 @read_llint(i64* nocapture writeonly %0) {
%2 = alloca i8
store i8 0, i8* %2
%3 = tail call i32 (...) @read_space()
%4 = call i64 @read_char(i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 45
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @unread_char(i8 signext %5)
br label %9
9: ; preds = %1, %7
%10 = call i64 @read_char(i8* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %9
%13 = load i8, i8* %2
%14 = call i64 @naive_isdigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %29, label %20
16: ; preds = %20
%17 = load i8, i8* %2
%18 = call i64 @naive_isdigit(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %12, %16
%21 = phi i64 [ %26, %16 ], [ 0, %12 ]
%22 = mul nsw i64 %21, 10
%23 = load i8, i8* %2
%24 = sext i8 %23 to i64
%25 = add i64 %22, -48
%26 = add i64 %25, %24
%27 = call i64 @read_char(i8* %2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %16
29: ; preds = %20, %16, %12, %9
%30 = phi i1 [ true, %9 ], [ true, %12 ], [ false, %16 ], [ false, %20 ]
%31 = phi i32 [ 0, %9 ], [ 0, %12 ], [ 1, %16 ], [ 1, %20 ]
%32 = phi i64 [ 0, %9 ], [ 0, %12 ], [ %26, %16 ], [ %26, %20 ]
%33 = load i8, i8* %2
%34 = icmp eq i8 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %29
%36 = call i32 @unread_char(i8 signext %33)
br label %37
37: ; preds = %35, %29
br i1 %30, label %41, label %38
38: ; preds = %37
%39 = sub nsw i64 0, %32
%40 = select i1 %6, i64 %39, i64 %32
store i64 %40, i64* %0
br label %44
41: ; preds = %37
br i1 %6, label %42, label %44
42: ; preds = %41
%43 = call i32 @unread_char(i8 signext 45)
br label %44
44: ; preds = %38, %42, %41
ret i32 %31
}