#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 ReadInt();
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char c = 0;
  int num = 0;
  printf("Please enter an integer: \n");
  while (1) {
    printf(">>> ");
    num = ReadInt();
    while (c != '\n') {
      c = getchar();
    }
    c = 0;
    printf("%d\n", num);
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <ReadInt@plt>
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     118c <main+0x5c>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
jmp    1170 <main+0x40>
movb   $0x0,-0x5(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1158 <main+0x28>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%r14
lea    0xea7(%rip),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <ReadInt@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <main+0x40>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <main+0x20>

LLVM IR (-O0):
@.str = [27 x i8] c"Please enter an integer: \0A\00"
@.str.1 = [5 x i8] c">>> \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i8 0, i8* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %14
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (...) @ReadInt()
store i32 %7, i32* %3
br label %8
8: ; preds = %12, %5
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %2
br label %8
14: ; preds = %8
store i8 0, i8* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %5
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c">>> \00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [26 x i8] c"Please enter an integer: \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %8, %0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (...) @ReadInt()
br label %5
5: ; preds = %2, %5
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %5
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %2
}