#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 */
struct fio_option {
  int dummy;
};

/* Variables and functions */
struct fio_option *find_option(struct fio_option *, char const *);
int /*<<< orphan*/ handle_option(struct fio_option *, char const *, void *);
int /*<<< orphan*/ log_err(char *, char const *, ...);
int parse_cmd_option(const char *opt, const char *val,
                     struct fio_option *options, void *data) {
  struct fio_option *o;
  o = find_option(options, opt);
  if (!o) {
    log_err("Bad option <%s>\n", opt);
    return 1;
  }
  if (!handle_option(o, val, data))
    return 0;
  log_err("fio: failed parsing %s=%s\n", opt, val);
  return 1;
}


x86 assembly (clang, -O0):
<parse_cmd_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <find_option@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1182 <parse_cmd_option+0x52>
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1050 <log_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <parse_cmd_option+0x95>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <handle_option@plt>
cmp    $0x0,%eax
jne    11a8 <parse_cmd_option+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <parse_cmd_option+0x95>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <log_err@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cmd_option>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rdi
mov    %rbx,%rsi
call   1030 <find_option@plt>
test   %rax,%rax
je     1176 <parse_cmd_option+0x46>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <handle_option@plt>
test   %eax,%eax
je     118e <parse_cmd_option+0x5e>
lea    0xeaa(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <log_err@plt>
jmp    1187 <parse_cmd_option+0x57>
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <log_err@plt>
mov    $0x1,%eax
jmp    1190 <parse_cmd_option+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.fio_option = type { i32 }
@.str = [17 x i8] c"Bad option <%s>\0A\00"
@.str.1 = [27 x i8] c"fio: failed parsing %s=%s\0A\00"
define i32 @parse_cmd_option(i8* %0, i8* %1, %struct.fio_option* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.fio_option*
%9 = alloca i8*
%10 = alloca %struct.fio_option*
store i8* %0, i8** %6
store i8* %1, i8** %7
store %struct.fio_option* %2, %struct.fio_option** %8
store i8* %3, i8** %9
%11 = load %struct.fio_option*, %struct.fio_option** %8
%12 = load i8*, i8** %6
%13 = call %struct.fio_option* @find_option(%struct.fio_option* %11, i8* %12)
store %struct.fio_option* %13, %struct.fio_option** %10
%14 = load %struct.fio_option*, %struct.fio_option** %10
%15 = icmp ne %struct.fio_option* %14, null
br i1 %15, label %19, label %16
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = call i32 (i8*, i8*, ...) @log_err(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %5
br label %30
19: ; preds = %4
%20 = load %struct.fio_option*, %struct.fio_option** %10
%21 = load i8*, i8** %7
%22 = load i8*, i8** %9
%23 = call i32 @handle_option(%struct.fio_option* %20, i8* %21, i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %19
store i32 0, i32* %5
br label %30
26: ; preds = %19
%27 = load i8*, i8** %6
%28 = load i8*, i8** %7
%29 = call i32 (i8*, i8*, ...) @log_err(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28)
store i32 1, i32* %5
br label %30
30: ; preds = %26, %25, %16
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
%struct.fio_option = type { i32 }
@.str = [17 x i8] c"Bad option <%s>\0A\00"
@.str.1 = [27 x i8] c"fio: failed parsing %s=%s\0A\00"
define i32 @parse_cmd_option(i8* %0, i8* %1, %struct.fio_option* %2, i8* %3) {
%5 = tail call %struct.fio_option* @find_option(%struct.fio_option* %2, i8* %0)
%6 = icmp eq %struct.fio_option* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (i8*, i8*, ...) @log_err(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %14
9: ; preds = %4
%10 = tail call i32 @handle_option(%struct.fio_option* %5, i8* %1, i8* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, i8*, ...) @log_err(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %14
14: ; preds = %9, %12, %7
%15 = phi i32 [ 1, %12 ], [ 1, %7 ], [ 0, %9 ]
ret i32 %15
}