#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 selectChoice() {
  int ch = 0;
  while (ch < 1 || ch > 3) {
    printf("\nPlease choose your method of approximation: ");
    printf("\n1. Left end-point ");
    printf("\n2. Mid-point ");
    printf("\n3. Right end-point ");
    printf("\nYour choice: ");
    scanf("%d", &ch);
    if (ch < 1 || ch > 3)
      printf("\nError! Invalid selection!\n");
  }
  return ch;
}


x86 assembly (clang, -O0):
<selectChoice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1148 <selectChoice+0x28>
cmpl   $0x3,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1158 <selectChoice+0x38>
jmp    11c9 <selectChoice+0xa9>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     11b8 <selectChoice+0x98>
cmpl   $0x3,-0x4(%rbp)
jle    11c4 <selectChoice+0xa4>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <selectChoice+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectChoice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xef8(%rip),%r12
lea    0xf00(%rip),%r13
lea    0xf0e(%rip),%rbx
lea    0xf16(%rip),%rbp
lea    0x4(%rsp),%r14
lea    0xf0d(%rip),%r15
nopl   0x0(%rax,%rax,1)
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffc,%ecx
ja     11cb <selectChoice+0x9b>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jb     1170 <selectChoice+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"\0APlease choose your method of approximation: \00"
@.str.1 = [20 x i8] c"\0A1. Left end-point \00"
@.str.2 = [15 x i8] c"\0A2. Mid-point \00"
@.str.3 = [21 x i8] c"\0A3. Right end-point \00"
@.str.4 = [15 x i8] c"\0AYour choice: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [28 x i8] c"\0AError! Invalid selection!\0A\00"
define i32 @selectChoice() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %24, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 1
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 3
br label %8
8: ; preds = %5, %2
%9 = phi i1 [ true, %2 ], [ %7, %5 ]
br i1 %9, label %10, label %25
10: ; preds = %8
%11 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 1
br i1 %18, label %22, label %19
19: ; preds = %10
%20 = load i32, i32* %1
%21 = icmp sgt i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19, %10
%23 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
br label %2
25: ; preds = %8
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [46 x i8] c"\0APlease choose your method of approximation: \00"
@.str.1 = [20 x i8] c"\0A1. Left end-point \00"
@.str.2 = [15 x i8] c"\0A2. Mid-point \00"
@.str.3 = [21 x i8] c"\0A3. Right end-point \00"
@.str.4 = [15 x i8] c"\0AYour choice: \00"
@.str.5 = [3 x i8] c"%d\00"
@str = [27 x i8] c"\0AError! Invalid selection!\00"
define i32 @selectChoice() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %0, %13
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = add i32 %10, -4
%12 = icmp ult i32 %11, -3
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = add i32 %15, -4
%17 = icmp ult i32 %16, -3
br i1 %17, label %3, label %18
18: ; preds = %3, %13
%19 = phi i32 [ %15, %13 ], [ %10, %3 ]
ret i32 %19
}