#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 *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  char *method = getenv("REQUEST_METHOD");
  char *data;
  printf("Content-type: text/plain\n\n");
  if (method && strcmp(method, "GET") == 0) {
    data = getenv("QUERY_STRING");
    printf("%s\n", data);
  } else if (method && strcmp(method, "POST") == 0) {
    ;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11a9 <main+0x79>
mov    -0x10(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a9 <main+0x79>
lea    0xea5(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d8 <main+0xa8>
cmpq   $0x0,-0x10(%rbp)
je     11d3 <main+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d3 <main+0xa3>
jmp    11d3 <main+0xa3>
jmp    11d8 <main+0xa8>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xede(%rip),%rdi
call   1040 <puts@plt>
test   %rbx,%rbx
je     118a <main+0x5a>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1176 <main+0x46>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
jmp    118a <main+0x5a>
lea    0xe96(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"REQUEST_METHOD\00"
@.str.1 = [27 x i8] c"Content-type: text/plain\0A\0A\00"
@.str.2 = [4 x i8] c"GET\00"
@.str.3 = [13 x i8] c"QUERY_STRING\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [5 x i8] c"POST\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %14)
br label %25
16: ; preds = %8, %0
%17 = load i8*, i8** %2
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8*, i8** %2
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
br label %24
24: ; preds = %23, %19, %16
br label %25
25: ; preds = %24, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"REQUEST_METHOD\00"
@.str.2 = [4 x i8] c"GET\00"
@.str.3 = [13 x i8] c"QUERY_STRING\00"
@.str.5 = [5 x i8] c"POST\00"
@str = [26 x i8] c"Content-type: text/plain\0A\00"
define i32 @main() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%3 = icmp eq i8* %1, null
br i1 %3, label %12, label %4
4: ; preds = %0
%5 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
br label %12
10: ; preds = %4
%11 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %12
12: ; preds = %0, %10, %7
ret i32 0
}