#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 */

/* Variables and functions */
int EOF;
int getchar();
int htoi(char *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int c, i = 0;
  char s[10];
  while ((c = getchar()) != EOF) {
    if (i < 10 - 1)
      if (c == '\n')
        break;
      else
        s[i] = c;
    else if (i == 10 - 1)
      break;
    ++i;
  }
  s[i] = '\0';
  printf("%d\n", htoi(s));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11ac <main+0x7c>
cmpl   $0x9,-0xc(%rbp)
jge    118a <main+0x5a>
cmpl   $0xa,-0x8(%rbp)
jne    1178 <main+0x48>
jmp    11ac <main+0x7c>
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x16(%rbp,%rax,1)
jmp    119e <main+0x6e>
cmpl   $0x9,-0xc(%rbp)
jne    1199 <main+0x69>
jmp    11ac <main+0x7c>
jmp    119e <main+0x6e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <main+0x16>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x16(%rbp,%rax,1)
lea    -0x16(%rbp),%rdi
call   1050 <htoi@plt>
mov    %eax,%esi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea1(%rip),%r14
cmp    (%r14),%eax
je     117e <main+0x4e>
xor    %ebx,%ebx
jmp    1166 <main+0x36>
cmp    $0x9,%rbx
je     1177 <main+0x47>
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     117c <main+0x4c>
cmp    $0x8,%rbx
ja     1150 <main+0x20>
cmp    $0xa,%eax
je     117c <main+0x4c>
mov    %al,0xe(%rsp,%rbx,1)
jmp    1156 <main+0x26>
mov    $0x9,%ebx
mov    %ebx,%ebx
movb   $0x0,0xe(%rsp,%rbx,1)
lea    0xe(%rsp),%rdi
call   1050 <htoi@plt>
lea    0xe6c(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %25, label %6
6: ; preds = %0, %17
%7 = phi i64 [ %18, %17 ], [ 0, %0 ]
%8 = phi i32 [ %19, %17 ], [ %3, %0 ]
%9 = icmp ult i64 %7, 9
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = icmp eq i32 %8, 10
br i1 %11, label %22, label %12
12: ; preds = %10
%13 = trunc i32 %8 to i8
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %7
store i8 %13, i8* %14
br label %17
15: ; preds = %6
%16 = icmp eq i64 %7, 9
br i1 %16, label %22, label %17
17: ; preds = %15, %12
%18 = add nuw i64 %7, 1
%19 = tail call i32 (...) @getchar()
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %6
22: ; preds = %15, %10, %17
%23 = phi i64 [ %18, %17 ], [ %7, %10 ], [ 9, %15 ]
%24 = and i64 %23, 4294967295
br label %25
25: ; preds = %22, %0
%26 = phi i64 [ 0, %0 ], [ %24, %22 ]
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %26
store i8 0, i8* %27
%28 = call i32 @htoi(i8* %2)
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
ret i32 0
}