#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ free(char *);
struct fio_option *get_option(char *, struct fio_option *, char **);
int /*<<< orphan*/ handle_option(struct fio_option *, char *, void *);
char *option_dup_subs(char const *);
int /*<<< orphan*/ stderr;
int parse_option(const char *opt, struct fio_option *options, void *data) {
  struct fio_option *o;
  char *post, *tmp;
  tmp = option_dup_subs(opt);
  o = get_option(tmp, options, &post);
  if (!o) {
    fprintf(stderr, "Bad option <%s>\n", tmp);
    free(tmp);
    return 1;
  }
  if (!handle_option(o, post, data)) {
    free(tmp);
    return 0;
  }
  fprintf(stderr, "fio: failed parsing %s\n", opt);
  free(tmp);
  return 1;
}


x86 assembly (clang, -O0):
<parse_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <option_dup_subs@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <get_option@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11bf <parse_option+0x6f>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xe5b(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1217 <parse_option+0xc7>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <handle_option@plt>
cmp    $0x0,%eax
jne    11ee <parse_option+0x9e>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1217 <parse_option+0xc7>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe0f(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%r14
call   1050 <option_dup_subs@plt>
mov    %rax,%rbx
mov    %rsp,%rdx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1070 <get_option@plt>
test   %rax,%rax
je     11a3 <parse_option+0x53>
mov    (%rsp),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1040 <handle_option@plt>
test   %eax,%eax
je     11c2 <parse_option+0x72>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
mov    %r14,%rdx
jmp    11b6 <parse_option+0x66>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%ebp
jmp    11c4 <parse_option+0x74>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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 = [24 x i8] c"fio: failed parsing %s\0A\00"
define i32 @parse_option(i8* %0, %struct.fio_option* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.fio_option*
%7 = alloca i8*
%8 = alloca %struct.fio_option*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store %struct.fio_option* %1, %struct.fio_option** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %5
%12 = call i8* @option_dup_subs(i8* %11)
store i8* %12, i8** %10
%13 = load i8*, i8** %10
%14 = load %struct.fio_option*, %struct.fio_option** %6
%15 = call %struct.fio_option* @get_option(i8* %13, %struct.fio_option* %14, i8** %9)
store %struct.fio_option* %15, %struct.fio_option** %8
%16 = load %struct.fio_option*, %struct.fio_option** %8
%17 = icmp ne %struct.fio_option* %16, null
br i1 %17, label %24, label %18
18: ; preds = %3
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %10
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %10
%23 = call i32 @free(i8* %22)
store i32 1, i32* %4
br label %39
24: ; preds = %3
%25 = load %struct.fio_option*, %struct.fio_option** %8
%26 = load i8*, i8** %9
%27 = load i8*, i8** %7
%28 = call i32 @handle_option(%struct.fio_option* %25, i8* %26, i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i8*, i8** %10
%32 = call i32 @free(i8* %31)
store i32 0, i32* %4
br label %39
33: ; preds = %24
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %5
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %10
%38 = call i32 @free(i8* %37)
store i32 1, i32* %4
br label %39
39: ; preds = %33, %30, %18
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
%struct.fio_option = type { i32 }
@stderr = global i32 0
@.str = [17 x i8] c"Bad option <%s>\0A\00"
@.str.1 = [24 x i8] c"fio: failed parsing %s\0A\00"
define i32 @parse_option(i8* %0, %struct.fio_option* %1, i8* %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = tail call i8* @option_dup_subs(i8* %0)
%7 = call %struct.fio_option* @get_option(i8* %6, %struct.fio_option* %1, i8** %4)
%8 = icmp eq %struct.fio_option* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %19
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = call i32 @handle_option(%struct.fio_option* %7, i8* %13, i8* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %12, %16, %9
%20 = phi i32 [ 1, %16 ], [ 1, %9 ], [ 0, %12 ]
%21 = call i32 @free(i8* %6)
ret i32 %20
}