#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 base64_decode(char *, char *, char *);
int curl(char *);
scalar_t__ getCookie(char *);
char *getenv(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int setCart__TOTALS(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
int main(void) {
  char cookie[128];
  memset(cookie, 0, 128);
  if (getCookie(cookie))
    return 0;
  char item[64];
  char *data = NULL;
  int len;
  data = getenv("QUERY_STRING");
  if (!data)
    return 0;
  len = strlen(data);
  if (len > 64)
    len = 64;
  memset(item, 0, 64);
  memcpy(item, data, len);
  char szDest[64];
  memset(szDest, 0, 64);
  int ret;
  ret = base64_decode(item, szDest, cookie);
  if (ret)
    return 0;
  char url[512];
  memset(url, 0, 512);
  sprintf(url, "http://rest:9000/delItem?cookie=%s&parameter=%s", cookie,
          szDest);
  int res;
  res = curl(url);
  res = setCart__TOTALS(cookie);
end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
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     11d7 <main+0x47>
movl   $0x0,-0x4(%rbp)
jmp    130f <main+0x17f>
movq   $0x0,-0xd8(%rbp)
lea    0xe17(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0xd8(%rbp)
cmpq   $0x0,-0xd8(%rbp)
jne    120f <main+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    130f <main+0x17f>
mov    -0xd8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xdc(%rbp)
cmpl   $0x40,-0xdc(%rbp)
jle    1238 <main+0xa8>
movl   $0x40,-0xdc(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
mov    -0xdc(%rbp),%edx
call   1090 <memcpy@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   10b0 <base64_decode@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
je     12b0 <main+0x120>
movl   $0x0,-0x4(%rbp)
jmp    130f <main+0x17f>
lea    -0x330(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x330(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xd2e(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x330(%rbp),%rdi
call   1080 <curl@plt>
mov    %eax,-0x334(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <setCart__TOTALS@plt>
mov    %eax,-0x334(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x300,%rsp
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
call   1070 <getCookie@plt>
test   %rax,%rax
je     11ca <main+0x3a>
xor    %eax,%eax
add    $0x300,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe2f(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11bc <main+0x2c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
cmp    $0x40,%eax
mov    $0x40,%eax
cmovge %eax,%ebp
lea    0xc0(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1090 <memcpy@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    0x40(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <base64_decode@plt>
test   %eax,%eax
jne    11bc <main+0x2c>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    0xdae(%rip),%rsi
lea    0x40(%rsp),%rbp
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1080 <curl@plt>
mov    %rbp,%rdi
call   1040 <setCart__TOTALS@plt>
jmp    11bc <main+0x2c>

LLVM IR (-O0):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [48 x i8] c"http://rest:9000/delItem?cookie=%s&parameter=%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca [64 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [64 x i8]
%7 = alloca i32
%8 = alloca [512 x i8]
%9 = alloca i32
store i32 0, i32* %1
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 128)
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%13 = call i64 @getCookie(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 0, i32* %1
br label %55
16: ; preds = %0
store i8* null, i8** %4
%17 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %16
store i32 0, i32* %1
br label %55
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 64
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 64, i32* %5
br label %27
27: ; preds = %26, %21
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%29 = call i32 @memset(i8* %28, i32 0, i32 64)
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%31 = load i8*, i8** %4
%32 = load i32, i32* %5
%33 = call i32 @memcpy(i8* %30, i8* %31, i32 %32)
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%35 = call i32 @memset(i8* %34, i32 0, i32 64)
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%39 = call i32 @base64_decode(i8* %36, i8* %37, i8* %38)
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %27
store i32 0, i32* %1
br label %55
43: ; preds = %27
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%45 = call i32 @memset(i8* %44, i32 0, i32 512)
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%49 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %47, i8* %48)
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%51 = call i32 @curl(i8* %50)
store i32 %51, i32* %9
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%53 = call i32 @setCart__TOTALS(i8* %52)
store i32 %53, i32* %9
br label %54
54: ; preds = %43
store i32 0, i32* %1
br label %55
55: ; preds = %54, %42, %20, %15
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [48 x i8] c"http://rest:9000/delItem?cookie=%s&parameter=%s\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 128)
%7 = call i64 @getCookie(i8* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %0
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%11 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %30, label %13
13: ; preds = %9
%14 = call i32 @strlen(i8* %11)
%15 = icmp slt i32 %14, 64
%16 = select i1 %15, i32 %14, i32 64
%17 = call i32 @memset(i8* %10, i32 0, i32 64)
%18 = call i32 @memcpy(i8* %10, i8* %11, i32 %16)
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 0, i32 64)
%21 = call i32 @base64_decode(i8* %10, i8* %19, i8* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %13
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 512)
%26 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %19)
%27 = call i32 @curl(i8* %24)
%28 = call i32 @setCart__TOTALS(i8* %5)
br label %29
29: ; preds = %13, %23
br label %30
30: ; preds = %9, %29
br label %31
31: ; preds = %0, %30
ret i32 0
}