#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*/ __fpurge(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int scanf(char *, int *);
int /*<<< orphan*/ stdin;
int readIntRet(char headerMessage[], char errorMessage[]) {
  int value;
  bool ret;
  do {
    printf("%s", headerMessage);
    ret = scanf("\n%d", &value);
    __fpurge(stdin);
    if (ret != true) {
      printf("%s", errorMessage);
    }
  } while (ret != true);
  return value;
}


x86 assembly (clang, -O0):
<readIntRet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
cmpl   $0x1,-0x18(%rbp)
je     118b <readIntRet+0x5b>
mov    -0x10(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    1190 <readIntRet+0x60>
cmpl   $0x1,-0x18(%rbp)
jne    1140 <readIntRet+0x10>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readIntRet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeb8(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    %eax,%ebx
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
cmp    $0x1,%ebx
je     11c6 <readIntRet+0x96>
lea    0xe83(%rip),%rbx
lea    0xe7f(%rip),%r12
lea    0x4(%rsp),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    %eax,%ebp
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
cmp    $0x1,%ebp
jne    1190 <readIntRet+0x60>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"\0A%d\00"
@stdin = global i32 0
define i32 @readIntRet(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* @stdin
%8 = call i32 @__fpurge(i32 %7)
%9 = icmp eq i32 %6, 1
br i1 %9, label %17, label %10
10: ; preds = %2, %10
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* @stdin
%15 = call i32 @__fpurge(i32 %14)
%16 = icmp eq i32 %13, 1
br i1 %16, label %17, label %10
17: ; preds = %10, %2
%18 = load i32, i32* %3
ret i32 %18
}