#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 */
double MS_1(int, int, double, double);
double MS_2(int, int, double, double);
double MS_3(int, int, double, double);
double MS_4(int, int, double, double);
double MS_5(int, int, double, double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
double MS_qnt_2D(int MS_no, int qnt_type, int qnt_id, double x, double y) {
  double qnt;
  switch (MS_no) {
  case 1:
    qnt = MS_1(qnt_type, qnt_id, x, y);
    break;
  case 2:
    qnt = MS_2(qnt_type, qnt_id, x, y);
    break;
  case 3:
    qnt = MS_3(qnt_type, qnt_id, x, y);
    break;
  case 4:
    qnt = MS_4(qnt_type, qnt_id, x, y);
    break;
  case 5:
    qnt = MS_5(qnt_type, qnt_id, x, y);
    break;
  default:
    printf("No MS is chosen! exit...\n");
    exit(1);
  }
  return (qnt);
}


x86 assembly (clang, -O0):
<MS_qnt_2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x4,%eax
ja     124f <MS_qnt_2D+0xdf>
mov    -0x30(%rbp),%rax
lea    0xe55(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1050 <MS_1@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1265 <MS_qnt_2D+0xf5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1080 <MS_2@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1265 <MS_qnt_2D+0xf5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <MS_3@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1265 <MS_qnt_2D+0xf5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1070 <MS_4@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1265 <MS_qnt_2D+0xf5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <MS_5@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1265 <MS_qnt_2D+0xf5>
lea    0xdbe(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MS_qnt_2D>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x4,%edi
ja     11bb <MS_qnt_2D+0x4b>
lea    0xe80(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1050 <MS_1@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1080 <MS_2@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1040 <MS_3@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1070 <MS_4@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1030 <MS_5@plt>
lea    0xe52(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"No MS is chosen! exit...\0A\00"
define double @MS_qnt_2D(i32 %0, i32 %1, i32 %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double %3, double* %9
store double %4, double* %10
%12 = load i32, i32* %6
switch i32 %12, label %43 [
i32 1, label %13
i32 2, label %19
i32 3, label %25
i32 4, label %31
i32 5, label %37
]
13: ; preds = %5
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = load double, double* %9
%17 = load double, double* %10
%18 = call double @MS_1(i32 %14, i32 %15, double %16, double %17)
store double %18, double* %11
br label %46
19: ; preds = %5
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = load double, double* %9
%23 = load double, double* %10
%24 = call double @MS_2(i32 %20, i32 %21, double %22, double %23)
store double %24, double* %11
br label %46
25: ; preds = %5
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = load double, double* %9
%29 = load double, double* %10
%30 = call double @MS_3(i32 %26, i32 %27, double %28, double %29)
store double %30, double* %11
br label %46
31: ; preds = %5
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = load double, double* %9
%35 = load double, double* %10
%36 = call double @MS_4(i32 %32, i32 %33, double %34, double %35)
store double %36, double* %11
br label %46
37: ; preds = %5
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load double, double* %9
%41 = load double, double* %10
%42 = call double @MS_5(i32 %38, i32 %39, double %40, double %41)
store double %42, double* %11
br label %46
43: ; preds = %5
%44 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %37, %31, %25, %19, %13
%47 = load double, double* %11
ret double %47
}

LLVM IR (-O2):
@str = [25 x i8] c"No MS is chosen! exit...\00"
define double @MS_qnt_2D(i32 %0, i32 %1, i32 %2, double %3, double %4) {
switch i32 %0, label %16 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
]
6: ; preds = %5
%7 = tail call double @MS_1(i32 %1, i32 %2, double %3, double %4)
br label %19
8: ; preds = %5
%9 = tail call double @MS_2(i32 %1, i32 %2, double %3, double %4)
br label %19
10: ; preds = %5
%11 = tail call double @MS_3(i32 %1, i32 %2, double %3, double %4)
br label %19
12: ; preds = %5
%13 = tail call double @MS_4(i32 %1, i32 %2, double %3, double %4)
br label %19
14: ; preds = %5
%15 = tail call double @MS_5(i32 %1, i32 %2, double %3, double %4)
br label %19
16: ; preds = %5
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %14, %12, %10, %8, %6
%20 = phi double [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ]
ret double %20
}