#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__SHIPPING(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 *, ...);
int /*<<< orphan*/ putLog(char *, 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("-\n");
    goto end;
  }
  char *cents = NULL, *ptr_cents = NULL;
  cents = getenv("CENTS");
  if (cents)
    ptr_cents = strstr(cents, "TRUE");
  int ret = 0;
  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);
  ret = getCart__SHIPPING(cookie, &f_shipping);
  float discount = 0;
  if (f_ht < 0 || f_tax < 0 || f_shipping < 0) {
    printf("-\n");
    putLog(argv[0], "003");
    goto end;
  } else {
    f_total = f_ht + f_tax + f_shipping - 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    0xe54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x90(%rbp),%rdi
call   1080 <getCookie@plt>
cmp    $0x0,%rax
je     11f3 <main+0x63>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13ae <main+0x21e>
movq   $0x0,-0x98(%rbp)
movq   $0x0,-0xa0(%rbp)
lea    0xe23(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     1244 <main+0xb4>
mov    -0x98(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0xa0(%rbp)
movl   $0x0,-0xa4(%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   1090 <getCart__HT@plt>
mov    %eax,-0xa4(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0xac(%rbp),%rsi
call   1050 <getCart__TAX@plt>
mov    %eax,-0xa4(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   10b0 <getCart__SHIPPING@plt>
mov    %eax,-0xa4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xb8(%rbp)
ff
xorps  %xmm0,%xmm0
ucomiss -0xa8(%rbp),%xmm0
ja     1300 <main+0x170>
xorps  %xmm0,%xmm0
ucomiss -0xac(%rbp),%xmm0
ja     1300 <main+0x170>
xorps  %xmm0,%xmm0
ucomiss -0xb0(%rbp),%xmm0
jbe    1326 <main+0x196>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd22(%rip),%rsi
call   1040 <putLog@plt>
jmp    13ae <main+0x21e>
movss  -0xa8(%rbp),%xmm0
ff
addss  -0xac(%rbp),%xmm0
ff
addss  -0xb0(%rbp),%xmm0
ff
subss  -0xb8(%rbp),%xmm0
ff
movss  %xmm0,-0xb4(%rbp)
ff
cmpq   $0x0,-0xa0(%rbp)
je     138f <main+0x1ff>
movss  0xc9c(%rip),%xmm0
mulss  -0xb4(%rbp),%xmm0
ff
movss  %xmm0,-0xb4(%rbp)
ff
cvttss2si -0xb4(%rbp),%esi
ff
lea    0xcbf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13a9 <main+0x219>
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xca3(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    13ae <main+0x21e>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rsi,%r15
lea    0xe65(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
call   1090 <getCookie@plt>
test   %rax,%rax
je     11ed <main+0x4d>
lea    0xe63(%rip),%rdi
call   1050 <puts@plt>
jmp    12d8 <main+0x138>
lea    0xe10(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1212 <main+0x72>
lea    0xe05(%rip),%rsi
mov    %rax,%rdi
call   10b0 <strstr@plt>
mov    %rax,%r14
jmp    1215 <main+0x75>
xor    %r14d,%r14d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <getCart__HT@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <getCart__TAX@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <getCart__SHIPPING@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
ja     12a9 <main+0x109>
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm2
ja     12a9 <main+0x109>
movss  0x4(%rsp),%xmm2
xorps  %xmm3,%xmm3
ucomiss %xmm2,%xmm3
ja     12a9 <main+0x109>
addss  %xmm1,%xmm0
addss  %xmm2,%xmm0
test   %r14,%r14
je     12c6 <main+0x126>
mulss  0xd6b(%rip),%xmm0
cvttss2si %xmm0,%esi
lea    0xd73(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12d8 <main+0x138>
lea    0xd96(%rip),%rdi
call   1050 <puts@plt>
mov    (%r15),%rdi
lea    0xd50(%rip),%rsi
call   1040 <putLog@plt>
jmp    12d8 <main+0x138>
cvtss2sd %xmm0,%xmm0
lea    0xd45(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
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"-\0A\00"
@.str.2 = [6 x i8] c"CENTS\00"
@.str.3 = [5 x i8] c"TRUE\00"
@.str.4 = [4 x i8] c"003\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 %73
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 i32 0, i32* %9
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
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%36 = call i32 @getCart__SHIPPING(i8* %35, float* %12)
store i32 %36, i32* %9
store float 0.000000e+00, float* %14
%37 = load float, float* %10
%38 = fcmp olt float %37, 0.000000e+00
br i1 %38, label %45, label %39
39: ; preds = %30
%40 = load float, float* %11
%41 = fcmp olt float %40, 0.000000e+00
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load float, float* %12
%44 = fcmp olt float %43, 0.000000e+00
br i1 %44, label %45, label %51
45: ; preds = %42, %39, %30
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @putLog(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %73
51: ; preds = %42
%52 = load float, float* %10
%53 = load float, float* %11
%54 = fadd float %52, %53
%55 = load float, float* %12
%56 = fadd float %54, %55
%57 = load float, float* %14
%58 = fsub float %56, %57
store float %58, float* %13
br label %59
59: ; preds = %51
%60 = load i8*, i8** %8
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %68
62: ; preds = %59
%63 = load float, float* %13
%64 = fmul float %63, 1.000000e+02
store float %64, float* %13
%65 = load float, float* %13
%66 = fptosi float %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %66)
br label %72
68: ; preds = %59
%69 = load float, float* %13
%70 = fpext float %69 to double
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %70)
br label %72
72: ; preds = %68, %62
br label %73
73: ; preds = %72, %45, %21
ret i32 0
}

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