#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 atoi(char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int readNumberFromFile(FILE *fileInput) {
  char c;
  fread(&c, 1, sizeof(char), fileInput);
  char buffer[3];
  buffer[0] = '\0';
  buffer[1] = '\0';
  buffer[2] = '\0';
  int i = 0;
  while (c != 32 && c != 10) {
    buffer[i] = c;
    i++;
    fread(&c, 1, sizeof(char), fileInput);
  }
  return atoi(buffer);
}


x86 assembly (clang, -O0):
<readNumberFromFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x9(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movb   $0x0,-0xc(%rbp)
movb   $0x0,-0xb(%rbp)
movb   $0x0,-0xa(%rbp)
movl   $0x0,-0x10(%rbp)
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x11(%rbp)
je     1172 <readNumberFromFile+0x52>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1182 <readNumberFromFile+0x62>
jmp    11af <readNumberFromFile+0x8f>
mov    -0x9(%rbp),%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x9(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
jmp    1153 <readNumberFromFile+0x33>
lea    -0xc(%rbp),%rdi
call   1040 <atoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNumberFromFile>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
lea    0xc(%rsp),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
movw   $0x0,0xd(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xd(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movzbl 0xc(%rsp),%eax
cmp    $0xa,%al
je     118a <readNumberFromFile+0x6a>
cmp    $0x20,%al
je     118a <readNumberFromFile+0x6a>
mov    %al,(%rbx)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
add    $0x1,%rbx
jmp    1160 <readNumberFromFile+0x40>
lea    0xd(%rsp),%rdi
call   1040 <atoi@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @readNumberFromFile(i32* nocapture %0) {
%2 = alloca i8
%3 = alloca [3 x i8]
%4 = call i32 @fread(i8* %2, i32 1, i32 1, i32* %0)
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 0, i8* %5
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 0, i8* %6
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %7
br label %8
8: ; preds = %11, %1
%9 = phi i64 [ %13, %11 ], [ 0, %1 ]
%10 = load i8, i8* %2
switch i8 %10, label %11 [
i8 32, label %15
i8 10, label %15
]
11: ; preds = %8
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 %9
store i8 %10, i8* %12
%13 = add nuw i64 %9, 1
%14 = call i32 @fread(i8* %2, i32 1, i32 1, i32* %0)
br label %8
15: ; preds = %8, %8
%16 = call i32 @atoi(i8* %5)
ret i32 %16
}