#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x;
  int y;
  printf("Voer een getal voor x in ");
  while (!scanf("%d", &x)) {
    printf("Ongeldige invoer\n");
    while (getchar() != '\n')
      ;
    printf("Voer een getal in ");
  }
  printf("Voer een getal voor y in ");
  while (!scanf("%d", &y)) {
    printf("Ongeldige invoer\n");
    while (getchar() != '\n')
      ;
    printf("Voer een getal in ");
  }
  printf("%d\n", x + y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1172 <main+0x42>
jmp    11ab <main+0x7b>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1198 <main+0x68>
jmp    1180 <main+0x50>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11de <main+0xae>
jmp    1217 <main+0xe7>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1204 <main+0xd4>
jmp    11ec <main+0xbc>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <main+0x89>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
test   %eax,%eax
jne    11c4 <main+0x84>
lea    0xedc(%rip),%r14
lea    0xea4(%rip),%r15
lea    0xe9a(%rip),%r12
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11a0 <main+0x60>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %eax,%eax
je     1190 <main+0x50>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
test   %eax,%eax
jne    1234 <main+0xf4>
lea    0xe62(%rip),%r14
lea    0xe2a(%rip),%r15
lea    0xe20(%rip),%r12
mov    %rsp,%rbx
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1210 <main+0xd0>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %eax,%eax
je     1200 <main+0xc0>
mov    (%rsp),%esi
add    0x4(%rsp),%esi
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Voer een getal voor x in \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Ongeldige invoer\0A\00"
@.str.3 = [19 x i8] c"Voer een getal in \00"
@.str.4 = [26 x i8] c"Voer een getal voor y in \00"
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %16, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %18
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %15, %9
%12 = call signext i8 (...) @getchar()
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %11
br label %11
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %5
18: ; preds = %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %31, %18
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %30, %24
%27 = call signext i8 (...) @getchar()
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %26
br label %26
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %20
33: ; preds = %20
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = add nsw i32 %34, %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Voer een getal voor x in \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Voer een getal in \00"
@.str.4 = [26 x i8] c"Voer een getal voor y in \00"
@.str.5 = [4 x i8] c"%d\0A\00"
@str.6 = [17 x i8] c"Ongeldige invoer\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %0, %13
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
br label %10
10: ; preds = %10, %8
%11 = call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %10
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %13, %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %17, %26
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
br label %23
23: ; preds = %23, %21
%24 = call signext i8 (...) @getchar()
%25 = icmp eq i8 %24, 10
br i1 %25, label %26, label %23
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%29 = icmp eq i32 %28, 0
br i1 %29, label %21, label %30
30: ; preds = %26, %17
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = add nsw i32 %32, %31
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %33)
ret i32 0
}