#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 /*<<< orphan*/ strncmp(char *, char *, int);
char *whichreq(char *buf) {
  if (!strncmp(&buf[0], "GET", 3) || !strncmp(&buf[0], "get", 3)) {
    return "get";
  }
  if (!strncmp(&buf[0], "HEAD", 4) || !strncmp(&buf[0], "head", 4)) {
    return "head";
  }
  return "other";
}


x86 assembly (clang, -O0):
<whichreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1158 <whichreq+0x48>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1168 <whichreq+0x58>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bf <whichreq+0xaf>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11a4 <whichreq+0x94>
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11b4 <whichreq+0xa4>
lea    0xe62(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bf <whichreq+0xaf>
lea    0xe57(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whichreq>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xee1(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
lea    0xed4(%rip),%rbx
test   %eax,%eax
je     118d <whichreq+0x7d>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     118d <whichreq+0x7d>
lea    0xeb9(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1186 <whichreq+0x76>
lea    0xea6(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
lea    0xe92(%rip),%rbx
cmove  %r15,%rbx
jmp    118d <whichreq+0x7d>
lea    0xe80(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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