#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 strlen(char const *);
char const *strstr(char const *, char const *);
const char *get_str_arg(const char *arg, const char *name) {
  if (strstr(arg, name) == arg) {
    int l = strlen(name);
    if (arg[l] == '=') {
      return arg + l + 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_str_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1185 <get_str_arg+0x65>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1180 <get_str_arg+0x60>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    118d <get_str_arg+0x6d>
jmp    1185 <get_str_arg+0x65>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_str_arg>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    115e <get_str_arg+0x3e>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x3d,(%r14,%rax,1)
jne    115e <get_str_arg+0x3e>
add    %r14,%rax
add    $0x1,%rax
jmp    1160 <get_str_arg+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @get_str_arg(i8* %0, i8* %1) {
%3 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %1)
%4 = tail call i32 @strncmp(i8* %0, i8* %1, i64 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %1)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 61
%12 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %11, label %14, label %13
13: ; preds = %6, %2
br label %14
14: ; preds = %6, %13
%15 = phi i8* [ %12, %6 ], [ null, %13 ]
ret i8* %15
}