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


x86 assembly (clang, -O0):
<parse_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116d <parse_param+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    11cb <parse_param+0x9b>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <trim_one_space@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11a5 <parse_param+0x75>
movl   $0x0,-0x4(%rbp)
jmp    11cb <parse_param+0x9b>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1050 <trim_one_space@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   *%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_param>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
mov    $0x3d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117b <parse_param+0x5b>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1040 <trim_one_space@plt>
cmpb   $0x0,(%r15)
je     1182 <parse_param+0x62>
mov    %rax,%r12
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <trim_one_space@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    *%rax
mov    $0x1,%eax
jmp    1184 <parse_param+0x64>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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