#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int GetYearFromUser(void) {
  int year;
  while (1) {
    printf("Which year? ");
    scanf("%d", &year);
    if (year >= 1900)
      return (year);
    printf("The year must be at least 1900.\n");
  }
}


x86 assembly (clang, -O0):
<GetYearFromUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x76c,-0x4(%rbp)
jl     115a <GetYearFromUser+0x3a>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
jmp    1128 <GetYearFromUser+0x8>

x86 assembly (clang, -O2):
<GetYearFromUser>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x76b,%eax
jg     11a6 <GetYearFromUser+0x76>
lea    0xea9(%rip),%r14
lea    0xe92(%rip),%r15
lea    0xe98(%rip),%r12
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x76b,%eax
jle    1180 <GetYearFromUser+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Which year? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"The year must be at least 1900.\0A\00"
define i32 @GetYearFromUser() {
%1 = alloca i32
br label %2
2: ; preds = %0, %9
%3 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sge i32 %5, 1900
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = load i32, i32* %1
ret i32 %8
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %2
}

LLVM IR (-O2):
@.str = [13 x i8] c"Which year? \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [32 x i8] c"The year must be at least 1900.\00"
define i32 @GetYearFromUser() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 1899
br i1 %6, label %7, label %9
7: ; preds = %9, %0
%8 = phi i32 [ %5, %0 ], [ %13, %9 ]
ret i32 %8
9: ; preds = %0, %9
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 1899
br i1 %14, label %7, label %9
}