#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*/ rfx_free(char *);
int /*<<< orphan*/ strcmp(char *, char *);
char *strdup(char *);
scalar_t__ strlen(char *);
char *swf_postread();
int /*<<< orphan*/ swf_scanquery(char *);
void swf_uncgi() {
  char *query, *dupquery, *method;
  query = getenv("QUERY_STRING");
  if ((query) && strlen(query)) {
    dupquery = strdup(query);
    swf_scanquery(dupquery);
    rfx_free(dupquery);
  }
  method = getenv("REQUEST_METHOD");
  if ((method) && !strcmp(method, "POST")) {
    query = swf_postread();
    if ((query) && (query[0] != 0))
      swf_scanquery(query);
    rfx_free(query);
  }
}


x86 assembly (clang, -O0):
<swf_uncgi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c5 <swf_uncgi+0x55>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     11c5 <swf_uncgi+0x55>
mov    -0x8(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <swf_scanquery@plt>
mov    -0x10(%rbp),%rdi
call   1050 <rfx_free@plt>
lea    0xe41(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1231 <swf_uncgi+0xc1>
mov    -0x18(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1231 <swf_uncgi+0xc1>
mov    $0x0,%al
call   1080 <swf_postread@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1228 <swf_uncgi+0xb8>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1228 <swf_uncgi+0xb8>
mov    -0x8(%rbp),%rdi
call   1070 <swf_scanquery@plt>
mov    -0x8(%rbp),%rdi
call   1050 <rfx_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swf_uncgi>:
push   %rbx
lea    0xe98(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1192 <swf_uncgi+0x32>
cmpb   $0x0,(%rax)
je     1192 <swf_uncgi+0x32>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <swf_scanquery@plt>
mov    %rbx,%rdi
call   1040 <rfx_free@plt>
lea    0xe74(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b6 <swf_uncgi+0x56>
lea    0xe72(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11b8 <swf_uncgi+0x58>
pop    %rbx
ret
xor    %eax,%eax
call   1070 <swf_postread@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d4 <swf_uncgi+0x74>
cmpb   $0x0,(%rbx)
je     11d4 <swf_uncgi+0x74>
mov    %rbx,%rdi
call   1060 <swf_scanquery@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <rfx_free@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [15 x i8] c"REQUEST_METHOD\00"
@.str.2 = [5 x i8] c"POST\00"
define void @swf_uncgi() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %18
7: ; preds = %0
%8 = load i8*, i8** %1
%9 = call i64 @strlen(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i8*, i8** %1
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = call i32 @swf_scanquery(i8* %14)
%16 = load i8*, i8** %2
%17 = call i32 @rfx_free(i8* %16)
br label %18
18: ; preds = %11, %7, %0
%19 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %3
%20 = load i8*, i8** %3
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %22
%27 = call i8* (...) @swf_postread()
store i8* %27, i8** %1
%28 = load i8*, i8** %1
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i8*, i8** %1
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i8*, i8** %1
%38 = call i32 @swf_scanquery(i8* %37)
br label %39
39: ; preds = %36, %30, %26
%40 = load i8*, i8** %1
%41 = call i32 @rfx_free(i8* %40)
br label %42
42: ; preds = %39, %22, %18
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [15 x i8] c"REQUEST_METHOD\00"
@.str.2 = [5 x i8] c"POST\00"
define void @swf_uncgi() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i8* @strdup(i8* %1)
%8 = tail call i32 @swf_scanquery(i8* %7)
%9 = tail call i32 @rfx_free(i8* %7)
br label %10
10: ; preds = %6, %3, %0
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = tail call i8* (...) @swf_postread()
%18 = icmp eq i8* %17, null
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = load i8, i8* %17
%21 = icmp eq i8 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @swf_scanquery(i8* %17)
br label %24
24: ; preds = %22, %19, %16
%25 = tail call i32 @rfx_free(i8* %17)
br label %26
26: ; preds = %24, %13, %10
ret void
}