#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 *strchr(char *, char);
size_t strlen(char *);
void *trim_one_space(char *);
bool parse_param(char *buf, bool allow_empty_value,
                 bool (*pfunc)(const char *name, const char *value,
                               void *private_data),
                 void *private_data) {
  char *equals;
  char *name;
  const char *value;
  size_t len;
  bool no_value = false;
  equals = strchr(buf, '=');
  if (equals != NULL) {
    *equals = '\0';
  } else {
    if (allow_empty_value) {
      no_value = true;
    } else {
      return true;
    }
  }
  name = trim_one_space(buf);
  len = strlen(buf);
  if (len == 0) {
    return false;
  }
  if (no_value) {
    value = "";
  } else {
    value = trim_one_space(equals + 1);
  }
  return pfunc(name, value, private_data);
}


x86 assembly (clang, -O0):
<parse_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1177 <parse_param+0x47>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
jmp    119e <parse_param+0x6e>
cmpl   $0x0,-0x14(%rbp)
je     118d <parse_param+0x5d>
movl   $0x1,-0x4c(%rbp)
jmp    1199 <parse_param+0x69>
movl   $0x1,-0x4(%rbp)
jmp    120f <parse_param+0xdf>
jmp    119e <parse_param+0x6e>
mov    -0x10(%rbp),%rdi
call   1050 <trim_one_space@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11cf <parse_param+0x9f>
movl   $0x0,-0x4(%rbp)
jmp    120f <parse_param+0xdf>
cmpl   $0x0,-0x4c(%rbp)
je     11e9 <parse_param+0xb9>
lea    0xe20(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11fa <parse_param+0xca>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1050 <trim_one_space@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   *%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_param>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r13
mov    %esi,%ebp
mov    %rdi,%r12
mov    $0x3d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116e <parse_param+0x4e>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r12,%rdi
call   1040 <trim_one_space@plt>
cmpb   $0x0,(%r12)
je     11a4 <parse_param+0x84>
mov    %rax,%r15
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <trim_one_space@plt>
mov    %rax,%rsi
jmp    118b <parse_param+0x6b>
test   %ebp,%ebp
je     11a8 <parse_param+0x88>
mov    %r12,%rdi
call   1040 <trim_one_space@plt>
cmpb   $0x0,(%r12)
je     11a4 <parse_param+0x84>
mov    %rax,%r15
lea    0xe75(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    *%rax
xor    %eax,%eax
jmp    11ad <parse_param+0x8d>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @parse_param(i8* %0, i32 %1, i32 (i8*, i8*, i8*)* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32 (i8*, i8*, i8*)*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 (i8*, i8*, i8*)* %2, i32 (i8*, i8*, i8*)** %8
store i8* %3, i8** %9
store i32 0, i32* %14
%15 = load i8*, i8** %6
%16 = call i8* @strchr(i8* %15, i8 signext 61)
store i8* %16, i8** %10
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i8*, i8** %10
store i8 0, i8* %20
br label %27
21: ; preds = %4
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %14
br label %26
25: ; preds = %21
store i32 1, i32* %5
br label %49
26: ; preds = %24
br label %27
27: ; preds = %26, %19
%28 = load i8*, i8** %6
%29 = call i8* @trim_one_space(i8* %28)
store i8* %29, i8** %11
%30 = load i8*, i8** %6
%31 = call i64 @strlen(i8* %30)
store i64 %31, i64* %13
%32 = load i64, i64* %13
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %27
store i32 0, i32* %5
br label %49
35: ; preds = %27
%36 = load i32, i32* %14
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %12
br label %43
39: ; preds = %35
%40 = load i8*, i8** %10
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i8* @trim_one_space(i8* %41)
store i8* %42, i8** %12
br label %43
43: ; preds = %39, %38
%44 = load i32 (i8*, i8*, i8*)*, i32 (i8*, i8*, i8*)** %8
%45 = load i8*, i8** %11
%46 = load i8*, i8** %12
%47 = load i8*, i8** %9
%48 = call i32 %44(i8* %45, i8* %46, i8* %47)
store i32 %48, i32* %5
br label %49
49: ; preds = %43, %34, %25
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @parse_param(i8* %0, i32 %1, i32 (i8*, i8*, i8*)* nocapture %2, i8* %3) {
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = icmp eq i32 %1, 0
br i1 %8, label %24, label %9
9: ; preds = %7
%10 = tail call i8* @trim_one_space(i8* %0)
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %24, label %20
13: ; preds = %4
store i8 0, i8* %5
%14 = tail call i8* @trim_one_space(i8* %0)
%15 = load i8, i8* %0
%16 = icmp eq i8 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %5, i64 1
%19 = tail call i8* @trim_one_space(i8* %18)
br label %20
20: ; preds = %9, %17
%21 = phi i8* [ %14, %17 ], [ %10, %9 ]
%22 = phi i8* [ %19, %17 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %9 ]
%23 = tail call i32 %2(i8* %21, i8* %22, i8* %3)
br label %24
24: ; preds = %13, %9, %7, %20
%25 = phi i32 [ %23, %20 ], [ 1, %7 ], [ 0, %9 ], [ 0, %13 ]
ret i32 %25
}