#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 *);
char getc(int /*<<< orphan*/ *);
int ReadNumber(FILE *fp) {
  char buff[12];
  int f;
  for (f = 0; f < 11; f++) {
    buff[f] = getc(fp);
  }
  buff[f] = 0;
  return atoi(buff);
}


x86 assembly (clang, -O0):
<ReadNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xb,-0x18(%rbp)
jge    115e <ReadNumber+0x3e>
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x14(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <ReadNumber+0x13>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x14(%rbp,%rax,1)
lea    -0x14(%rbp),%rdi
call   1030 <atoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadNumber>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <getc@plt>
mov    %al,0x4(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0x5(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0x6(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0x7(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0x9(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0xa(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0xb(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0xc(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0xd(%rsp)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <atoi@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ReadNumber(i32* %0) {
%2 = alloca i32*
%3 = alloca [12 x i8]
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %14, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 11
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = call signext i8 @getc(i32* %9)
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %12
store i8 %10, i8* %13
br label %14
14: ; preds = %8
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %5
17: ; preds = %5
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
ret i32 %22
}

LLVM IR (-O2):
define i32 @ReadNumber(i32* nocapture %0) {
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%4 = tail call signext i8 @getc(i32* %0)
store i8 %4, i8* %3
%5 = tail call signext i8 @getc(i32* %0)
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 1
store i8 %5, i8* %6
%7 = tail call signext i8 @getc(i32* %0)
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 2
store i8 %7, i8* %8
%9 = tail call signext i8 @getc(i32* %0)
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 3
store i8 %9, i8* %10
%11 = tail call signext i8 @getc(i32* %0)
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 4
store i8 %11, i8* %12
%13 = tail call signext i8 @getc(i32* %0)
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 5
store i8 %13, i8* %14
%15 = tail call signext i8 @getc(i32* %0)
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 6
store i8 %15, i8* %16
%17 = tail call signext i8 @getc(i32* %0)
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 7
store i8 %17, i8* %18
%19 = tail call signext i8 @getc(i32* %0)
%20 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 8
store i8 %19, i8* %20
%21 = tail call signext i8 @getc(i32* %0)
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 9
store i8 %21, i8* %22
%23 = tail call signext i8 @getc(i32* %0)
%24 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 10
store i8 %23, i8* %24
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 11
store i8 0, i8* %25
%26 = call i32 @atoi(i8* %3)
ret i32 %26
}