#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 */
char getchar();
int is_valid(char *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  char egn[12];
  char temp;
  int i;
  for (i = 0; i < 12; i++) {
    temp = getchar();
    if (temp == '\n')
      break;
    egn[i] = temp;
  }
  printf("%d", is_valid(egn, i));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xc,-0x18(%rbp)
jge    1185 <main+0x55>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    116c <main+0x3c>
jmp    1185 <main+0x55>
mov    -0x11(%rbp),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <main+0x16>
lea    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <is_valid@plt>
mov    %eax,%esi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0x4(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x1,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0x5(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x2,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0x6(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x3,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0x7(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x4,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0x8(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x5,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0x9(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x6,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0xa(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x7,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0xb(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x8,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0xc(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x9,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0xd(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0xa,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0xe(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0xb,%ebx
cmp    $0xa,%al
je     123f <main+0x10f>
mov    %al,0xf(%rsp)
mov    $0xc,%ebx
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1050 <is_valid@plt>
lea    0xdae(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %50, label %5
5: ; preds = %0
store i8 %3, i8* %2
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %50, label %8
8: ; preds = %5
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 1
store i8 %6, i8* %9
%10 = tail call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %50, label %12
12: ; preds = %8
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 2
store i8 %10, i8* %13
%14 = tail call signext i8 (...) @getchar()
%15 = icmp eq i8 %14, 10
br i1 %15, label %50, label %16
16: ; preds = %12
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 3
store i8 %14, i8* %17
%18 = tail call signext i8 (...) @getchar()
%19 = icmp eq i8 %18, 10
br i1 %19, label %50, label %20
20: ; preds = %16
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 4
store i8 %18, i8* %21
%22 = tail call signext i8 (...) @getchar()
%23 = icmp eq i8 %22, 10
br i1 %23, label %50, label %24
24: ; preds = %20
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 5
store i8 %22, i8* %25
%26 = tail call signext i8 (...) @getchar()
%27 = icmp eq i8 %26, 10
br i1 %27, label %50, label %28
28: ; preds = %24
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 6
store i8 %26, i8* %29
%30 = tail call signext i8 (...) @getchar()
%31 = icmp eq i8 %30, 10
br i1 %31, label %50, label %32
32: ; preds = %28
%33 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 7
store i8 %30, i8* %33
%34 = tail call signext i8 (...) @getchar()
%35 = icmp eq i8 %34, 10
br i1 %35, label %50, label %36
36: ; preds = %32
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 8
store i8 %34, i8* %37
%38 = tail call signext i8 (...) @getchar()
%39 = icmp eq i8 %38, 10
br i1 %39, label %50, label %40
40: ; preds = %36
%41 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 9
store i8 %38, i8* %41
%42 = tail call signext i8 (...) @getchar()
%43 = icmp eq i8 %42, 10
br i1 %43, label %50, label %44
44: ; preds = %40
%45 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 10
store i8 %42, i8* %45
%46 = tail call signext i8 (...) @getchar()
%47 = icmp eq i8 %46, 10
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 11
store i8 %46, i8* %49
br label %50
50: ; preds = %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %8, %5, %0
%51 = phi i32 [ 0, %0 ], [ 1, %5 ], [ 2, %8 ], [ 3, %12 ], [ 4, %16 ], [ 5, %20 ], [ 6, %24 ], [ 7, %28 ], [ 8, %32 ], [ 9, %36 ], [ 10, %40 ], [ 11, %44 ], [ 12, %48 ]
%52 = call i32 @is_valid(i8* %2, i32 %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %52)
ret i32 0
}