#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int getinput(void) {
  int a;
  a = -1;
  while (0 > a) {
    scanf("%d", &a);
    if (0 > a || a > 100) {
      printf("I need a non-negative number less than 100: ");
      a = -1;
    }
  }
  return a;
}


x86 assembly (clang, -O0):
<getinput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jle    1177 <getinput+0x57>
lea    0xebf(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jg     115f <getinput+0x3f>
cmpl   $0x64,-0x4(%rbp)
jle    1172 <getinput+0x52>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    112f <getinput+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getinput>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x65,%eax
jb     1184 <getinput+0x64>
lea    0xeb1(%rip),%r14
lea    0xea7(%rip),%r15
lea    0xc(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <printf@plt>
movl   $0xffffffff,0xc(%rsp)
ff
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x64,%eax
ja     1160 <getinput+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"I need a non-negative number less than 100: \00"
define i32 @getinput() {
%1 = alloca i32
store i32 -1, i32* %1
br label %2
2: ; preds = %14, %0
%3 = load i32, i32* %1
%4 = icmp sgt i32 0, %3
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 0, %7
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 100
br i1 %11, label %12, label %14
12: ; preds = %9, %5
%13 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %14
14: ; preds = %12, %9
br label %2
15: ; preds = %2
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"I need a non-negative number less than 100: \00"
define i32 @getinput() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp ugt i32 %4, 100
br i1 %5, label %6, label %11
6: ; preds = %0, %6
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp ugt i32 %9, 100
br i1 %10, label %6, label %11
11: ; preds = %6, %0
%12 = phi i32 [ %4, %0 ], [ %9, %6 ]
ret i32 %12
}