#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*/ getLine(char *, int);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, int *);
int getInteger() {
  char input[9];
  int result = 0;
  int validInt = 0;
  getLine(input, 9);
  while (validInt == 0) {
    if (!isspace(input[0]))
      validInt = sscanf(input, "%d", &result);
    if (validInt == 0) {
      printf("Error - Please enter a valid number: ");
      getLine(input, 9);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<getInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x9(%rbp),%rdi
mov    $0x9,%esi
call   1060 <getLine@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11c0 <getInteger+0x80>
movsbl -0x9(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    1197 <getInteger+0x57>
lea    -0x9(%rbp),%rdi
lea    0xe75(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11bb <getInteger+0x7b>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
lea    -0x9(%rbp),%rdi
mov    $0x9,%esi
call   1060 <getLine@plt>
jmp    1164 <getInteger+0x24>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInteger>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x8(%rsp)
lea    0xf(%rsp),%rbx
lea    0xea1(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe98(%rip),%r12
jmp    1178 <getInteger+0x38>
nopl   (%rax)
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1060 <getLine@plt>
movsbl 0xf(%rsp),%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    1170 <getInteger+0x30>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
je     1170 <getInteger+0x30>
mov    0x8(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [38 x i8] c"Error - Please enter a valid number: \00"
define i32 @getInteger() {
%1 = alloca [9 x i8]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%5 = call i32 @getLine(i8* %4, i32 9)
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%11 = load i8, i8* %10
%12 = call i32 @isspace(i8 signext %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %9
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%23 = call i32 @getLine(i8* %22, i32 9)
br label %24
24: ; preds = %20, %17
br label %6
25: ; preds = %6
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [38 x i8] c"Error - Please enter a valid number: \00"
define i32 @getInteger() {
%1 = alloca [9 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %13, %0
%6 = call i32 @getLine(i8* %3, i32 9)
%7 = load i8, i8* %3
%8 = call i32 @isspace(i8 signext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %5
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %5
15: ; preds = %10
%16 = load i32, i32* %2
ret i32 %16
}