#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 *, unsigned long *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ isdigit(int);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
unsigned long getint(FILE *f) {
  int c;
  unsigned long i;
  while ((c = getc(f)) != EOF && !isdigit(c))
    if (c == '#')
      while ((c = getc(f)) != EOF && !(c == 13 || c == 10))
        ;
  if (c != EOF) {
    ungetc(c, f);
    fscanf(f, "%lu", &i);
  }
  return i;
}


x86 assembly (clang, -O0):
<getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
mov    0x2e85(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x19(%rbp)
je     1181 <getint+0x41>
mov    -0xc(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1191 <getint+0x51>
jmp    1202 <getint+0xc2>
cmpl   $0x23,-0xc(%rbp)
jne    11fd <getint+0xbd>
jmp    11a0 <getint+0x60>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
mov    0x2e31(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x1a(%rbp)
je     11e3 <getint+0xa3>
mov    $0x1,%al
cmpl   $0xd,-0xc(%rbp)
mov    %al,-0x1b(%rbp)
je     11db <getint+0x9b>
cmpl   $0xa,-0xc(%rbp)
sete   %al
mov    %al,-0x1b(%rbp)
mov    -0x1b(%rbp),%al
xor    $0xff,%al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11f3 <getint+0xb3>
jmp    11f8 <getint+0xb8>
jmp    11a0 <getint+0x60>
jmp    11fd <getint+0xbd>
jmp    114c <getint+0xc>
mov    -0xc(%rbp),%eax
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%eax
je     1234 <getint+0xf4>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <ungetc@plt>
mov    -0x8(%rbp),%rdi
lea    0xdd5(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getint>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <getc@plt>
mov    0x2ea5(%rip),%r14
mov    (%r14),%edx
cmp    %edx,%eax
je     11a9 <getint+0x79>
mov    %eax,%ecx
add    $0xffffffc6,%ecx
cmp    $0xfffffff5,%ecx
ja     11a9 <getint+0x79>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x23,%eax
jne    1190 <getint+0x60>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <getc@plt>
cmp    (%r14),%eax
je     1190 <getint+0x60>
cmp    $0xd,%eax
je     1190 <getint+0x60>
cmp    $0xa,%eax
jne    1170 <getint+0x40>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <getc@plt>
mov    (%r14),%edx
cmp    %edx,%eax
je     11a9 <getint+0x79>
mov    %eax,%ecx
add    $0xffffffc6,%ecx
cmp    $0xfffffff6,%ecx
jb     1160 <getint+0x30>
cmp    %edx,%eax
je     11cd <getint+0x9d>
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
lea    0xe42(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
mov    (%rsp),%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"%lu\00"
define i64 @getint(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
store i32* %0, i32** %2
br label %5
5: ; preds = %39, %1
%6 = load i32*, i32** %2
%7 = call i32 @getc(i32* %6)
store i32 %7, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i32, i32* %3
%12 = call i32 @isdigit(i32 %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %40
17: ; preds = %15
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 35
br i1 %19, label %20, label %39
20: ; preds = %17
br label %21
21: ; preds = %37, %20
%22 = load i32*, i32** %2
%23 = call i32 @getc(i32* %22)
store i32 %23, i32* %3
%24 = load i32, i32* @EOF
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %21
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 13
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 10
br label %32
32: ; preds = %29, %26
%33 = phi i1 [ true, %26 ], [ %31, %29 ]
%34 = xor i1 %33, true
br label %35
35: ; preds = %32, %21
%36 = phi i1 [ false, %21 ], [ %34, %32 ]
br i1 %36, label %37, label %38
37: ; preds = %35
br label %21
38: ; preds = %35
br label %39
39: ; preds = %38, %17
br label %5
40: ; preds = %15
%41 = load i32, i32* %3
%42 = load i32, i32* @EOF
%43 = icmp ne i32 %41, %42
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* %3
%46 = load i32*, i32** %2
%47 = call i32 @ungetc(i32 %45, i32* %46)
%48 = load i32*, i32** %2
%49 = call i32 @fscanf(i32* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %4)
br label %50
50: ; preds = %44, %40
%51 = load i64, i64* %4
ret i64 %51
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%lu\00"
define i64 @getint(i32* nocapture %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i32 @getc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
%7 = add i32 %4, -58
%8 = icmp ult i32 %7, -10
%9 = and i1 %6, %8
br i1 %9, label %10, label %25
10: ; preds = %1, %18
%11 = phi i32 [ %19, %18 ], [ %4, %1 ]
%12 = icmp eq i32 %11, 35
br i1 %12, label %13, label %18
13: ; preds = %10, %17
%14 = tail call i32 @getc(i32* %0)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %18, label %17
17: ; preds = %13
switch i32 %14, label %13 [
i32 13, label %18
i32 10, label %18
]
18: ; preds = %17, %17, %13, %10
%19 = tail call i32 @getc(i32* %0)
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
%22 = add i32 %19, -58
%23 = icmp ult i32 %22, -10
%24 = and i1 %21, %23
br i1 %24, label %10, label %25
25: ; preds = %18, %1
%26 = phi i32 [ %4, %1 ], [ %19, %18 ]
%27 = phi i32 [ %5, %1 ], [ %20, %18 ]
%28 = icmp eq i32 %26, %27
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = tail call i32 @ungetc(i32 %26, i32* %0)
%31 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%32 = load i64, i64* %2
br label %33
33: ; preds = %29, %25
%34 = phi i64 [ %32, %29 ], [ undef, %25 ]
ret i64 %34
}