#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 *, char *);
int prompt_for_precision(void) {
  char c;
  while (1) {
    printf("\nMENU for the working precision :\n");
    printf("  0. standard double precision;\n");
    printf("  1. double double precision;\n");
    printf("  2. quad double precision.\n");
    printf("Type 0, 1, or 2 to select the precision : ");
    c = getchar();
    if (c == '0')
      return 0;
    else if (c == '1')
      return 1;
    else if (c == '2')
      return 2;
    else {
      printf("Wrong selection, please try again ...\n");
      scanf("%c", &c);
    }
  }
}


x86 assembly (clang, -O0):
<prompt_for_precision>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jne    1197 <prompt_for_precision+0x67>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <prompt_for_precision+0xc4>
movsbl -0x5(%rbp),%eax
cmp    $0x31,%eax
jne    11b0 <prompt_for_precision+0x80>
movl   $0x1,-0x4(%rbp)
jmp    11f4 <prompt_for_precision+0xc4>
movsbl -0x5(%rbp),%eax
cmp    $0x32,%eax
jne    11c9 <prompt_for_precision+0x99>
movl   $0x2,-0x4(%rbp)
jmp    11f4 <prompt_for_precision+0xc4>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
jmp    11ea <prompt_for_precision+0xba>
jmp    11ef <prompt_for_precision+0xbf>
jmp    1138 <prompt_for_precision+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt_for_precision>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf1e(%rip),%r12
lea    0xf35(%rip),%r13
lea    0xea0(%rip),%rbx
lea    0xf43(%rip),%rbp
lea    0xebd(%rip),%r14
lea    0x7(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,0x7(%rsp)
add    $0xd0,%al
cmp    $0x3,%al
jb     11d6 <prompt_for_precision+0x96>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
jmp    1180 <prompt_for_precision+0x40>
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0AMENU for the working precision :\0A\00"
@.str.1 = [33 x i8] c" 0. standard double precision;\0A\00"
@.str.2 = [31 x i8] c" 1. double double precision;\0A\00"
@.str.3 = [29 x i8] c" 2. quad double precision.\0A\00"
@.str.4 = [43 x i8] c"Type 0, 1, or 2 to select the precision : \00"
@.str.5 = [39 x i8] c"Wrong selection, please try again ...\0A\00"
@.str.6 = [3 x i8] c"%c\00"
define i32 @prompt_for_precision() {
%1 = alloca i32
%2 = alloca i8
br label %3
3: ; preds = %0, %29
%4 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %2
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 48
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %1
br label %30
14: ; preds = %3
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 49
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %1
br label %30
19: ; preds = %14
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 50
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 2, i32* %1
br label %30
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
br label %27
27: ; preds = %24
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
br label %3
30: ; preds = %23, %18, %13
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str.4 = [43 x i8] c"Type 0, 1, or 2 to select the precision : \00"
@.str.6 = [3 x i8] c"%c\00"
@str = [34 x i8] c"\0AMENU for the working precision :\00"
@str.7 = [32 x i8] c" 0. standard double precision;\00"
@str.8 = [30 x i8] c" 1. double double precision;\00"
@str.9 = [28 x i8] c" 2. quad double precision.\00"
@str.10 = [38 x i8] c"Wrong selection, please try again ...\00"
define i32 @prompt_for_precision() {
%1 = alloca i8
br label %2
2: ; preds = %11, %0
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %1
%9 = add i8 %8, -48
%10 = icmp ult i8 %9, 3
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %1)
br label %2
14: ; preds = %2
%15 = zext i8 %9 to i32
ret i32 %15
}