#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 commercial_calculation(int);
double industrial_calculation(int, int);
double residential_calculation(int);
double determine_amount_due(char use_code, int consumption1, int consumption2) {
  double amount_due = 0.0;
  switch (use_code) {
  case ('R'):
  case ('r'):
    amount_due = residential_calculation(consumption1);
    break;
  case ('C'):
  case ('c'):
    amount_due = commercial_calculation(consumption1);
    break;
  case ('i'):
  case ('I'):
    amount_due = industrial_calculation(consumption1, consumption2);
    break;
  default:
    break;
  }
  return amount_due;
}


x86 assembly (clang, -O0):
<determine_amount_due>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x43,%eax
je     11c8 <determine_amount_due+0x98>
jmp    1161 <determine_amount_due+0x31>
mov    -0x1c(%rbp),%eax
sub    $0x49,%eax
je     11da <determine_amount_due+0xaa>
jmp    1172 <determine_amount_due+0x42>
mov    -0x1c(%rbp),%eax
sub    $0x52,%eax
je     11b6 <determine_amount_due+0x86>
jmp    1183 <determine_amount_due+0x53>
mov    -0x1c(%rbp),%eax
sub    $0x63,%eax
je     11c8 <determine_amount_due+0x98>
jmp    1194 <determine_amount_due+0x64>
mov    -0x1c(%rbp),%eax
sub    $0x69,%eax
je     11da <determine_amount_due+0xaa>
jmp    11a5 <determine_amount_due+0x75>
mov    -0x1c(%rbp),%eax
sub    $0x72,%eax
jne    11ef <determine_amount_due+0xbf>
jmp    11b6 <determine_amount_due+0x86>
mov    -0x8(%rbp),%edi
call   1030 <residential_calculation@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11f4 <determine_amount_due+0xc4>
mov    -0x8(%rbp),%edi
call   1040 <commercial_calculation@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11f4 <determine_amount_due+0xc4>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <industrial_calculation@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11f4 <determine_amount_due+0xc4>
jmp    11f4 <determine_amount_due+0xc4>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_amount_due>:
add    $0xffffffbd,%edi
cmp    $0x2f,%edi
ja     117f <determine_amount_due+0x4f>
movabs $0x100000001,%rax
bt     %rdi,%rax
jb     1178 <determine_amount_due+0x48>
movabs $0x4000000040,%rax
bt     %rdi,%rax
jb     116f <determine_amount_due+0x3f>
movabs $0x800000008000,%rax
bt     %rdi,%rax
jae    117f <determine_amount_due+0x4f>
mov    %esi,%edi
jmp    1030 <residential_calculation@plt>
mov    %esi,%edi
mov    %edx,%esi
jmp    1050 <industrial_calculation@plt>
mov    %esi,%edi
jmp    1040 <commercial_calculation@plt>
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @determine_amount_due(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %7
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
switch i32 %9, label %20 [
i32 82, label %10
i32 114, label %10
i32 67, label %13
i32 99, label %13
i32 105, label %16
i32 73, label %16
]
10: ; preds = %3, %3
%11 = load i32, i32* %5
%12 = call double @residential_calculation(i32 %11)
store double %12, double* %7
br label %21
13: ; preds = %3, %3
%14 = load i32, i32* %5
%15 = call double @commercial_calculation(i32 %14)
store double %15, double* %7
br label %21
16: ; preds = %3, %3
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call double @industrial_calculation(i32 %17, i32 %18)
store double %19, double* %7
br label %21
20: ; preds = %3
br label %21
21: ; preds = %20, %16, %13, %10
%22 = load double, double* %7
ret double %22
}

LLVM IR (-O2):
define double @determine_amount_due(i8 signext %0, i32 %1, i32 %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %11 [
i32 82, label %5
i32 114, label %5
i32 67, label %7
i32 99, label %7
i32 105, label %9
i32 73, label %9
]
5: ; preds = %3, %3
%6 = tail call double @residential_calculation(i32 %1)
br label %11
7: ; preds = %3, %3
%8 = tail call double @commercial_calculation(i32 %1)
br label %11
9: ; preds = %3, %3
%10 = tail call double @industrial_calculation(i32 %1, i32 %2)
br label %11
11: ; preds = %3, %9, %7, %5
%12 = phi double [ 0.000000e+00, %3 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
ret double %12
}