#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *);
main() {
  int val;
  int status = 0;
  char inbuf[133];
  while (status < 1) {
    printf("Enter and integer: ");
    gets(inbuf);
    status = sscanf(inbuf, "%d", &val);
    if (status == 0)
      printf("That was not an integer!\n");
  }
  printf("The integer entered was %d.\n", val);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    11a4 <main+0x74>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <gets@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe99(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    119f <main+0x6f>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1149 <main+0x19>
mov    -0x8(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xea8(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xeb0(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xec4(%rip),%r13
jmp    1184 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ebp,%ebp
jg     11b4 <main+0x74>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1180 <main+0x40>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    1180 <main+0x40>
mov    0xc(%rsp),%esi
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter and integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"That was not an integer!\0A\00"
@.str.3 = [29 x i8] c"The integer entered was %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [133 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %18, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [133 x i8], [133 x i8]* %4, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [133 x i8], [133 x i8]* %4, i64 0, i64 0
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %8
br label %5
19: ; preds = %5
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter and integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [29 x i8] c"The integer entered was %d.\0A\00"
@str = [25 x i8] c"That was not an integer!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [133 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [133 x i8], [133 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %12
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @gets(i8* %4)
%8 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = icmp slt i32 %8, 1
br i1 %13, label %5, label %14
14: ; preds = %12
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %15)
ret i32 0
}