#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 determine_amount_due(char, int, int);
int /*<<< orphan*/ display_amount_due(int, double);
int /*<<< orphan*/ display_message(int);
int prompt_account_number();
int prompt_consumption(char *);
char prompt_use_code();
int main(void) {
  char use_code = '\0';
  int correct_code = 1;
  int account_number = 0, consumption_1 = 0, consumption_2 = 0;
  double amount_due = 0.0;
  display_message(1);
  account_number = prompt_account_number();
  do {
    use_code = prompt_use_code();
    switch (use_code) {
    case ('R'):
    case ('r'):
    case ('C'):
    case ('c'):
      consumption_1 = prompt_consumption("Consumption");
      amount_due = determine_amount_due(use_code, consumption_1, -1);
      break;
    case ('i'):
    case ('I'):
      consumption_1 = prompt_consumption("Peak Consumption");
      consumption_2 = prompt_consumption("Off-Peak Consumption");
      amount_due = determine_amount_due(use_code, consumption_1, consumption_2);
      break;
    default:
      correct_code = 0;
      display_message(2);
      break;
    }
  } while (correct_code == 0);
  display_amount_due(account_number, amount_due);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x1,%edi
call   1060 <display_message@plt>
mov    $0x0,%al
call   1030 <prompt_account_number@plt>
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
call   1080 <prompt_use_code@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x43,%eax
je     121f <main+0xbf>
jmp    11ca <main+0x6a>
mov    -0x24(%rbp),%eax
sub    $0x49,%eax
je     124b <main+0xeb>
jmp    11db <main+0x7b>
mov    -0x24(%rbp),%eax
sub    $0x52,%eax
je     121f <main+0xbf>
jmp    11ec <main+0x8c>
mov    -0x24(%rbp),%eax
sub    $0x63,%eax
je     121f <main+0xbf>
jmp    11fd <main+0x9d>
mov    -0x24(%rbp),%eax
sub    $0x69,%eax
je     124b <main+0xeb>
jmp    120e <main+0xae>
mov    -0x24(%rbp),%eax
sub    $0x72,%eax
jne    1284 <main+0x124>
jmp    121f <main+0xbf>
lea    0xde3(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,-0x14(%rbp)
mov    -0x5(%rbp),%al
mov    -0x14(%rbp),%esi
mov    $0xffffffff,%edx
movsbl %al,%edi
call   1050 <determine_amount_due@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1295 <main+0x135>
lea    0xdb2(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,-0x14(%rbp)
lea    0xd9f(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,-0x18(%rbp)
mov    -0x5(%rbp),%al
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
movsbl %al,%edi
call   1050 <determine_amount_due@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1295 <main+0x135>
movl   $0x0,-0xc(%rbp)
mov    $0x2,%edi
call   1060 <display_message@plt>
jmp    129a <main+0x13a>
cmpl   $0x0,-0xc(%rbp)
je     11ab <main+0x4b>
mov    -0x10(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
call   1040 <display_amount_due@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
call   1060 <display_message@plt>
xor    %eax,%eax
call   1030 <prompt_account_number@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1080 <prompt_use_code@plt>
movsbl %al,%ebx
lea    -0x43(%rbx),%eax
movabs $0x800100008001,%r13
cmp    $0x2f,%eax
ja     1204 <main+0xa4>
bt     %rax,%r13
jae    11b6 <main+0x56>
lea    0xe61(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,%ebp
mov    $0xffffffff,%edx
jmp    11e2 <main+0x82>
movabs $0x4000000040,%rcx
bt     %rax,%rcx
jae    1204 <main+0xa4>
lea    0xe37(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,%ebp
lea    0xe25(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,%edx
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <determine_amount_due@plt>
mov    %r14d,%edi
call   1040 <display_amount_due@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%edi
call   1060 <display_message@plt>
lea    0xdf4(%rip),%r12
movabs $0x4000000040,%r14
lea    0xdda(%rip),%r15
jmp    1246 <main+0xe6>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1070 <prompt_consumption@plt>
mov    %ebp,%edi
mov    %eax,%esi
mov    $0xffffffff,%edx
call   1050 <determine_amount_due@plt>
xor    %eax,%eax
call   1080 <prompt_use_code@plt>
movsbl %al,%ebp
lea    -0x43(%rbp),%eax
cmp    $0x2f,%eax
ja     1287 <main+0x127>
bt     %rax,%r13
jb     1230 <main+0xd0>
bt     %rax,%r14
jae    1287 <main+0x127>
lea    0xd99(%rip),%rdi
call   1070 <prompt_consumption@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1070 <prompt_consumption@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <determine_amount_due@plt>
jmp    1246 <main+0xe6>
mov    $0x2,%edi
call   1060 <display_message@plt>
jmp    1246 <main+0xe6>

LLVM IR (-O0):
@.str = [12 x i8] c"Consumption\00"
@.str.1 = [17 x i8] c"Peak Consumption\00"
@.str.2 = [21 x i8] c"Off-Peak Consumption\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 0, i32* %1
store i8 0, i8* %2
store i32 1, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store double 0.000000e+00, double* %7
%8 = call i32 @display_message(i32 1)
%9 = call i32 (...) @prompt_account_number()
store i32 %9, i32* %4
br label %10
10: ; preds = %29, %0
%11 = call signext i8 (...) @prompt_use_code()
store i8 %11, i8* %2
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
switch i32 %13, label %26 [
i32 82, label %14
i32 114, label %14
i32 67, label %14
i32 99, label %14
i32 105, label %19
i32 73, label %19
]
14: ; preds = %10, %10, %10, %10
%15 = call i32 @prompt_consumption(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %5
%16 = load i8, i8* %2
%17 = load i32, i32* %5
%18 = call double @determine_amount_due(i8 signext %16, i32 %17, i32 -1)
store double %18, double* %7
br label %28
19: ; preds = %10, %10
%20 = call i32 @prompt_consumption(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 %20, i32* %5
%21 = call i32 @prompt_consumption(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 %21, i32* %6
%22 = load i8, i8* %2
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call double @determine_amount_due(i8 signext %22, i32 %23, i32 %24)
store double %25, double* %7
br label %28
26: ; preds = %10
store i32 0, i32* %3
%27 = call i32 @display_message(i32 2)
br label %28
28: ; preds = %26, %19, %14
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 0
br i1 %31, label %10, label %32
32: ; preds = %29
%33 = load i32, i32* %4
%34 = load double, double* %7
%35 = call i32 @display_amount_due(i32 %33, double %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Consumption\00"
@.str.1 = [17 x i8] c"Peak Consumption\00"
@.str.2 = [21 x i8] c"Off-Peak Consumption\00"
define i32 @main() {
%1 = tail call i32 @display_message(i32 1)
%2 = tail call i32 (...) @prompt_account_number()
%3 = tail call signext i8 (...) @prompt_use_code()
%4 = sext i8 %3 to i32
switch i32 %4, label %10 [
i32 82, label %8
i32 114, label %8
i32 67, label %8
i32 99, label %8
i32 105, label %5
i32 73, label %5
]
5: ; preds = %0, %0
%6 = tail call i32 @prompt_consumption(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @prompt_consumption(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %25
8: ; preds = %0, %0, %0, %0
%9 = tail call i32 @prompt_consumption(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %25
10: ; preds = %0
%11 = tail call i32 @display_message(i32 2)
br label %12
12: ; preds = %18, %10
%13 = tail call signext i8 (...) @prompt_use_code()
%14 = sext i8 %13 to i32
switch i32 %14, label %23 [
i32 82, label %15
i32 114, label %15
i32 67, label %15
i32 99, label %15
i32 105, label %19
i32 73, label %19
]
15: ; preds = %12, %12, %12, %12
%16 = tail call i32 @prompt_consumption(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%17 = tail call double @determine_amount_due(i8 signext %13, i32 %16, i32 -1)
br label %18
18: ; preds = %15, %19, %23
br label %12
19: ; preds = %12, %12
%20 = tail call i32 @prompt_consumption(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @prompt_consumption(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call double @determine_amount_due(i8 signext %13, i32 %20, i32 %21)
br label %18
23: ; preds = %12
%24 = tail call i32 @display_message(i32 2)
br label %18
25: ; preds = %8, %5
%26 = phi i32 [ -1, %8 ], [ %7, %5 ]
%27 = phi i32 [ %9, %8 ], [ %6, %5 ]
%28 = tail call double @determine_amount_due(i8 signext %3, i32 %27, i32 %26)
%29 = tail call i32 @display_amount_due(i32 %2, double %28)
ret i32 0
}