#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 ask(char *str, int result) {
  int answer;
  for (;;) {
    printf("%s = ", str);
    if (!scanf("%i", &answer))
      return 0;
    if (result == answer) {
      printf("Oikein!\n\n");
      return 1;
    } else {
      printf("Ei ihan. Koita uudestaan!\n");
    }
  }
}


x86 assembly (clang, -O0):
<ask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%eax
jne    1166 <ask+0x46>
movl   $0x0,-0x4(%rbp)
jmp    119f <ask+0x7f>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    118c <ask+0x6c>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119f <ask+0x7f>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <ask+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xeb8(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
test   %eax,%eax
je     11c2 <ask+0x92>
lea    0xe90(%rip),%r12
lea    0xe8f(%rip),%r13
lea    0x4(%rsp),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
cmp    %r14d,0x4(%rsp)
je     11b1 <ask+0x81>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
test   %eax,%eax
jne    1180 <ask+0x50>
jmp    11c2 <ask+0x92>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s = \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [10 x i8] c"Oikein!\0A\0A\00"
@.str.3 = [27 x i8] c"Ei ihan. Koita uudestaan!\0A\00"
define i32 @ask(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
br label %7
7: ; preds = %21, %2
%8 = load i8*, i8** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %7
store i32 0, i32* %3
br label %22
13: ; preds = %7
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %22
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19
br label %7
22: ; preds = %17, %12
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s = \00"
@.str.1 = [3 x i8] c"%i\00"
@str = [26 x i8] c"Ei ihan. Koita uudestaan!\00"
@str.4 = [9 x i8] c"Oikein!\0A\00"
define i32 @ask(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %2, %13
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0))
br label %18
13: ; preds = %8
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %8
18: ; preds = %13, %2, %11
%19 = phi i32 [ 1, %11 ], [ 0, %2 ], [ 0, %13 ]
ret i32 %19
}