#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 */
char EOF;
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
int readNum(FILE *fp) {
  int res = 0;
  char c;
  while ((c = getc(fp)) != ' ' && c != '\n' && c != EOF) {
    res = res * 10 + c - '0';
  }
  ungetc(c, fp);
  return res;
}


x86 assembly (clang, -O0):
<readNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0xe(%rbp)
je     1178 <readNum+0x58>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xe(%rbp)
je     1178 <readNum+0x58>
movsbl -0xd(%rbp),%eax
mov    0x2e7b(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    1188 <readNum+0x68>
jmp    119d <readNum+0x7d>
imul   $0xa,-0xc(%rbp),%eax
movsbl -0xd(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <readNum+0x13>
mov    -0xd(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <ungetc@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNum>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2eb7(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <getc@plt>
movsbl %al,%edi
cmp    $0xa,%dil
je     1165 <readNum+0x45>
cmp    $0x20,%al
je     1165 <readNum+0x45>
cmp    (%r15),%al
je     1165 <readNum+0x45>
lea    (%rbx,%rbx,4),%eax
lea    (%rdi,%rax,2),%ebx
add    $0xffffffd0,%ebx
jmp    1140 <readNum+0x20>
mov    %r14,%rsi
call   1030 <ungetc@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @readNum(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %22, %1
%6 = load i32*, i32** %2
%7 = call signext i8 @getc(i32* %6)
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 32
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br label %20
20: ; preds = %14, %10, %5
%21 = phi i1 [ false, %10 ], [ false, %5 ], [ %19, %14 ]
br i1 %21, label %22, label %29
22: ; preds = %20
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 10
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = add nsw i32 %24, %26
%28 = sub nsw i32 %27, 48
store i32 %28, i32* %3
br label %5
29: ; preds = %20
%30 = load i8, i8* %4
%31 = load i32*, i32** %2
%32 = call i32 @ungetc(i8 signext %30, i32* %31)
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @readNum(i32* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i32 [ 0, %1 ], [ %12, %9 ]
%4 = tail call signext i8 @getc(i32* %0)
%5 = sext i8 %4 to i32
switch i8 %4, label %6 [
i8 32, label %13
i8 10, label %13
]
6: ; preds = %2
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %4, %7
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = mul nsw i32 %3, 10
%11 = add i32 %10, -48
%12 = add i32 %11, %5
br label %2
13: ; preds = %2, %2, %6
%14 = tail call i32 @ungetc(i8 signext %4, i32* %0)
ret i32 %3
}