#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*/ adafinal();
int /*<<< orphan*/ adainit();
int dobldobl_reducer();
int greetings();
int /*<<< orphan*/ printf(char *);
int quaddobl_reducer();
int /*<<< orphan*/ scanf(char *, int *);
int standard_nonlinear_reducer();
int standard_reducer();
int main(int argc, char *argv[]) {
  int fail, choice;
  adainit();
  fail = greetings();
  printf("\nMENU for reduction :\n");
  printf("  0. linear reduction in double precision arithmetic\n");
  printf("  1. linear reduction in double double precision arithmetic\n");
  printf("  2. linear reduction in quad double precision arithmetic\n");
  printf("  3. nonlinear reduction in double precision arithmetic\n");
  printf("Type 0, 1, 2, or 3 to make your choice : ");
  scanf("%d", &choice);
  if (choice == 0)
    fail = standard_reducer();
  else if (choice == 1)
    fail = dobldobl_reducer();
  else if (choice == 2)
    fail = quaddobl_reducer();
  else if (choice == 3)
    fail = standard_nonlinear_reducer();
  adafinal();
  return fail;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <adainit@plt>
mov    $0x0,%al
call   1080 <greetings@plt>
mov    %eax,-0x14(%rbp)
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1228 <main+0x98>
mov    $0x0,%al
call   10b0 <standard_reducer@plt>
mov    %eax,-0x14(%rbp)
jmp    127d <main+0xed>
cmpl   $0x1,-0x18(%rbp)
jne    1241 <main+0xb1>
mov    $0x0,%al
call   10a0 <dobldobl_reducer@plt>
mov    %eax,-0x14(%rbp)
jmp    1278 <main+0xe8>
cmpl   $0x2,-0x18(%rbp)
jne    125a <main+0xca>
mov    $0x0,%al
call   1040 <quaddobl_reducer@plt>
mov    %eax,-0x14(%rbp)
jmp    1273 <main+0xe3>
cmpl   $0x3,-0x18(%rbp)
jne    126e <main+0xde>
mov    $0x0,%al
call   1090 <standard_nonlinear_reducer@plt>
mov    %eax,-0x14(%rbp)
jmp    1273 <main+0xe3>
jmp    1278 <main+0xe8>
jmp    127d <main+0xed>
mov    $0x0,%al
call   1050 <adafinal@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <adainit@plt>
xor    %eax,%eax
call   1090 <greetings@plt>
mov    %eax,%ebx
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
lea    0xe18(%rip),%rdi
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%rax
ja     124c <main+0xac>
lea    0xde1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   10c0 <standard_reducer@plt>
jmp    124a <main+0xaa>
xor    %eax,%eax
call   10b0 <dobldobl_reducer@plt>
jmp    124a <main+0xaa>
xor    %eax,%eax
call   1050 <quaddobl_reducer@plt>
jmp    124a <main+0xaa>
xor    %eax,%eax
call   10a0 <standard_nonlinear_reducer@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <adafinal@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0AMENU for reduction :\0A\00"
@.str.1 = [54 x i8] c" 0. linear reduction in double precision arithmetic\0A\00"
@.str.2 = [61 x i8] c" 1. linear reduction in double double precision arithmetic\0A\00"
@.str.3 = [59 x i8] c" 2. linear reduction in quad double precision arithmetic\0A\00"
@.str.4 = [57 x i8] c" 3. nonlinear reduction in double precision arithmetic\0A\00"
@.str.5 = [42 x i8] c"Type 0, 1, 2, or 3 to make your choice : \00"
@.str.6 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @adainit()
%9 = call i32 (...) @greetings()
store i32 %9, i32* %6
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %7)
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (...) @standard_reducer()
store i32 %20, i32* %6
br label %39
21: ; preds = %2
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @dobldobl_reducer()
store i32 %25, i32* %6
br label %38
26: ; preds = %21
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (...) @quaddobl_reducer()
store i32 %30, i32* %6
br label %37
31: ; preds = %26
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 3
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (...) @standard_nonlinear_reducer()
store i32 %35, i32* %6
br label %36
36: ; preds = %34, %31
br label %37
37: ; preds = %36, %29
br label %38
38: ; preds = %37, %24
br label %39
39: ; preds = %38, %19
%40 = call i32 (...) @adafinal()
%41 = load i32, i32* %6
ret i32 %41
}

LLVM IR (-O2):
@.str.5 = [42 x i8] c"Type 0, 1, 2, or 3 to make your choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@str = [22 x i8] c"\0AMENU for reduction :\00"
@str.7 = [53 x i8] c" 0. linear reduction in double precision arithmetic\00"
@str.8 = [60 x i8] c" 1. linear reduction in double double precision arithmetic\00"
@str.9 = [58 x i8] c" 2. linear reduction in quad double precision arithmetic\00"
@str.10 = [56 x i8] c" 3. nonlinear reduction in double precision arithmetic\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (...) @adainit()
%6 = tail call i32 (...) @greetings()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.7, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.8, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.10, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
switch i32 %14, label %23 [
i32 0, label %15
i32 1, label %17
i32 2, label %19
i32 3, label %21
]
15: ; preds = %2
%16 = call i32 (...) @standard_reducer()
br label %23
17: ; preds = %2
%18 = call i32 (...) @dobldobl_reducer()
br label %23
19: ; preds = %2
%20 = call i32 (...) @quaddobl_reducer()
br label %23
21: ; preds = %2
%22 = call i32 (...) @standard_nonlinear_reducer()
br label %23
23: ; preds = %2, %17, %21, %19, %15
%24 = phi i32 [ %16, %15 ], [ %18, %17 ], [ %20, %19 ], [ %22, %21 ], [ %6, %2 ]
%25 = call i32 (...) @adafinal()
ret i32 %24
}