#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*/ strcmp(char *, char *);
int getRequestMethod() {
  char *request_method;
  int form_method;
  request_method = getenv("REQUEST_METHOD");
  if (request_method == NULL)
    return -1;
  if (!strcmp(request_method, "GET") || !strcmp(request_method, "HEAD")) {
    form_method = 0;
  } else if (!strcmp(request_method, "POST")) {
    form_method = 1;
  } else {
    return -1;
  }
  return form_method;
}


x86 assembly (clang, -O0):
<getRequestMethod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114f <getRequestMethod+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <getRequestMethod+0xa9>
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1181 <getRequestMethod+0x61>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118d <getRequestMethod+0x6d>
movl   $0x0,-0x14(%rbp)
jmp    11c3 <getRequestMethod+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b2 <getRequestMethod+0x92>
movl   $0x1,-0x14(%rbp)
jmp    11be <getRequestMethod+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <getRequestMethod+0xa9>
jmp    11c3 <getRequestMethod+0xa3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRequestMethod>:
push   %rbp
push   %r14
push   %rbx
lea    0xed5(%rip),%rdi
call   1030 <getenv@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1182 <getRequestMethod+0x62>
mov    %rax,%rbx
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     117f <getRequestMethod+0x5f>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     117f <getRequestMethod+0x5f>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1182 <getRequestMethod+0x62>
mov    $0x1,%r14d
mov    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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