#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*/ scanf(char *, int *);
int get_option(void) {
  int in = 0;
  do {
    printf("Option? [1..9] ");
    scanf("%d", &in);
    while (getchar() != '\n')
      ;
  } while (in < 1 || in > 9);
  return in;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1173 <get_option+0x43>
jmp    115b <get_option+0x2b>
jmp    1178 <get_option+0x48>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1191 <get_option+0x61>
cmpl   $0x9,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    113f <get_option+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_option>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb8(%rip),%r14
lea    0xec1(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1180 <get_option+0x50>
mov    0xc(%rsp),%eax
lea    -0xa(%rax),%ecx
cmp    $0xfffffff7,%ecx
jb     1160 <get_option+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Option? [1..9] \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @get_option() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %17, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %9, %2
%6 = call signext i8 (...) @getchar()
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 10
br i1 %8, label %9, label %10
9: ; preds = %5
br label %5
10: ; preds = %5
br label %11
11: ; preds = %10
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 9
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %2, label %19
19: ; preds = %17
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [16 x i8] c"Option? [1..9] \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @get_option() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %9, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %6
6: ; preds = %6, %3
%7 = call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 10
br i1 %8, label %9, label %6
9: ; preds = %6
%10 = load i32, i32* %1
%11 = add i32 %10, -10
%12 = icmp ult i32 %11, -9
br i1 %12, label %3, label %13
13: ; preds = %9
ret i32 %10
}