#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 || year < 100) {
      if (year < 100)
        return (1900 + year);
      return (year);
    }
  }
}


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    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x76c,-0x8(%rbp)
jge    115b <GetYearFromUser+0x3b>
cmpl   $0x64,-0x8(%rbp)
jge    1180 <GetYearFromUser+0x60>
cmpl   $0x64,-0x8(%rbp)
jge    1175 <GetYearFromUser+0x55>
mov    -0x8(%rbp),%eax
add    $0x76c,%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <GetYearFromUser+0x65>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <GetYearFromUser+0x65>
jmp    1128 <GetYearFromUser+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetYearFromUser>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%r14
lea    0xed6(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
lea    -0x76c(%rcx),%eax
cmp    $0xfffff8f7,%eax
ja     1140 <GetYearFromUser+0x20>
lea    0x76c(%rcx),%eax
cmp    $0x64,%ecx
cmovge %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Which year? \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @GetYearFromUser() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %0, %19
%4 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sge i32 %6, 1900
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %19
11: ; preds = %8, %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %2
%16 = add nsw i32 1900, %15
store i32 %16, i32* %1
br label %20
17: ; preds = %11
%18 = load i32, i32* %2
store i32 %18, i32* %1
br label %20
19: ; preds = %8
br label %3
20: ; preds = %17, %14
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [13 x i8] c"Which year? \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @GetYearFromUser() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -1900
%8 = icmp ult i32 %7, -1800
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = icmp slt i32 %6, 100
%11 = add nsw i32 %6, 1900
%12 = select i1 %10, i32 %11, i32 %6
ret i32 %12
}