#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*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ handle_option(struct fio_option *, char const *, void *);
int /*<<< orphan*/ stderr;
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) {
    fprintf(stderr, "Bad option <%s>\n", opt);
    return 1;
  }
  if (!handle_option(o, val, data))
    return 0;
  fprintf(stderr, "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    118b <parse_cmd_option+0x5b>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <parse_cmd_option+0xa7>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <handle_option@plt>
cmp    $0x0,%eax
jne    11b1 <parse_cmd_option+0x81>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <parse_cmd_option+0xa7>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@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     117f <parse_cmd_option+0x4f>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <handle_option@plt>
test   %eax,%eax
je     11a0 <parse_cmd_option+0x70>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1199 <parse_cmd_option+0x69>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11a2 <parse_cmd_option+0x72>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.fio_option = type { i32 }
@stderr = global i32 0
@.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 %20, label %16
16: ; preds = %4
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %6
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %5
br label %32
20: ; preds = %4
%21 = load %struct.fio_option*, %struct.fio_option** %10
%22 = load i8*, i8** %7
%23 = load i8*, i8** %9
%24 = call i32 @handle_option(%struct.fio_option* %21, i8* %22, i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %20
store i32 0, i32* %5
br label %32
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %6
%30 = load i8*, i8** %7
%31 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
store i32 1, i32* %5
br label %32
32: ; preds = %27, %26, %16
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
%struct.fio_option = type { i32 }
@stderr = global i32 0
@.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 %10
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
10: ; preds = %4
%11 = tail call i32 @handle_option(%struct.fio_option* %5, i8* %1, i8* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %16
16: ; preds = %10, %13, %7
%17 = phi i32 [ 1, %13 ], [ 1, %7 ], [ 0, %10 ]
ret i32 %17
}