#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 */
char getchar();
int /*<<< orphan*/ menu();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, ...);
int main(void) {
  float weightA = 0, weightB = 0, weightC = 0;
  char type;
  menu();
  while (scanf("%c", &type) && type != 'q') {
    while (getchar() != '\n')
      continue;
    float addition;
    switch (type) {
    case 'a':
      printf("please enter the weight (in pound) of artichoke\n");
      scanf("%f", &addition);
      weightA += addition;
      break;
    case 'b':
      printf("please enter the weight (in pound) of beet\n");
      scanf("%f", &addition);
      weightB += addition;
      break;
    case 'c':
      printf("please enter the weight (in pound) of carrot\n");
      scanf("%f", &addition);
      weightC += addition;
      break;
    default:
      printf("No such option! Please enter a letter within the range a ~ c & "
             "q.\n");
      continue;
    }
    while (getchar() != '\n')
      continue;
    menu();
  }
  float costA = weightA * 1.25, costB = weightB * 0.65, costC = weightC * 0.89,
        costABC = costA + costB + costC, weight = weightA + weightB + weightC,
        costTrans = weight < 5    ? 3.5
                    : weight < 20 ? 10.0
                                  : 8 + 0.1 * (weight - 20),
        discount = costABC > 100 ? 0.05 * costABC : 0,
        costT = costABC - discount + costTrans;
  printf("\n***********************************\n\n");
  printf("Unit price:\n");
  printf("Artichoke: $%.2f\tBeet: $%.2f\n", 1.25, 0.65);
  printf("Carrot: $%.2f\n\n", 0.89);
  printf("Weight ordered:\n");
  printf("Artichoke: %.2f\t\tBeet: %.2f\n", weightA, weightB);
  printf("Carrot: %.2f\n\n", weightC);
  printf("Order price:\n");
  printf("Artichoke: $%.2f\tBeet: $%.2f\n", costA, costB);
  printf("Carrot: $%.2f\t\tAll: $%.2f\n\n", costC, costABC);
  printf("Discount: $%.2f\n", discount);
  printf("Transportation cost: $%.2f\n\n", costTrans);
  printf("Total: $%.2f\n", costT);
  printf("\n***********************************\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <menu@plt>
lea    0xedb(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x39(%rbp)
je     119f <main+0x5f>
movsbl -0x11(%rbp),%eax
cmp    $0x71,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11af <main+0x6f>
jmp    12db <main+0x19b>
jmp    11b4 <main+0x74>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11cc <main+0x8c>
jmp    11b4 <main+0x74>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x61,%eax
je     1203 <main+0xc3>
jmp    11e1 <main+0xa1>
mov    -0x40(%rbp),%eax
sub    $0x62,%eax
je     1237 <main+0xf7>
jmp    11f2 <main+0xb2>
mov    -0x40(%rbp),%eax
sub    $0x63,%eax
je     126b <main+0x12b>
jmp    129f <main+0x15f>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12b2 <main+0x172>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe38(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12b2 <main+0x172>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe04(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    12b2 <main+0x172>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    116e <main+0x2e>
jmp    12b7 <main+0x177>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     12cf <main+0x18f>
jmp    12b7 <main+0x177>
mov    $0x0,%al
call   1030 <menu@plt>
jmp    116e <main+0x2e>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd34(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xce8(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xc9b(%rip),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    1381 <main+0x241>
movsd  0xcc9(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    13e1 <main+0x2a1>
movss  0xc7b(%rip),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    13a5 <main+0x265>
movsd  0xc9d(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    13d7 <main+0x297>
movss  -0x2c(%rbp),%xmm0
movss  0xc52(%rip),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc66(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc62(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
movss  0xc0c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1424 <main+0x2e4>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xc32(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1431 <main+0x2f1>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1431 <main+0x2f1>
movsd  -0x58(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x28(%rbp),%xmm0
subss  -0x34(%rbp),%xmm0
addss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xce2(%rip),%rdi
movsd  0xba2(%rip),%xmm0
movsd  0xb92(%rip),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xce2(%rip),%rdi
movsd  0xb74(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xccd(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcd3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xc49(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xca2(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xca7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xca1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xca7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xba2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1040 <menu@plt>
lea    0xee4(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
test   %rax,%rax
je     12db <main+0x18b>
cmpb   $0x71,0x7(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
je     12ed <main+0x19d>
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xe9c(%rip),%r15
lea    0x18(%rsp),%r12
lea    0xe8d(%rip),%r13
lea    0x7(%rsp),%rbx
lea    0xfe0(%rip),%r14
lea    0x1009(%rip),%rbp
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    11f0 <main+0xa0>
movsbl 0x7(%rsp),%eax
cmp    $0x63,%eax
je     123c <main+0xec>
cmp    $0x62,%eax
je     1269 <main+0x119>
cmp    $0x61,%eax
jne    12b4 <main+0x164>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x8(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
jmp    12a0 <main+0x150>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0xc(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    12a0 <main+0x150>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x10(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    12a0 <main+0x150>
xor    %eax,%eax
call   1040 <menu@plt>
jmp    12bc <main+0x16c>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
test   %rax,%rax
je     12ed <main+0x19d>
cmpb   $0x71,0x7(%rsp)
jne    11f0 <main+0xa0>
jmp    12ed <main+0x19d>
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xd0b(%rip),%xmm4
movss  0x10(%rsp),%xmm2
cvtss2sd %xmm2,%xmm1
movsd  0xd19(%rip),%xmm0
movsd  %xmm1,0x30(%rsp)
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm5
movss  0xc(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
movsd  0xcfe(%rip),%xmm0
movsd  %xmm1,0x38(%rsp)
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
mulss  %xmm1,%xmm4
movss  %xmm4,0x24(%rsp)
movss  %xmm5,0x1c(%rsp)
addss  %xmm5,%xmm4
movss  %xmm0,0x20(%rsp)
addss  %xmm0,%xmm4
addss  %xmm1,%xmm2
addss  %xmm3,%xmm2
movss  0xc9c(%rip),%xmm0
ucomiss %xmm2,%xmm0
jbe    137b <main+0x22b>
movss  0xc8b(%rip),%xmm2
jmp    13b8 <main+0x268>
movss  0xc8d(%rip),%xmm0
ucomiss %xmm2,%xmm0
jbe    1392 <main+0x242>
movss  0xc7c(%rip),%xmm2
jmp    13b8 <main+0x268>
addss  0xc7a(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulsd  0xc87(%rip),%xmm0
addsd  0xc87(%rip),%xmm0
xorps  %xmm2,%xmm2
cvtsd2ss %xmm0,%xmm2
movss  %xmm2,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xc60(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xc28(%rip),%xmm1
cmpltss %xmm4,%xmm1
andps  %xmm0,%xmm1
movaps %xmm1,0x40(%rsp)
subss  %xmm1,%xmm4
addss  %xmm2,%xmm4
movss  %xmm4,0x8(%rsp)
lea    0xd1f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xce7(%rip),%rdi
call   1030 <puts@plt>
lea    0xc29(%rip),%rbp
movsd  0xc13(%rip),%xmm0
movsd  0xbe3(%rip),%xmm1
mov    %rbp,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xc26(%rip),%rdi
movsd  0xbd2(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xcb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xc14(%rip),%rdi
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xc17(%rip),%rdi
movsd  0x38(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xc86(%rip),%rdi
call   1030 <puts@plt>
movss  0x24(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %rbp,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbde(%rip),%rdi
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
movaps 0x40(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbdd(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbd6(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbdb(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [49 x i8] c"please enter the weight (in pound) of artichoke\0A\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [44 x i8] c"please enter the weight (in pound) of beet\0A\00"
@.str.4 = [46 x i8] c"please enter the weight (in pound) of carrot\0A\00"
@.str.5 = [67 x i8] c"No such option! Please enter a letter within the range a ~ c & q.\0A\00"
@.str.6 = [39 x i8] c"\0A***********************************\0A\0A\00"
@.str.7 = [13 x i8] c"Unit price:\0A\00"
@.str.8 = [30 x i8] c"Artichoke: $%.2f\09Beet: $%.2f\0A\00"
@.str.9 = [16 x i8] c"Carrot: $%.2f\0A\0A\00"
@.str.10 = [17 x i8] c"Weight ordered:\0A\00"
@.str.11 = [29 x i8] c"Artichoke: %.2f\09\09Beet: %.2f\0A\00"
@.str.12 = [15 x i8] c"Carrot: %.2f\0A\0A\00"
@.str.13 = [14 x i8] c"Order price:\0A\00"
@.str.14 = [28 x i8] c"Carrot: $%.2f\09\09All: $%.2f\0A\0A\00"
@.str.15 = [17 x i8] c"Discount: $%.2f\0A\00"
@.str.16 = [29 x i8] c"Transportation cost: $%.2f\0A\0A\00"
@.str.17 = [14 x i8] c"Total: $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i8
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%15 = call i32 (...) @menu()
br label %16
16: ; preds = %60, %52, %0
%17 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 113
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %25, label %62
25: ; preds = %23
br label %26
26: ; preds = %30, %25
%27 = call signext i8 (...) @getchar()
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %26
br label %26
31: ; preds = %26
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
switch i32 %33, label %52 [
i32 97, label %34
i32 98, label %40
i32 99, label %46
]
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%36 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %6)
%37 = load float, float* %6
%38 = load float, float* %2
%39 = fadd float %38, %37
store float %39, float* %2
br label %54
40: ; preds = %31
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%42 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %6)
%43 = load float, float* %6
%44 = load float, float* %3
%45 = fadd float %44, %43
store float %45, float* %3
br label %54
46: ; preds = %31
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%48 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %6)
%49 = load float, float* %6
%50 = load float, float* %4
%51 = fadd float %50, %49
store float %51, float* %4
br label %54
52: ; preds = %31
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0))
br label %16
54: ; preds = %46, %40, %34
br label %55
55: ; preds = %59, %54
%56 = call signext i8 (...) @getchar()
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 10
br i1 %58, label %59, label %60
59: ; preds = %55
br label %55
60: ; preds = %55
%61 = call i32 (...) @menu()
br label %16
62: ; preds = %23
%63 = load float, float* %2
%64 = fpext float %63 to double
%65 = fmul double %64, 1.250000e+00
%66 = fptrunc double %65 to float
store float %66, float* %7
%67 = load float, float* %3
%68 = fpext float %67 to double
%69 = fmul double %68, 6.500000e-01
%70 = fptrunc double %69 to float
store float %70, float* %8
%71 = load float, float* %4
%72 = fpext float %71 to double
%73 = fmul double %72, 8.900000e-01
%74 = fptrunc double %73 to float
store float %74, float* %9
%75 = load float, float* %7
%76 = load float, float* %8
%77 = fadd float %75, %76
%78 = load float, float* %9
%79 = fadd float %77, %78
store float %79, float* %10
%80 = load float, float* %2
%81 = load float, float* %3
%82 = fadd float %80, %81
%83 = load float, float* %4
%84 = fadd float %82, %83
store float %84, float* %11
%85 = load float, float* %11
%86 = fcmp olt float %85, 5.000000e+00
br i1 %86, label %87, label %88
87: ; preds = %62
br label %99
88: ; preds = %62
%89 = load float, float* %11
%90 = fcmp olt float %89, 2.000000e+01
br i1 %90, label %91, label %92
91: ; preds = %88
br label %97
92: ; preds = %88
%93 = load float, float* %11
%94 = fsub float %93, 2.000000e+01
%95 = fpext float %94 to double
%96 = call double @llvm.fmuladd.f64(double 1.000000e-01, double %95, double 8.000000e+00)
br label %97
97: ; preds = %92, %91
%98 = phi double [ 1.000000e+01, %91 ], [ %96, %92 ]
br label %99
99: ; preds = %97, %87
%100 = phi double [ 3.500000e+00, %87 ], [ %98, %97 ]
%101 = fptrunc double %100 to float
store float %101, float* %12
%102 = load float, float* %10
%103 = fcmp ogt float %102, 1.000000e+02
br i1 %103, label %104, label %108
104: ; preds = %99
%105 = load float, float* %10
%106 = fpext float %105 to double
%107 = fmul double 5.000000e-02, %106
br label %109
108: ; preds = %99
br label %109
109: ; preds = %108, %104
%110 = phi double [ %107, %104 ], [ 0.000000e+00, %108 ]
%111 = fptrunc double %110 to float
store float %111, float* %13
%112 = load float, float* %10
%113 = load float, float* %13
%114 = fsub float %112, %113
%115 = load float, float* %12
%116 = fadd float %114, %115
store float %116, float* %14
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double 1.250000e+00, double 6.500000e-01)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double 8.900000e-01)
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%122 = load float, float* %2
%123 = fpext float %122 to double
%124 = load float, float* %3
%125 = fpext float %124 to double
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), double %123, double %125)
%127 = load float, float* %4
%128 = fpext float %127 to double
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), double %128)
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0))
%131 = load float, float* %7
%132 = fpext float %131 to double
%133 = load float, float* %8
%134 = fpext float %133 to double
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double %132, double %134)
%136 = load float, float* %9
%137 = fpext float %136 to double
%138 = load float, float* %10
%139 = fpext float %138 to double
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), double %137, double %139)
%141 = load float, float* %13
%142 = fpext float %141 to double
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0), double %142)
%144 = load float, float* %12
%145 = fpext float %144 to double
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0), double %145)
%147 = load float, float* %14
%148 = fpext float %147 to double
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), double %148)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.8 = [30 x i8] c"Artichoke: $%.2f\09Beet: $%.2f\0A\00"
@.str.9 = [16 x i8] c"Carrot: $%.2f\0A\0A\00"
@.str.11 = [29 x i8] c"Artichoke: %.2f\09\09Beet: %.2f\0A\00"
@.str.12 = [15 x i8] c"Carrot: %.2f\0A\0A\00"
@.str.14 = [28 x i8] c"Carrot: $%.2f\09\09All: $%.2f\0A\0A\00"
@.str.15 = [17 x i8] c"Discount: $%.2f\0A\00"
@.str.16 = [29 x i8] c"Transportation cost: $%.2f\0A\0A\00"
@.str.17 = [14 x i8] c"Total: $%.2f\0A\00"
@str.18 = [12 x i8] c"Unit price:\00"
@str.19 = [16 x i8] c"Weight ordered:\00"
@str.20 = [13 x i8] c"Order price:\00"
@str.21 = [38 x i8] c"\0A***********************************\0A\00"
@str.22 = [45 x i8] c"please enter the weight (in pound) of carrot\00"
@str.23 = [43 x i8] c"please enter the weight (in pound) of beet\00"
@str.24 = [48 x i8] c"please enter the weight (in pound) of artichoke\00"
@str.25 = [66 x i8] c"No such option! Please enter a letter within the range a ~ c & q.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = tail call i32 (...) @menu()
%4 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = icmp ne i64 %4, 0
%6 = load i8, i8* %1
%7 = icmp ne i8 %6, 113
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %56
9: ; preds = %0
%10 = bitcast float* %2 to i8*
br label %11
11: ; preds = %9, %47
%12 = phi float [ 0.000000e+00, %9 ], [ %50, %47 ]
%13 = phi float [ 0.000000e+00, %9 ], [ %49, %47 ]
%14 = phi float [ 0.000000e+00, %9 ], [ %48, %47 ]
br label %15
15: ; preds = %11, %15
%16 = call signext i8 (...) @getchar()
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %15
18: ; preds = %15
%19 = load i8, i8* %1
%20 = sext i8 %19 to i32
switch i32 %20, label %36 [
i32 97, label %21
i32 98, label %26
i32 99, label %31
]
21: ; preds = %18
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.24, i64 0, i64 0))
%23 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%24 = load float, float* %2
%25 = fadd float %12, %24
br label %38
26: ; preds = %18
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.23, i64 0, i64 0))
%28 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%29 = load float, float* %2
%30 = fadd float %13, %29
br label %38
31: ; preds = %18
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.22, i64 0, i64 0))
%33 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%34 = load float, float* %2
%35 = fadd float %14, %34
br label %38
36: ; preds = %18
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.25, i64 0, i64 0))
br label %47
38: ; preds = %31, %26, %21
%39 = phi float [ %35, %31 ], [ %14, %26 ], [ %14, %21 ]
%40 = phi float [ %13, %31 ], [ %30, %26 ], [ %13, %21 ]
%41 = phi float [ %12, %31 ], [ %12, %26 ], [ %25, %21 ]
br label %42
42: ; preds = %42, %38
%43 = call signext i8 (...) @getchar()
%44 = icmp eq i8 %43, 10
br i1 %44, label %45, label %42
45: ; preds = %42
%46 = call i32 (...) @menu()
br label %47
47: ; preds = %45, %36
%48 = phi float [ %14, %36 ], [ %39, %45 ]
%49 = phi float [ %13, %36 ], [ %40, %45 ]
%50 = phi float [ %12, %36 ], [ %41, %45 ]
%51 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%52 = icmp ne i64 %51, 0
%53 = load i8, i8* %1
%54 = icmp ne i8 %53, 113
%55 = select i1 %52, i1 %54, i1 false
br i1 %55, label %11, label %56
56: ; preds = %47, %0
%57 = phi float [ 0.000000e+00, %0 ], [ %48, %47 ]
%58 = phi float [ 0.000000e+00, %0 ], [ %49, %47 ]
%59 = phi float [ 0.000000e+00, %0 ], [ %50, %47 ]
%60 = fmul float %59, 1.250000e+00
%61 = fpext float %58 to double
%62 = fmul double %61, 6.500000e-01
%63 = fptrunc double %62 to float
%64 = fpext float %57 to double
%65 = fmul double %64, 8.900000e-01
%66 = fptrunc double %65 to float
%67 = fadd float %60, %63
%68 = fadd float %67, %66
%69 = fadd float %58, %59
%70 = fadd float %57, %69
%71 = fcmp olt float %70, 5.000000e+00
br i1 %71, label %79, label %72
72: ; preds = %56
%73 = fcmp olt float %70, 2.000000e+01
br i1 %73, label %79, label %74
74: ; preds = %72
%75 = fadd float %70, -2.000000e+01
%76 = fpext float %75 to double
%77 = call double @llvm.fmuladd.f64(double %76, double 1.000000e-01, double 8.000000e+00)
%78 = fptrunc double %77 to float
br label %79
79: ; preds = %74, %72, %56
%80 = phi float [ 3.500000e+00, %56 ], [ %78, %74 ], [ 1.000000e+01, %72 ]
%81 = fpext float %59 to double
%82 = fcmp ogt float %68, 1.000000e+02
%83 = fpext float %68 to double
%84 = fmul double %83, 5.000000e-02
%85 = fptrunc double %84 to float
%86 = select i1 %82, float %85, float 0.000000e+00
%87 = fsub float %68, %86
%88 = fadd float %87, %80
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.21, i64 0, i64 0))
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double 1.250000e+00, double 6.500000e-01)
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double 8.900000e-01)
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.19, i64 0, i64 0))
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), double %81, double %61)
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), double %64)
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.20, i64 0, i64 0))
%97 = fpext float %60 to double
%98 = fpext float %63 to double
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double %97, double %98)
%100 = fpext float %66 to double
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), double %100, double %83)
%102 = fpext float %86 to double
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0), double %102)
%104 = fpext float %80 to double
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0), double %104)
%106 = fpext float %88 to double
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), double %106)
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.21, i64 0, i64 0))
ret i32 0
}