#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 atoi(char *);
int /*<<< orphan*/ printf(char *);
int takeYear(char *person) {
  char yearChar[1];
  int i;
  int j = 0;
  for (i = 0; i < 2; i++) {
    yearChar[j] = person[i];
    j++;
  }
  int year = atoi(yearChar);
  if (year >= 0 && year < 100) {
    return year;
  }
  printf("the year you entered is not valid\n");
  return 0;
}


x86 assembly (clang, -O0):
<takeYear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    116e <takeYear+0x4e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x11(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <takeYear+0x1a>
lea    -0x11(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     1199 <takeYear+0x79>
cmpl   $0x64,-0x20(%rbp)
jge    1199 <takeYear+0x79>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <takeYear+0x8c>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<takeYear>:
push   %rax
mov    0x1(%rdi),%al
mov    %al,0x7(%rsp)
lea    0x7(%rsp),%rdi
call   1040 <atoi@plt>
cmp    $0x64,%eax
jb     1145 <takeYear+0x25>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@str = [34 x i8] c"the year you entered is not valid\00"
define i32 @takeYear(i8* nocapture %0) {
%2 = alloca [1 x i8]
%3 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
store i8 %5, i8* %3
%6 = call i32 @atoi(i8* %3)
%7 = icmp ult i32 %6, 100
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %1, %8
%11 = phi i32 [ 0, %8 ], [ %6, %1 ]
ret i32 %11
}