#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*/ free(char *);
char *strdup(char const *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
char *strtok(char *, char const *);
char *extract_param(const char *input, const char *param_name,
                    const char *separators) {
  char *s = strdup(input);
  int parlen = strlen(param_name);
  strtok(s, separators);
  do {
    if (parlen == 0)
      return s;
    if ((strlen(s) > parlen + 2) && !strncmp(param_name, s, parlen) &&
        s[parlen] == '=') {
      return &s[parlen + 1];
    }
    s = strtok(NULL, separators);
  } while (s);
  free(s);
  return NULL;
}


x86 assembly (clang, -O0):
<extract_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strtok@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    11a1 <extract_param+0x51>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    122c <extract_param+0xdc>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jle    11ff <extract_param+0xaf>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11ff <extract_param+0xaf>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    11ff <extract_param+0xaf>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    122c <extract_param+0xdc>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118a <extract_param+0x3a>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_param>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r15
call   1070 <strdup@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strtok@plt>
lea    0x2(%r13),%r14d
movslq %r13d,%rbp
mov    %rbx,(%rsp)
jmp    11a2 <extract_param+0x52>
nopl   0x0(%rax)
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11db <extract_param+0x8b>
test   %r13d,%r13d
je     11d5 <extract_param+0x85>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    %r14d,%eax
jle    1190 <extract_param+0x40>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1190 <extract_param+0x40>
cmpb   $0x3d,(%rbx,%rbp,1)
jne    1190 <extract_param+0x40>
add    %rbp,%rbx
add    $0x1,%rbx
jmp    11e4 <extract_param+0x94>
mov    (%rsp),%rbx
jmp    11e4 <extract_param+0x94>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @extract_param(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %5
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %8
%12 = load i8*, i8** %6
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %9
%14 = load i8*, i8** %8
%15 = load i8*, i8** %7
%16 = call i8* @strtok(i8* %14, i8* %15)
br label %17
17: ; preds = %51, %3
%18 = load i32, i32* %9
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i8*, i8** %8
store i8* %21, i8** %4
br label %57
22: ; preds = %17
%23 = load i8*, i8** %8
%24 = call i32 @strlen(i8* %23)
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 2
%27 = icmp sgt i32 %24, %26
br i1 %27, label %28, label %48
28: ; preds = %22
%29 = load i8*, i8** %6
%30 = load i8*, i8** %8
%31 = load i32, i32* %9
%32 = call i32 @strncmp(i8* %29, i8* %30, i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %48, label %34
34: ; preds = %28
%35 = load i8*, i8** %8
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 61
br i1 %41, label %42, label %48
42: ; preds = %34
%43 = load i8*, i8** %8
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
store i8* %47, i8** %4
br label %57
48: ; preds = %34, %28, %22
%49 = load i8*, i8** %7
%50 = call i8* @strtok(i8* null, i8* %49)
store i8* %50, i8** %8
br label %51
51: ; preds = %48
%52 = load i8*, i8** %8
%53 = icmp ne i8* %52, null
br i1 %53, label %17, label %54
54: ; preds = %51
%55 = load i8*, i8** %8
%56 = call i32 @free(i8* %55)
store i8* null, i8** %4
br label %57
57: ; preds = %54, %42, %20
%58 = load i8*, i8** %4
ret i8* %58
}

LLVM IR (-O2):
define i8* @extract_param(i8* nocapture %0, i8* %1, i8* nocapture %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i8* @strtok(i8* %4, i8* %2)
%7 = icmp eq i32 %5, 0
%8 = add nsw i32 %5, 2
%9 = sext i32 %5 to i64
br label %10
10: ; preds = %26, %3
%11 = phi i8* [ %4, %3 ], [ %27, %26 ]
br i1 %7, label %31, label %12
12: ; preds = %10
%13 = tail call i32 @strlen(i8* %11)
%14 = icmp sgt i32 %13, %8
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = tail call i32 @strncmp(i8* %1, i8* %11, i32 %5)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %11, i64 %9
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 61
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = add nsw i32 %5, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %11, i64 %24
br label %31
26: ; preds = %18, %15, %12
%27 = tail call i8* @strtok(i8* null, i8* %2)
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %10
29: ; preds = %26
%30 = tail call i32 @free(i8* null)
br label %31
31: ; preds = %10, %29, %22
%32 = phi i8* [ null, %29 ], [ %25, %22 ], [ %4, %10 ]
ret i8* %32
}