#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 *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int askQuestionInt(int *value, char *q) {
  printf("\n%s : ", q);
  scanf("%d", value);
  if (*value == -1) {
    return -1;
  }
  while (getchar() != '\n')
    ;
  return 0;
}


x86 assembly (clang, -O0):
<askQuestionInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1179 <askQuestionInt+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <askQuestionInt+0x6d>
jmp    117e <askQuestionInt+0x4e>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1196 <askQuestionInt+0x66>
jmp    117e <askQuestionInt+0x4e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askQuestionInt>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,(%rbx)
je     116d <askQuestionInt+0x3d>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1160 <askQuestionInt+0x30>
jmp    1172 <askQuestionInt+0x42>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"\0A%s : \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @askQuestionInt(i32* %0, i8* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %0)
%5 = load i32, i32* %0
%6 = icmp eq i32 %5, -1
br i1 %6, label %10, label %7
7: ; preds = %2, %7
%8 = tail call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 10
br i1 %9, label %10, label %7
10: ; preds = %7, %2
%11 = phi i32 [ -1, %2 ], [ 0, %7 ]
ret i32 %11
}