#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 getchar();
int /*<<< orphan*/ sscanf(char *, char *, int *);
int input_int(void) {
  int c;
  char line[200];
  int done;
  int val;
  int i;
  int isdigit(int);
  for (i = 0; i < 200; i++) {
    line[i] = '\0';
  }
  i = 0;
  done = 0;
  while (!done) {
    c = getchar();
    if (c >= 0 && c <= 127) {
      line[i] = (char)c;
      if (isdigit(line[i]) || line[i] == '-') {
        i++;
      } else if (i != 0) {
        done = 1;
      }
    } else {
      done = 1;
    }
  }
  (void)sscanf(line, "%d", &val);
  return (val);
}


x86 assembly (clang, -O0):
<input_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0xdc(%rbp)
cmpl   $0xc8,-0xdc(%rbp)
jge    1178 <input_int+0x48>
movslq -0xdc(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    1145 <input_int+0x15>
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xd4(%rbp)
cmpl   $0x0,-0xd4(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a5 <input_int+0x75>
jmp    124f <input_int+0x11f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1240 <input_int+0x110>
cmpl   $0x7f,-0x4(%rbp)
jg     1240 <input_int+0x110>
mov    -0x4(%rbp),%eax
mov    %al,%cl
movslq -0xdc(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
movslq -0xdc(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    120b <input_int+0xdb>
movslq -0xdc(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%eax
ff
cmp    $0x2d,%eax
jne    121f <input_int+0xef>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    123b <input_int+0x10b>
cmpl   $0x0,-0xdc(%rbp)
je     1236 <input_int+0x106>
movl   $0x1,-0xd4(%rbp)
jmp    123b <input_int+0x10b>
jmp    124a <input_int+0x11a>
movl   $0x1,-0xd4(%rbp)
jmp    118c <input_int+0x5c>
lea    -0xd0(%rbp),%rdi
lea    0xda3(%rip),%rsi
lea    -0xd8(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0xd8(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_int>:
push   %rbx
sub    $0xe0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xc0(%rsp)
movq   $0x0,0xd0(%rsp)
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x7f,%eax
ja     11c8 <input_int+0xa8>
lea    -0x30(%rax),%esi
cmp    $0xa,%esi
setb   %cl
cmp    $0x2d,%eax
sete   %dl
or     %cl,%dl
movzbl %dl,%ecx
add    %ebx,%ecx
mov    %ebx,%edx
mov    %al,0x10(%rsp,%rdx,1)
cmp    $0x2d,%eax
je     1190 <input_int+0x70>
cmp    $0xa,%esi
jb     1190 <input_int+0x70>
test   %ebx,%ebx
je     1190 <input_int+0x70>
lea    0xe31(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%eax
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @input_int() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %5
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 200
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %11
store i8 0, i8* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
br label %6
16: ; preds = %6
store i32 0, i32* %5
store i32 0, i32* %3
br label %17
17: ; preds = %58, %16
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %59
21: ; preds = %17
%22 = call i32 (...) @getchar()
store i32 %22, i32* %1
%23 = load i32, i32* %1
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %57
25: ; preds = %21
%26 = load i32, i32* %1
%27 = icmp sle i32 %26, 127
br i1 %27, label %28, label %57
28: ; preds = %25
%29 = load i32, i32* %1
%30 = trunc i32 %29 to i8
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %32
store i8 %30, i8* %33
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 @isdigit(i32 %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %48, label %41
41: ; preds = %28
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 45
br i1 %47, label %48, label %51
48: ; preds = %41, %28
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %56
51: ; preds = %41
%52 = load i32, i32* %5
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 1, i32* %3
br label %55
55: ; preds = %54, %51
br label %56
56: ; preds = %55, %48
br label %58
57: ; preds = %25, %21
store i32 1, i32* %3
br label %58
58: ; preds = %57, %56
br label %17
59: ; preds = %17
%60 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%61 = call i32 @sscanf(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @input_int() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = alloca i32
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %0, %10
%7 = phi i32 [ %21, %10 ], [ 0, %0 ]
%8 = tail call i32 (...) @getchar()
%9 = icmp ult i32 %8, 128
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = trunc i32 %8 to i8
%12 = zext i32 %7 to i64
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %12
store i8 %11, i8* %13
%14 = add nsw i32 %8, -48
%15 = icmp ult i32 %14, 10
%16 = icmp eq i32 %8, 45
%17 = or i1 %16, %15
%18 = icmp eq i32 %7, 0
%19 = or i1 %16, %15
%20 = zext i1 %17 to i32
%21 = add nuw nsw i32 %7, %20
%22 = select i1 %19, i1 true, i1 %18
br i1 %22, label %6, label %23
23: ; preds = %6, %10
%24 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
ret i32 %25
}