#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 atoi(char *);
char *getenv(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
char *strstr(char *, char *);
int main(void) {
  char *cookie_env = NULL, *cookie_ptr = NULL;
  cookie_env = getenv("HTTP_COOKIE");
  if (cookie_env) {
    cookie_ptr = strstr(cookie_env, "MWS_CARD_SIZE=");
    if (!cookie_ptr)
      goto end;
    int value = 0;
    char *ptr_value = NULL;
    ptr_value = getenv("NUMBER");
    if (!ptr_value)
      goto end;
    value = atoi(ptr_value);
    int valueCookie = 0;
    char szTemp[2];
    memset(szTemp, 0, 2);
    memcpy(szTemp, cookie_ptr + 14, 1);
    valueCookie = atoi(szTemp);
    if (value == valueCookie) {
      printf("Content-Type: text/plain;charset=us-ascii\n\n");
      printf("selected='selected'");
      return 0;
    }
  end:
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe7a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1273 <main+0x113>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11be <main+0x5e>
jmp    1267 <main+0x107>
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe47(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ed <main+0x8d>
jmp    1267 <main+0x107>
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x2e(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
lea    -0x2e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xe,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    -0x2e(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1262 <main+0x102>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <main+0x11a>
jmp    1267 <main+0x107>
movl   $0x0,-0x4(%rbp)
jmp    127a <main+0x11a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     120d <main+0x9d>
lea    0xe78(%rip),%rsi
mov    %rax,%rdi
call   1090 <strstr@plt>
test   %rax,%rax
je     120d <main+0x9d>
mov    %rax,%rbx
lea    0xe70(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     120d <main+0x9d>
mov    %rax,%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
lea    0xe(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1060 <memset@plt>
add    $0xe,%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <memcpy@plt>
mov    %rbp,%rdi
call   1080 <atoi@plt>
cmp    %eax,%r14d
jne    120d <main+0x9d>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"HTTP_COOKIE\00"
@.str.1 = [15 x i8] c"MWS_CARD_SIZE=\00"
@.str.2 = [7 x i8] c"NUMBER\00"
@.str.3 = [44 x i8] c"Content-Type: text/plain;charset=us-ascii\0A\0A\00"
@.str.4 = [20 x i8] c"selected='selected'\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [2 x i8]
store i32 0, i32* %1
store i8* null, i8** %2
store i8* null, i8** %3
%8 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %41
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %11
br label %40
17: ; preds = %11
store i32 0, i32* %4
store i8* null, i8** %5
%18 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %17
br label %40
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %4
store i32 0, i32* %6
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%26 = call i32 @memset(i8* %25, i32 0, i32 2)
%27 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 14
%30 = call i32 @memcpy(i8* %27, i8* %29, i32 1)
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %6
%33 = load i32, i32* %4
%34 = load i32, i32* %6
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %22
%37 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %42
39: ; preds = %22
br label %40
40: ; preds = %39, %21, %16
store i32 0, i32* %1
br label %42
41: ; preds = %0
store i32 0, i32* %1
br label %42
42: ; preds = %41, %40, %36
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [12 x i8] c"HTTP_COOKIE\00"
@.str.1 = [15 x i8] c"MWS_CARD_SIZE=\00"
@.str.2 = [7 x i8] c"NUMBER\00"
@.str.4 = [20 x i8] c"selected='selected'\00"
@str = [43 x i8] c"Content-Type: text/plain;charset=us-ascii\0A\00"
define i32 @main() {
%1 = alloca [2 x i8]
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %21, label %4
4: ; preds = %0
%5 = tail call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %21, label %7
7: ; preds = %4
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %21, label %10
10: ; preds = %7
%11 = tail call i32 @atoi(i8* %8)
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 2)
%14 = getelementptr inbounds i8, i8* %5, i64 14
%15 = call i32 @memcpy(i8* %12, i8* %14, i32 1)
%16 = call i32 @atoi(i8* %12)
%17 = icmp eq i32 %11, %16
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %0, %4, %7, %10, %18
ret i32 0
}