#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 *get_option(char *, struct fio_option *, char **);
int /*<<< orphan*/ handle_option(struct fio_option *, char *, void *);
int /*<<< orphan*/ log_err(char *, char const *);
int /*<<< orphan*/ memmove(char *, char *, int);
int strlen(char *);
int parse_option(char *opt, const char *input, struct fio_option *options,
                 struct fio_option **o, void *data) {
  char *post;
  if (!opt) {
    log_err("fio: failed parsing %s\n", input);
    *o = NULL;
    return 1;
  }
  *o = get_option(opt, options, &post);
  if (!*o) {
    if (post) {
      int len = strlen(opt);
      if (opt + len + 1 != post)
        memmove(opt + len + 1, post, strlen(post));
      opt[len] = '=';
    }
    return 1;
  }
  if (!handle_option(*o, post, data)) {
    return 0;
  }
  log_err("fio: failed parsing %s\n", input);
  return 1;
}


x86 assembly (clang, -O0):
<parse_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119e <parse_option+0x4e>
mov    -0x18(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1070 <log_err@plt>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1282 <parse_option+0x132>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <get_option@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1242 <parse_option+0xf2>
cmpq   $0x0,-0x38(%rbp)
je     1236 <parse_option+0xe6>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
cmp    -0x38(%rbp),%rax
je     122a <parse_option+0xda>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movb   $0x3d,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
jmp    1282 <parse_option+0x132>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <handle_option@plt>
cmp    $0x0,%eax
jne    126b <parse_option+0x11b>
movl   $0x0,-0x4(%rbp)
jmp    1282 <parse_option+0x132>
mov    -0x18(%rbp),%rsi
lea    0xd8a(%rip),%rdi
call   1070 <log_err@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbp
mov    %rsi,%r14
test   %rdi,%rdi
je     11a3 <parse_option+0x53>
mov    %r8,%r15
mov    %rdi,%rbx
mov    %rsp,%rax
mov    %rdx,%rsi
mov    %rax,%rdx
call   1060 <get_option@plt>
mov    %rax,0x0(%rbp)
mov    (%rsp),%rsi
test   %rax,%rax
je     11cc <parse_option+0x7c>
mov    %rax,%rdi
mov    %r15,%rdx
call   1030 <handle_option@plt>
test   %eax,%eax
je     1210 <parse_option+0xc0>
lea    0xe67(%rip),%rdi
mov    %r14,%rsi
call   1070 <log_err@plt>
jmp    11ba <parse_option+0x6a>
lea    0xe56(%rip),%rdi
mov    %r14,%rsi
call   1070 <log_err@plt>
movq   $0x0,0x0(%rbp)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
test   %rsi,%rsi
je     11bf <parse_option+0x6f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%r15
lea    (%rbx,%rax,1),%r14
add    $0x1,%r14
mov    (%rsp),%rbx
cmp    %rbx,%r14
je     120a <parse_option+0xba>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
movb   $0x3d,(%r15)
jmp    11bf <parse_option+0x6f>
xor    %ebp,%ebp
jmp    11bf <parse_option+0x6f>

LLVM IR (-O0):
%struct.fio_option = type { i32 }
@.str = [24 x i8] c"fio: failed parsing %s\0A\00"
define i32 @parse_option(i8* %0, i8* %1, %struct.fio_option* %2, %struct.fio_option** %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.fio_option*
%10 = alloca %struct.fio_option**
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store %struct.fio_option* %2, %struct.fio_option** %9
store %struct.fio_option** %3, %struct.fio_option*** %10
store i8* %4, i8** %11
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %20, label %16
16: ; preds = %5
%17 = load i8*, i8** %8
%18 = call i32 @log_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load %struct.fio_option**, %struct.fio_option*** %10
store %struct.fio_option* null, %struct.fio_option** %19
store i32 1, i32* %6
br label %68
20: ; preds = %5
%21 = load i8*, i8** %7
%22 = load %struct.fio_option*, %struct.fio_option** %9
%23 = call %struct.fio_option* @get_option(i8* %21, %struct.fio_option* %22, i8** %12)
%24 = load %struct.fio_option**, %struct.fio_option*** %10
store %struct.fio_option* %23, %struct.fio_option** %24
%25 = load %struct.fio_option**, %struct.fio_option*** %10
%26 = load %struct.fio_option*, %struct.fio_option** %25
%27 = icmp ne %struct.fio_option* %26, null
br i1 %27, label %57, label %28
28: ; preds = %20
%29 = load i8*, i8** %12
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %56
31: ; preds = %28
%32 = load i8*, i8** %7
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %13
%34 = load i8*, i8** %7
%35 = load i32, i32* %13
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8*, i8** %12
%40 = icmp ne i8* %38, %39
br i1 %40, label %41, label %51
41: ; preds = %31
%42 = load i8*, i8** %7
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8*, i8** %12
%48 = load i8*, i8** %12
%49 = call i32 @strlen(i8* %48)
%50 = call i32 @memmove(i8* %46, i8* %47, i32 %49)
br label %51
51: ; preds = %41, %31
%52 = load i8*, i8** %7
%53 = load i32, i32* %13
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 61, i8* %55
br label %56
56: ; preds = %51, %28
store i32 1, i32* %6
br label %68
57: ; preds = %20
%58 = load %struct.fio_option**, %struct.fio_option*** %10
%59 = load %struct.fio_option*, %struct.fio_option** %58
%60 = load i8*, i8** %12
%61 = load i8*, i8** %11
%62 = call i32 @handle_option(%struct.fio_option* %59, i8* %60, i8* %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %65, label %64
64: ; preds = %57
store i32 0, i32* %6
br label %68
65: ; preds = %57
%66 = load i8*, i8** %8
%67 = call i32 @log_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %66)
store i32 1, i32* %6
br label %68
68: ; preds = %65, %64, %56, %16
%69 = load i32, i32* %6
ret i32 %69
}

LLVM IR (-O2):
%struct.fio_option = type { i32 }
@.str = [24 x i8] c"fio: failed parsing %s\0A\00"
define i32 @parse_option(i8* %0, i8* %1, %struct.fio_option* %2, %struct.fio_option** nocapture writeonly %3, i8* %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = icmp eq i8* %0, null
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @log_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %1)
store %struct.fio_option* null, %struct.fio_option** %3
br label %33
11: ; preds = %5
%12 = call %struct.fio_option* @get_option(i8* %0, %struct.fio_option* %2, i8** %6)
store %struct.fio_option* %12, %struct.fio_option** %3
%13 = icmp eq %struct.fio_option* %12, null
%14 = load i8*, i8** %6
br i1 %13, label %15, label %28
15: ; preds = %11
%16 = icmp eq i8* %14, null
br i1 %16, label %33, label %17
17: ; preds = %15
%18 = call i32 @strlen(i8* %0)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8*, i8** %6
%23 = icmp eq i8* %21, %22
br i1 %23, label %27, label %24
24: ; preds = %17
%25 = call i32 @strlen(i8* %22)
%26 = call i32 @memmove(i8* %21, i8* %22, i32 %25)
br label %27
27: ; preds = %24, %17
store i8 61, i8* %20
br label %33
28: ; preds = %11
%29 = call i32 @handle_option(%struct.fio_option* %12, i8* %14, i8* %4)
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @log_err(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %33
33: ; preds = %28, %15, %27, %31, %9
%34 = phi i32 [ 1, %31 ], [ 1, %9 ], [ 1, %27 ], [ 1, %15 ], [ 0, %28 ]
ret i32 %34
}