#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ test_dobldobl_multiplicity_structure(int);
int /*<<< orphan*/ test_quaddobl_multiplicity_structure(int);
int /*<<< orphan*/ test_standard_multiplicity_structure(int);
int main(int argc, char *argv[]) {
  int choice, order;
  char ch;
  adainit();
  printf("\nMENU to compute the multiplicity structure : \n");
  printf("  1. test with standard double arithmetic;\n");
  printf("  2. test with double double arithmetic;\n");
  printf("  3. test with quad double arithmetic.\n");
  printf("Type 0, 1, 2, or 3 to select : ");
  scanf("%d", &choice);
  scanf("%c", &ch);
  printf("Give the maximum differentiation order : ");
  scanf("%d", &order);
  if (choice == 1)
    test_standard_multiplicity_structure(order);
  else if (choice == 2)
    test_dobldobl_multiplicity_structure(order);
  else if (choice == 3)
    test_quaddobl_multiplicity_structure(order);
  else
    printf("invalid selection, please try again\n");
  adafinal();
  return 0;
}


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   1080 <adainit@plt>
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
call   1040 <printf@plt>
lea    0xefe(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xeef(%rip),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xee0(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    1222 <main+0xb2>
mov    -0x18(%rbp),%edi
call   1060 <test_standard_multiplicity_structure@plt>
jmp    1266 <main+0xf6>
cmpl   $0x2,-0x14(%rbp)
jne    1239 <main+0xc9>
mov    -0x18(%rbp),%edi
call   1030 <test_dobldobl_multiplicity_structure@plt>
jmp    1261 <main+0xf1>
cmpl   $0x3,-0x14(%rbp)
jne    1250 <main+0xe0>
mov    -0x18(%rbp),%edi
call   1090 <test_quaddobl_multiplicity_structure@plt>
jmp    125c <main+0xec>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
jmp    1261 <main+0xf1>
jmp    1266 <main+0xf6>
mov    $0x0,%al
call   1050 <adafinal@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1090 <adainit@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe51(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe3e(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe2e(%rip),%rdi
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     122a <main+0xaa>
cmp    $0x2,%eax
je     1235 <main+0xb5>
cmp    $0x1,%eax
jne    1240 <main+0xc0>
mov    0x4(%rsp),%edi
call   1070 <test_standard_multiplicity_structure@plt>
jmp    124c <main+0xcc>
mov    0x4(%rsp),%edi
call   10a0 <test_quaddobl_multiplicity_structure@plt>
jmp    124c <main+0xcc>
mov    0x4(%rsp),%edi
call   1040 <test_dobldobl_multiplicity_structure@plt>
jmp    124c <main+0xcc>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <adafinal@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [48 x i8] c"\0AMENU to compute the multiplicity structure : \0A\00"
@.str.1 = [44 x i8] c" 1. test with standard double arithmetic;\0A\00"
@.str.2 = [42 x i8] c" 2. test with double double arithmetic;\0A\00"
@.str.3 = [40 x i8] c" 3. test with quad double arithmetic.\0A\00"
@.str.4 = [32 x i8] c"Type 0, 1, 2, or 3 to select : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [42 x i8] c"Give the maximum differentiation order : \00"
@.str.8 = [37 x i8] c"invalid selection, please try again\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @adainit()
%10 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%17 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i32, i32* %7
%23 = call i32 @test_standard_multiplicity_structure(i32 %22)
br label %40
24: ; preds = %2
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %7
%29 = call i32 @test_dobldobl_multiplicity_structure(i32 %28)
br label %39
30: ; preds = %24
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 3
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %7
%35 = call i32 @test_quaddobl_multiplicity_structure(i32 %34)
br label %38
36: ; preds = %30
%37 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
br label %39
39: ; preds = %38, %27
br label %40
40: ; preds = %39, %21
%41 = call i32 (...) @adafinal()
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [32 x i8] c"Type 0, 1, 2, or 3 to select : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [42 x i8] c"Give the maximum differentiation order : \00"
@str = [47 x i8] c"\0AMENU to compute the multiplicity structure : \00"
@str.9 = [43 x i8] c" 1. test with standard double arithmetic;\00"
@str.10 = [41 x i8] c" 2. test with double double arithmetic;\00"
@str.11 = [39 x i8] c" 3. test with quad double arithmetic.\00"
@str.12 = [36 x i8] c"invalid selection, please try again\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = tail call i32 (...) @adainit()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.10, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.11, i64 0, i64 0))
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %3
switch i32 %18, label %28 [
i32 1, label %19
i32 2, label %22
i32 3, label %25
]
19: ; preds = %2
%20 = load i32, i32* %4
%21 = call i32 @test_standard_multiplicity_structure(i32 %20)
br label %30
22: ; preds = %2
%23 = load i32, i32* %4
%24 = call i32 @test_dobldobl_multiplicity_structure(i32 %23)
br label %30
25: ; preds = %2
%26 = load i32, i32* %4
%27 = call i32 @test_quaddobl_multiplicity_structure(i32 %26)
br label %30
28: ; preds = %2
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.12, i64 0, i64 0))
br label %30
30: ; preds = %22, %28, %25, %19
%31 = call i32 (...) @adafinal()
ret i32 0
}