#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 *);
int /*<<< orphan*/ putchar(char);
int scanf(char *, int *);
int get_int(void) {
  int input;
  char ch;
  while (scanf("%d", &input) != 1) {
    while ((ch = getchar()) != '\n')
      putchar(ch);
    printf(" is not an integer.\nPlease enter an "
           "integer value, such as 25, -178, or 3: ");
  }
  return input;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     119b <get_int+0x5b>
jmp    1166 <get_int+0x26>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     118a <get_int+0x4a>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    1166 <get_int+0x26>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
jmp    1148 <get_int+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     11ab <get_int+0x6b>
lea    0xe9d(%rip),%r14
lea    0xe93(%rip),%r15
lea    0xc(%rsp),%rbx
jmp    1188 <get_int+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <get_int+0x40>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1188 <get_int+0x48>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [76 x i8] c" is not an integer.\0APlease enter an integer value, such as 25, -178, or 3: \00"
define i32 @get_int() {
%1 = alloca i32
%2 = alloca i8
br label %3
3: ; preds = %14, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = icmp ne i32 %4, 1
br i1 %5, label %6, label %16
6: ; preds = %3
br label %7
7: ; preds = %11, %6
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i8, i8* %2
%13 = call i32 @putchar(i8 signext %12)
br label %7
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0))
br label %3
16: ; preds = %3
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [76 x i8] c" is not an integer.\0APlease enter an integer value, such as 25, -178, or 3: \00"
define i32 @get_int() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %17, label %5
5: ; preds = %0, %13
%6 = call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi i8 [ %11, %8 ], [ %6, %5 ]
%10 = call i32 @putchar(i8 signext %9)
%11 = call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %8
13: ; preds = %8, %5
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %5
17: ; preds = %13, %0
%18 = load i32, i32* %1
ret i32 %18
}