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


x86 assembly (clang, -O0):
<readLongRet>:
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    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
cmpl   $0x1,-0x1c(%rbp)
je     118b <readLongRet+0x5b>
mov    -0x10(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    1190 <readLongRet+0x60>
cmpl   $0x1,-0x1c(%rbp)
jne    1140 <readLongRet+0x10>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLongRet>:
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
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    %eax,%ebx
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
cmp    $0x1,%ebx
je     11c6 <readLongRet+0x96>
lea    0xe85(%rip),%rbx
lea    0xe81(%rip),%r12
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nop
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 <readLongRet+0x60>
mov    (%rsp),%rax
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 = [5 x i8] c"\0A%ld\00"
@stdin = global i32 0
define i64 @readLongRet(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%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 ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %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 i64, i64* %5
ret i64 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"\0A%ld\00"
@stdin = global i32 0
define i64 @readLongRet(i8* %0, i8* %1) {
%3 = alloca i64
%4 = bitcast i64* %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 ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %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 ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %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 i64, i64* %3
ret i64 %18
}