#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int getc(int /*<<< orphan*/ *);
scalar_t__ isdigit(int);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int readint(FILE *inp) {
  int c, n;
  while (1) {
    c = getc(inp);
    if (isdigit(c)) {
      ungetc(c, inp);
      break;
    }
    if (c == '#')
      while (c >= ' ')
        c = getc(inp);
    if (c == EOF)
      return -1;
  }
  fscanf(inp, "%d", &n);
  return n;
}


x86 assembly (clang, -O0):
<readint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     117b <readint+0x3b>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <ungetc@plt>
jmp    11cd <readint+0x8d>
cmpl   $0x23,-0x14(%rbp)
jne    11aa <readint+0x6a>
jmp    118a <readint+0x4a>
cmpl   $0x20,-0x14(%rbp)
jl     11a5 <readint+0x65>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    118a <readint+0x4a>
jmp    11aa <readint+0x6a>
mov    -0x14(%rbp),%eax
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%eax
jne    11c8 <readint+0x88>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <readint+0xa7>
jmp    114c <readint+0xc>
mov    -0x10(%rbp),%rdi
lea    0xe28(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readint>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e96(%rip),%r14
jmp    1165 <readint+0x25>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    (%r14),%ebp
je     1191 <readint+0x51>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1198 <readint+0x58>
cmp    $0x23,%ebp
jne    1160 <readint+0x20>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    $0x1f,%eax
jg     1180 <readint+0x40>
mov    %eax,%ebp
jmp    1160 <readint+0x20>
mov    $0xffffffff,%eax
jmp    11ba <readint+0x7a>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
lea    0xe57(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [3 x i8] c"%d\00"
define i32 @readint(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
br label %6
6: ; preds = %1, %32
%7 = load i32*, i32** %3
%8 = call i32 @getc(i32* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = call i64 @isdigit(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i32, i32* %4
%14 = load i32*, i32** %3
%15 = call i32 @ungetc(i32 %13, i32* %14)
br label %33
16: ; preds = %6
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 35
br i1 %18, label %19, label %27
19: ; preds = %16
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %4
%22 = icmp sge i32 %21, 32
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32*, i32** %3
%25 = call i32 @getc(i32* %24)
store i32 %25, i32* %4
br label %20
26: ; preds = %20
br label %27
27: ; preds = %26, %16
%28 = load i32, i32* %4
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %2
br label %37
32: ; preds = %27
br label %6
33: ; preds = %12
%34 = load i32*, i32** %3
%35 = call i32 @fscanf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%36 = load i32, i32* %5
store i32 %36, i32* %2
br label %37
37: ; preds = %33, %31
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [3 x i8] c"%d\00"
define i32 @readint(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %17, %1
%5 = tail call i32 @getc(i32* %0)
%6 = tail call i64 @isdigit(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i32 @ungetc(i32 %5, i32* %0)
%10 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
br label %21
12: ; preds = %4
%13 = icmp eq i32 %5, 35
br i1 %13, label %14, label %17
14: ; preds = %12, %14
%15 = tail call i32 @getc(i32* %0)
%16 = icmp sgt i32 %15, 31
br i1 %16, label %14, label %17
17: ; preds = %14, %12
%18 = phi i32 [ %5, %12 ], [ %15, %14 ]
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %4
21: ; preds = %17, %8
%22 = phi i32 [ %11, %8 ], [ -1, %17 ]
ret i32 %22
}