#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 getnights();
int menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ showprice(double, int);
int main(void) {
  int nights;
  double hotel_rate;
  int code;
  while ((code = menu()) != 5) {
    switch (code) {
    case 1:
      hotel_rate = 80.00;
      break;
    case 2:
      hotel_rate = 125.00;
      break;
    case 3:
      hotel_rate = 155.00;
      break;
    case 4:
      hotel_rate = 200.00;
      break;
    default:
      hotel_rate = 0.0;
      printf("Opps!\n");
      break;
    }
    nights = getnights();
    showprice(hotel_rate, nights);
  }
  printf("Thank you and good bye.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <menu@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x5,%eax
je     1203 <main+0xc3>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11d3 <main+0x93>
mov    -0x20(%rbp),%rax
lea    0xe9e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11e7 <main+0xa7>
movsd  0xe6b(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11e7 <main+0xa7>
movsd  0xe51(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11e7 <main+0xa7>
movsd  0xe37(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11e7 <main+0xa7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getnights@plt>
mov    %eax,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%edi
call   1030 <showprice@plt>
jmp    114f <main+0xf>
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xf01(%rip),%r14
lea    0xece(%rip),%rbx
jmp    1178 <main+0x38>
mov    %r14,%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
nop
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <getnights@plt>
movsd  (%rsp),%xmm0
mov    %eax,%edi
call   1040 <showprice@plt>
xor    %eax,%eax
call   1050 <menu@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1154 <main+0x14>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
movsd  0xe6a(%rip),%xmm0
jmp    *%rax
movsd  0xe78(%rip),%xmm0
jmp    1160 <main+0x20>
movsd  0xe66(%rip),%xmm0
jmp    1160 <main+0x20>
movsd  0xe54(%rip),%xmm0
jmp    1160 <main+0x20>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Opps!\0A\00"
@.str.1 = [25 x i8] c"Thank you and good bye.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %16, %0
%6 = call i32 (...) @menu()
store i32 %6, i32* %4
%7 = icmp ne i32 %6, 5
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i32, i32* %4
switch i32 %9, label %14 [
i32 1, label %10
i32 2, label %11
i32 3, label %12
i32 4, label %13
]
10: ; preds = %8
store double 8.000000e+01, double* %3
br label %16
11: ; preds = %8
store double 1.250000e+02, double* %3
br label %16
12: ; preds = %8
store double 1.550000e+02, double* %3
br label %16
13: ; preds = %8
store double 2.000000e+02, double* %3
br label %16
14: ; preds = %8
store double 0.000000e+00, double* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %13, %12, %11, %10
%17 = call i32 (...) @getnights()
store i32 %17, i32* %2
%18 = load double, double* %3
%19 = load i32, i32* %2
%20 = call i32 @showprice(double %18, i32 %19)
br label %5
21: ; preds = %5
%22 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [24 x i8] c"Thank you and good bye.\00"
@str.2 = [6 x i8] c"Opps!\00"
define i32 @main() {
br label %1
1: ; preds = %8, %0
%2 = tail call i32 (...) @menu()
switch i32 %2, label %6 [
i32 5, label %12
i32 1, label %8
i32 2, label %3
i32 3, label %4
i32 4, label %5
]
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.2, i64 0, i64 0))
br label %8
8: ; preds = %1, %6, %5, %4, %3
%9 = phi double [ 0.000000e+00, %6 ], [ 2.000000e+02, %5 ], [ 1.550000e+02, %4 ], [ 1.250000e+02, %3 ], [ 8.000000e+01, %1 ]
%10 = tail call i32 (...) @getnights()
%11 = tail call i32 @showprice(double %9, i32 %10)
br label %1
12: ; preds = %1
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
ret i32 0
}