#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 choice = 0;
  do {
    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", &choice);
    if (choice < 1 || choice > 3)
      printf("\nError! Invalid selection!\n");
  } while (choice < 1 || choice > 3);
  return choice;
}


x86 assembly (clang, -O0):
<selectChoice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     118f <selectChoice+0x6f>
cmpl   $0x3,-0x4(%rbp)
jle    119b <selectChoice+0x7b>
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
jmp    11a0 <selectChoice+0x80>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11b9 <selectChoice+0x99>
cmpl   $0x3,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    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 = %23, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
br label %17
17: ; preds = %16
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 3
br label %23
23: ; preds = %20, %17
%24 = phi i1 [ true, %17 ], [ %22, %20 ]
br i1 %24, label %2, label %25
25: ; preds = %23
%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 = %13, %0
%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
}