#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 */
scalar_t__ strcmp(char *, char *);
char *http_arg_val(char **args, char *key) {
  char *val = NULL;
  if (!args)
    return (NULL);
  if (!key)
    return (NULL);
  while (*args) {
    if (strcmp(key, *args) == 0)
      return (*(args + 1));
    args += 2;
  }
  return (val);
}


x86 assembly (clang, -O0):
<http_arg_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1140 <http_arg_val+0x30>
movq   $0x0,-0x8(%rbp)
jmp    11af <http_arg_val+0x9f>
cmpq   $0x0,-0x18(%rbp)
jne    1158 <http_arg_val+0x48>
movq   $0x0,-0x8(%rbp)
jmp    11af <http_arg_val+0x9f>
jmp    115d <http_arg_val+0x4d>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a7 <http_arg_val+0x97>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1196 <http_arg_val+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11af <http_arg_val+0x9f>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    115d <http_arg_val+0x4d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_arg_val>:
push   %r15
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     1164 <http_arg_val+0x54>
mov    %rsi,%r15
test   %rsi,%rsi
je     1164 <http_arg_val+0x54>
mov    %rdi,%rbx
mov    (%rdi),%rsi
test   %rsi,%rsi
je     115b <http_arg_val+0x4b>
add    $0x10,%rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1160 <http_arg_val+0x50>
mov    (%rbx),%rsi
add    $0x10,%rbx
test   %rsi,%rsi
jne    1140 <http_arg_val+0x30>
jmp    1164 <http_arg_val+0x54>
xor    %r14d,%r14d
jmp    1164 <http_arg_val+0x54>
mov    -0x8(%rbx),%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @http_arg_val(i8** %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%7 = load i8**, i8*** %4
%8 = icmp ne i8** %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i8* null, i8** %3
br label %34
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10
store i8* null, i8** %3
br label %34
14: ; preds = %10
br label %15
15: ; preds = %29, %14
%16 = load i8**, i8*** %4
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8**, i8*** %4
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %20, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %3
br label %34
29: ; preds = %19
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 2
store i8** %31, i8*** %4
br label %15
32: ; preds = %15
%33 = load i8*, i8** %6
store i8* %33, i8** %3
br label %34
34: ; preds = %32, %25, %13, %9
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
define i8* @http_arg_val(i8** %0, i8* %1) {
%3 = icmp eq i8** %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %21, label %6
6: ; preds = %2
%7 = load i8*, i8** %0
%8 = icmp eq i8* %7, null
br i1 %8, label %21, label %9
9: ; preds = %6, %17
%10 = phi i8* [ %19, %17 ], [ %7, %6 ]
%11 = phi i8** [ %18, %17 ], [ %0, %6 ]
%12 = tail call i64 @strcmp(i8* %1, i8* %10)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %11, i64 1
%16 = load i8*, i8** %15
br label %21
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %11, i64 2
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %9
21: ; preds = %17, %6, %2, %14
%22 = phi i8* [ %16, %14 ], [ null, %2 ], [ null, %6 ], [ null, %17 ]
ret i8* %22
}