#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 getCart__HT(char *, float *);
int getCart__TAX(char *, float *);
scalar_t__ getCookie(char *);
char *getenv(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
char *strstr(char *, char *);
int main(int argc, char **argv) {
  printf("Content-Type: text/plain;charset=us-ascii\n\n");
  char cookie[128];
  memset(cookie, 0, 128);
  if (getCookie(cookie)) {
    printf("0\n");
    goto end;
  }
  char *cents = NULL, *ptr_cents = NULL;
  cents = getenv("CENTS");
  if (cents)
    ptr_cents = strstr(cents, "TRUE");
  int ret;
  float f_ht = 0, f_tax = 0, f_shipping = 0, f_total = 0;
  ret = getCart__HT(cookie, &f_ht);
  ret = getCart__TAX(cookie, &f_tax);
  float discount = 0;
  if (f_ht < 0 || f_tax < 0) {
    printf("-\n");
    goto end;
  } else {
    f_total = f_ht + f_tax - discount;
  }
  if (ptr_cents) {
    f_total *= 100;
    printf("%i", (int)f_total);
  } else {
    printf("%.2f", f_total);
  }
end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x90(%rbp),%rdi
call   1070 <getCookie@plt>
cmp    $0x0,%rax
je     11d3 <main+0x63>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1340 <main+0x1d0>
movq   $0x0,-0x98(%rbp)
movq   $0x0,-0xa0(%rbp)
lea    0xe43(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     1224 <main+0xb4>
mov    -0x98(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,-0xa0(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xa8(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xac(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xb0(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xb4(%rbp)
ff
lea    -0x90(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
call   1080 <getCart__HT@plt>
mov    %eax,-0xa4(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0xac(%rbp),%rsi
call   1040 <getCart__TAX@plt>
mov    %eax,-0xa4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xb8(%rbp)
ff
xorps  %xmm0,%xmm0
ucomiss -0xa8(%rbp),%xmm0
ja     12ad <main+0x13d>
xorps  %xmm0,%xmm0
ucomiss -0xac(%rbp),%xmm0
jbe    12c0 <main+0x150>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1340 <main+0x1d0>
movss  -0xa8(%rbp),%xmm0
ff
addss  -0xac(%rbp),%xmm0
ff
subss  -0xb8(%rbp),%xmm0
ff
movss  %xmm0,-0xb4(%rbp)
ff
cmpq   $0x0,-0xa0(%rbp)
je     1321 <main+0x1b1>
movss  0xd0a(%rip),%xmm0
mulss  -0xb4(%rbp),%xmm0
ff
movss  %xmm0,-0xb4(%rbp)
ff
cvttss2si -0xb4(%rbp),%esi
ff
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    133b <main+0x1cb>
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd10(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1340 <main+0x1d0>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x98,%rsp
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
call   1080 <getCookie@plt>
test   %rax,%rax
je     11c8 <main+0x48>
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
jmp    127d <main+0xfd>
lea    0xe35(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11ed <main+0x6d>
lea    0xe2a(%rip),%rsi
mov    %rax,%rdi
call   10a0 <strstr@plt>
mov    %rax,%r14
jmp    11f0 <main+0x70>
xor    %r14d,%r14d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <getCart__HT@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <getCart__TAX@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
ja     125d <main+0xdd>
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm2
ja     125d <main+0xdd>
addss  %xmm1,%xmm0
test   %r14,%r14
je     126b <main+0xeb>
mulss  0xdb7(%rip),%xmm0
cvttss2si %xmm0,%esi
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    127d <main+0xfd>
lea    0xdde(%rip),%rdi
call   1040 <puts@plt>
jmp    127d <main+0xfd>
cvtss2sd %xmm0,%xmm0
lea    0xd9c(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Content-Type: text/plain;charset=us-ascii\0A\0A\00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [6 x i8] c"CENTS\00"
@.str.3 = [5 x i8] c"TRUE\00"
@.str.4 = [3 x i8] c"-\0A\00"
@.str.5 = [3 x i8] c"%i\00"
@.str.6 = [5 x i8] c"%.2f\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 128)
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%19 = call i64 @getCookie(i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %62
23: ; preds = %2
store i8* null, i8** %7
store i8* null, i8** %8
%24 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %7
%29 = call i8* @strstr(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %29, i8** %8
br label %30
30: ; preds = %27, %23
store float 0.000000e+00, float* %10
store float 0.000000e+00, float* %11
store float 0.000000e+00, float* %12
store float 0.000000e+00, float* %13
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%32 = call i32 @getCart__HT(i8* %31, float* %10)
store i32 %32, i32* %9
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%34 = call i32 @getCart__TAX(i8* %33, float* %11)
store i32 %34, i32* %9
store float 0.000000e+00, float* %14
%35 = load float, float* %10
%36 = fcmp olt float %35, 0.000000e+00
br i1 %36, label %40, label %37
37: ; preds = %30
%38 = load float, float* %11
%39 = fcmp olt float %38, 0.000000e+00
br i1 %39, label %40, label %42
40: ; preds = %37, %30
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %62
42: ; preds = %37
%43 = load float, float* %10
%44 = load float, float* %11
%45 = fadd float %43, %44
%46 = load float, float* %14
%47 = fsub float %45, %46
store float %47, float* %13
br label %48
48: ; preds = %42
%49 = load i8*, i8** %8
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = load float, float* %13
%53 = fmul float %52, 1.000000e+02
store float %53, float* %13
%54 = load float, float* %13
%55 = fptosi float %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %61
57: ; preds = %48
%58 = load float, float* %13
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %59)
br label %61
61: ; preds = %57, %51
br label %62
62: ; preds = %61, %40, %21
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"CENTS\00"
@.str.3 = [5 x i8] c"TRUE\00"
@.str.5 = [3 x i8] c"%i\00"
@.str.6 = [5 x i8] c"%.2f\00"
@str = [43 x i8] c"Content-Type: text/plain;charset=us-ascii\0A\00"
@str.7 = [2 x i8] c"-\00"
@str.8 = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca float
%5 = alloca float
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 128)
%9 = call i64 @getCookie(i8* %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
br label %39
13: ; preds = %2
%14 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i8* @strstr(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = phi i8* [ %17, %16 ], [ null, %13 ]
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%20 = call i32 @getCart__HT(i8* %7, float* %4)
%21 = call i32 @getCart__TAX(i8* %7, float* %5)
%22 = load float, float* %4
%23 = fcmp olt float %22, 0.000000e+00
%24 = load float, float* %5
%25 = fcmp olt float %24, 0.000000e+00
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %27, label %29
27: ; preds = %18
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
br label %39
29: ; preds = %18
%30 = fadd float %22, %24
%31 = icmp eq i8* %19, null
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = fmul float %30, 1.000000e+02
%34 = fptosi float %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %39
36: ; preds = %29
%37 = fpext float %30 to double
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %37)
br label %39
39: ; preds = %32, %36, %27, %11
ret i32 0
}