#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 command_line_option {
  int dummy;
};

/* Variables and functions */
int validate_option(struct command_line_option const *, size_t, char const *,
                    int);
int parse_command_line_option(const struct command_line_option *options,
                              size_t n, const char *arg, int flags) {
  static char a[] = " ";
  int i, m;
  if (arg[0] != '-')
    return 0x80000000;
  if (arg[1] == '-')
    return validate_option(options, n, &arg[2], flags);
  m = flags;
  for (i = 1; a[0] = arg[i]; i++) {
    m = validate_option(options, n, a, m);
    if (m & 0x80000000)
      break;
  }
  return m;
}


x86 assembly (clang, -O0):
<parse_command_line_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1143 <parse_command_line_option+0x33>
movl   $0x80000000,-0x4(%rbp)
jmp    11e3 <parse_command_line_option+0xd3>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    1174 <parse_command_line_option+0x64>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    $0x2,%rdx
mov    -0x24(%rbp),%ecx
call   1030 <validate_option@plt>
mov    %eax,-0x4(%rbp)
jmp    11e3 <parse_command_line_option+0xd3>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,0x2e96(%rip)
cmp    $0x0,%al
je     11dd <parse_command_line_option+0xcd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
lea    0x2e7c(%rip),%rdx
call   1030 <validate_option@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     11ca <parse_command_line_option+0xba>
jmp    11dd <parse_command_line_option+0xcd>
jmp    11cf <parse_command_line_option+0xbf>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1181 <parse_command_line_option+0x71>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_command_line_option>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x80000000,%eax
cmpb   $0x2d,(%rdx)
jne    1199 <parse_command_line_option+0x89>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x1(%rdx),%al
cmp    $0x2d,%al
jne    114f <parse_command_line_option+0x3f>
add    $0x2,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <validate_option@plt>
mov    %al,0x2ed3(%rip)
test   %al,%al
je     1197 <parse_command_line_option+0x87>
add    $0x2,%rbx
lea    0x2ec4(%rip),%r12
mov    %ecx,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %eax,%ecx
call   1030 <validate_option@plt>
test   %eax,%eax
js     1199 <parse_command_line_option+0x89>
movzbl (%rbx),%ecx
mov    %cl,0x2e9b(%rip)
add    $0x1,%rbx
test   %cl,%cl
jne    1170 <parse_command_line_option+0x60>
jmp    1199 <parse_command_line_option+0x89>
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.command_line_option = type { i32 }
@parse_command_line_option.a = internal global [2 x i8] c" \00"
define i32 @parse_command_line_option(%struct.command_line_option* %0, i64 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.command_line_option*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.command_line_option* %0, %struct.command_line_option** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i8*, i8** %8
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 45
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 -2147483648, i32* %5
br label %55
18: ; preds = %4
%19 = load i8*, i8** %8
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 45
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load %struct.command_line_option*, %struct.command_line_option** %6
%26 = load i64, i64* %7
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = load i32, i32* %9
%30 = call i32 @validate_option(%struct.command_line_option* %25, i64 %26, i8* %28, i32 %29)
store i32 %30, i32* %5
br label %55
31: ; preds = %18
%32 = load i32, i32* %9
store i32 %32, i32* %11
store i32 1, i32* %10
br label %33
33: ; preds = %50, %31
%34 = load i8*, i8** %8
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
store i8 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @parse_command_line_option.a, i64 0, i64 0)
%39 = icmp ne i8 %38, 0
br i1 %39, label %40, label %53
40: ; preds = %33
%41 = load %struct.command_line_option*, %struct.command_line_option** %6
%42 = load i64, i64* %7
%43 = load i32, i32* %11
%44 = call i32 @validate_option(%struct.command_line_option* %41, i64 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @parse_command_line_option.a, i64 0, i64 0), i32 %43)
store i32 %44, i32* %11
%45 = load i32, i32* %11
%46 = and i32 %45, -2147483648
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %40
br label %53
49: ; preds = %40
br label %50
50: ; preds = %49
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
store i32 %52, i32* %10
br label %33
53: ; preds = %48, %33
%54 = load i32, i32* %11
store i32 %54, i32* %5
br label %55
55: ; preds = %53, %24, %17
%56 = load i32, i32* %5
ret i32 %56
}

LLVM IR (-O2):
%struct.command_line_option = type { i32 }
@parse_command_line_option.a = internal global [2 x i8] c" \00"
define i32 @parse_command_line_option(%struct.command_line_option* %0, i64 %1, i8* %2, i32 %3) {
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 45
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %2, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %13, label %11
11: ; preds = %7
store i8 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @parse_command_line_option.a, i64 0, i64 0)
%12 = icmp eq i8 %9, 0
br i1 %12, label %26, label %20
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %2, i64 2
%15 = tail call i32 @validate_option(%struct.command_line_option* %0, i64 %1, i8* %14, i32 %3)
br label %26
16: ; preds = %20
%17 = getelementptr inbounds i8, i8* %2, i64 %25
%18 = load i8, i8* %17
store i8 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @parse_command_line_option.a, i64 0, i64 0)
%19 = icmp eq i8 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %11, %16
%21 = phi i64 [ %25, %16 ], [ 1, %11 ]
%22 = phi i32 [ %23, %16 ], [ %3, %11 ]
%23 = tail call i32 @validate_option(%struct.command_line_option* %0, i64 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @parse_command_line_option.a, i64 0, i64 0), i32 %22)
%24 = icmp sgt i32 %23, -1
%25 = add nuw i64 %21, 1
br i1 %24, label %16, label %26
26: ; preds = %20, %16, %11, %4, %13
%27 = phi i32 [ %15, %13 ], [ -2147483648, %4 ], [ %3, %11 ], [ %23, %16 ], [ %23, %20 ]
ret i32 %27
}