#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 *);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i;
  int ok = 0;
  char jaar[5];
  printf("geef jaartal (4 cijfers): ");
  for (i = 0; (jaar[i] = getchar()) != '\n'; i++)
    ;
  jaar[i] = '\0';
  i = atoi(jaar);
  if (i % 4 == 0) {
    ok = 1;
    if (i % 100 == 0) {
      ok = 0;
    }
    if (i % 400 == 0) {
      ok = 1;
    }
  }
  if (ok == 1) {
    printf("\n%d is een schrikkeljaar!\n", i);
  } else
    printf("\n%d is geen schrikkeljaar\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
movslq -0x8(%rbp),%rcx
mov    %al,-0x11(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     1189 <main+0x59>
jmp    117b <main+0x4b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x2b>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x11(%rbp,%rax,1)
lea    -0x11(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f4 <main+0xc4>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d4 <main+0xa4>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ef <main+0xbf>
movl   $0x1,-0xc(%rbp)
jmp    11f4 <main+0xc4>
cmpl   $0x1,-0xc(%rbp)
jne    1214 <main+0xe4>
mov    -0x8(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1225 <main+0xf5>
mov    -0x8(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffffffffffff,%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %al,0xc(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xa,%al
jne    1150 <main+0x20>
mov    %ebx,%eax
movb   $0x0,0xb(%rsp,%rax,1)
lea    0xb(%rsp),%rdi
call   1050 <atoi@plt>
test   $0x3,%al
jne    11b6 <main+0x86>
imul   $0xc28f5c29,%eax,%ecx
add    $0x51eb850,%ecx
ror    $0x4,%ecx
lea    0xe8d(%rip),%rdi
cmp    $0xa3d70b,%ecx
jb     11bd <main+0x8d>
movslq %eax,%rcx
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
jne    11bd <main+0x8d>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"geef jaartal (4 cijfers): \00"
@.str.1 = [27 x i8] c"\0A%d is een schrikkeljaar!\0A\00"
@.str.2 = [27 x i8] c"\0A%d is geen schrikkeljaar\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %14, %0
%7 = call signext i8 (...) @getchar()
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %9
store i8 %7, i8* %10
%11 = sext i8 %7 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %17
13: ; preds = %6
br label %14
14: ; preds = %13
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %6
17: ; preds = %6
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = srem i32 %23, 4
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %17
store i32 1, i32* %3
%27 = load i32, i32* %2
%28 = srem i32 %27, 100
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 0, i32* %3
br label %31
31: ; preds = %30, %26
%32 = load i32, i32* %2
%33 = srem i32 %32, 400
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %3
br label %36
36: ; preds = %35, %31
br label %37
37: ; preds = %36, %17
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %46
43: ; preds = %37
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %43, %40
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [27 x i8] c"geef jaartal (4 cijfers): \00"
@.str.1 = [27 x i8] c"\0A%d is een schrikkeljaar!\0A\00"
@.str.2 = [27 x i8] c"\0A%d is geen schrikkeljaar\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = phi i64 [ %9, %4 ], [ 0, %0 ]
%6 = tail call signext i8 (...) @getchar()
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %5
store i8 %6, i8* %7
%8 = icmp eq i8 %6, 10
%9 = add nuw i64 %5, 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = and i64 %5, 4294967295
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 @atoi(i8* %2)
%14 = and i32 %13, 3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = srem i32 %13, 100
%18 = icmp ne i32 %17, 0
%19 = srem i32 %13, 400
%20 = icmp eq i32 %19, 0
%21 = or i1 %20, %18
br i1 %21, label %23, label %22
22: ; preds = %10, %16
br label %23
23: ; preds = %16, %22
%24 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), %22 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %16 ]
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, i32 %13)
ret i32 0
}