#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*/ fgets(char *, int const, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int const);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main() {
  static const int maxdata = sizeof(int) * 2;
  char *indata = malloc(maxdata);
  int tries = 0;
  do {
    if (tries == 0) {
      printf("Mata in året du är född: ");
    } else {
      printf("Det där blev nog fel, försök igen: ");
    }
    fgets(indata, maxdata, stdin);
    if (1900 <= atoi(indata) && atoi(indata) <= 2013) {
      break;
    } else {
      tries++;
    }
  } while ((2013 <= atoi(indata) || atoi(indata) <= 1900) && tries < 5);
  if (tries < 5) {
    printf("Grattis du matade in ett godkänt årtal\n");
  } else {
    printf("Tyvärr lyckades du inte mata in ett godkänt årtal\n");
  }
  free(indata);
  indata = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    118f <main+0x3f>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
jmp    119b <main+0x4b>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    $0x76c,%eax
cmp    %ecx,%eax
jg     11e3 <main+0x93>
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
cmp    $0x7dd,%eax
jg     11e3 <main+0x93>
jmp    123a <main+0xea>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f1 <main+0xa1>
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    $0x7dd,%eax
cmp    %ecx,%eax
jle    1225 <main+0xd5>
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x76c,%ecx
mov    %al,-0x15(%rbp)
jg     122f <main+0xdf>
cmpl   $0x5,-0x14(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1174 <main+0x24>
cmpl   $0x5,-0x14(%rbp)
jge    1255 <main+0x105>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
jmp    1261 <main+0x111>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e63(%rip),%r15
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
add    $0xfffff894,%eax
lea    0xed0(%rip),%r14
cmp    $0x72,%eax
jb     127e <main+0x11e>
lea    0xe64(%rip),%rdi
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
add    $0xfffff894,%eax
cmp    $0x72,%eax
jb     127e <main+0x11e>
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
add    $0xfffff894,%eax
cmp    $0x72,%eax
jb     127e <main+0x11e>
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
add    $0xfffff894,%eax
cmp    $0x72,%eax
jb     127e <main+0x11e>
lea    0xdd6(%rip),%rdi
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
add    $0xfffff894,%eax
cmp    $0x72,%eax
lea    0xe06(%rip),%rax
lea    0xdca(%rip),%r14
cmovb  %rax,%r14
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.maxdata = internal constant i32 8
@.str = [29 x i8] c"Mata in \C3\A5ret du \C3\A4r f\C3\B6dd: \00"
@.str.1 = [39 x i8] c"Det d\C3\A4r blev nog fel, f\C3\B6rs\C3\B6k igen: \00"
@stdin = global i32 0
@.str.2 = [42 x i8] c"Grattis du matade in ett godk\C3\A4nt \C3\A5rtal\0A\00"
@.str.3 = [54 x i8] c"Tyv\C3\A4rr lyckades du inte mata in ett godk\C3\A4nt \C3\A5rtal\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i8* @malloc(i32 8)
store i8* %4, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %39, %0
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %5
%11 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = load i8*, i8** %2
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 8, i32 %14)
%16 = load i8*, i8** %2
%17 = call i32 @atoi(i8* %16)
%18 = icmp sle i32 1900, %17
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i8*, i8** %2
%21 = call i32 @atoi(i8* %20)
%22 = icmp sle i32 %21, 2013
br i1 %22, label %23, label %24
23: ; preds = %19
br label %41
24: ; preds = %19, %12
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %27
27: ; preds = %24
br label %28
28: ; preds = %27
%29 = load i8*, i8** %2
%30 = call i32 @atoi(i8* %29)
%31 = icmp sle i32 2013, %30
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8*, i8** %2
%34 = call i32 @atoi(i8* %33)
%35 = icmp sle i32 %34, 1900
br i1 %35, label %36, label %39
36: ; preds = %32, %28
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 5
br label %39
39: ; preds = %36, %32
%40 = phi i1 [ false, %32 ], [ %38, %36 ]
br i1 %40, label %5, label %41
41: ; preds = %39, %23
%42 = load i32, i32* %3
%43 = icmp slt i32 %42, 5
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %48
46: ; preds = %41
%47 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
%49 = load i8*, i8** %2
%50 = call i32 @free(i8* %49)
store i8* null, i8** %2
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Mata in \C3\A5ret du \C3\A4r f\C3\B6dd: \00"
@.str.1 = [39 x i8] c"Det d\C3\A4r blev nog fel, f\C3\B6rs\C3\B6k igen: \00"
@stdin = global i32 0
@str = [53 x i8] c"Tyv\C3\A4rr lyckades du inte mata in ett godk\C3\A4nt \C3\A5rtal\00"
@str.4 = [41 x i8] c"Grattis du matade in ett godk\C3\A4nt \C3\A5rtal\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgets(i8* %1, i32 8, i32 %3)
%5 = tail call i32 @atoi(i8* %1)
%6 = add i32 %5, -1900
%7 = icmp ult i32 %6, 114
br i1 %7, label %37, label %8
8: ; preds = %0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = tail call i32 @fgets(i8* %1, i32 8, i32 %10)
%12 = tail call i32 @atoi(i8* %1)
%13 = add i32 %12, -1900
%14 = icmp ult i32 %13, 114
br i1 %14, label %37, label %15
15: ; preds = %8
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = tail call i32 @fgets(i8* %1, i32 8, i32 %17)
%19 = tail call i32 @atoi(i8* %1)
%20 = add i32 %19, -1900
%21 = icmp ult i32 %20, 114
br i1 %21, label %37, label %22
22: ; preds = %15
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @stdin
%25 = tail call i32 @fgets(i8* %1, i32 8, i32 %24)
%26 = tail call i32 @atoi(i8* %1)
%27 = add i32 %26, -1900
%28 = icmp ult i32 %27, 114
br i1 %28, label %37, label %29
29: ; preds = %22
%30 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @stdin
%32 = tail call i32 @fgets(i8* %1, i32 8, i32 %31)
%33 = tail call i32 @atoi(i8* %1)
%34 = add i32 %33, -1900
%35 = icmp ult i32 %34, 114
%36 = select i1 %35, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0)
br label %37
37: ; preds = %29, %22, %15, %8, %0
%38 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0), %22 ], [ %36, %29 ]
%39 = tail call i32 @puts(i8* dereferenceable(1) %38)
%40 = tail call i32 @free(i8* %1)
ret i32 0
}