#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 option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ no_argument;
int /*<<< orphan*/ usage();
int /*<<< orphan*/ version();
int check_commandline_args(int argc, char **argv) {
  struct option longopts[] = {
      {"help", no_argument, 0, 'h'},
      {"version", no_argument, 0, 'v'},
  };
  int longindex;
  int opt;
  int rc = 0;
  int do_break = 0;
  while ((opt = getopt_long(argc, argv, "hv", longopts, &longindex)) != -1) {
    switch (opt) {
    case 'h':
      usage();
      rc = -1;
      break;
    case 'v':
      version();
      rc = -1;
      break;
    default:
      break;
    }
    if (do_break) {
      break;
    }
  }
  return rc;
}


x86 assembly (clang, -O0):
<check_commandline_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x68,-0x30(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x76,-0x18(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rcx
lea    0xe64(%rip),%rdx
lea    -0x44(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x48(%rbp)
cmp    $0xffffffff,%eax
je     1222 <check_commandline_args+0xf2>
mov    -0x48(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x68,%eax
je     11e3 <check_commandline_args+0xb3>
jmp    11d2 <check_commandline_args+0xa2>
mov    -0x54(%rbp),%eax
sub    $0x76,%eax
je     11f6 <check_commandline_args+0xc6>
jmp    1209 <check_commandline_args+0xd9>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0xffffffff,-0x4c(%rbp)
jmp    120e <check_commandline_args+0xde>
mov    $0x0,%al
call   1040 <version@plt>
movl   $0xffffffff,-0x4c(%rbp)
jmp    120e <check_commandline_args+0xde>
jmp    120e <check_commandline_args+0xde>
cmpl   $0x0,-0x50(%rbp)
je     121d <check_commandline_args+0xed>
jmp    1222 <check_commandline_args+0xf2>
jmp    1197 <check_commandline_args+0x67>
mov    -0x4c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_commandline_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb6(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%al
mov    %al,0x18(%rsp)
movabs $0x6800000000,%rcx
mov    %rcx,0x1c(%rsp)
lea    0xe93(%rip),%rcx
mov    %rcx,0x28(%rsp)
mov    %al,0x30(%rsp)
movabs $0x7600000000,%rax
mov    %rax,0x34(%rsp)
lea    0xe7c(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
xor    %r13d,%r13d
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1030 <getopt_long@plt>
cmp    $0xffffffff,%eax
je     11e0 <check_commandline_args+0xb0>
cmp    $0x76,%eax
je     11d1 <check_commandline_args+0xa1>
cmp    $0x68,%eax
jne    11a0 <check_commandline_args+0x70>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0xffffffff,%r13d
jmp    11a0 <check_commandline_args+0x70>
xor    %eax,%eax
call   1040 <version@plt>
mov    $0xffffffff,%r13d
jmp    11a0 <check_commandline_args+0x70>
mov    %r13d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [3 x i8] c"hv\00"
define i32 @check_commandline_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [2 x %struct.option]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %5, i64 0, i64 0
%11 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 1
%13 = load i32, i32* @no_argument
%14 = trunc i32 %13 to i8
store i8 %14, i8* %12
%15 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 2
store i32 0, i32* %15
%16 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 3
store i32 104, i32* %16
%17 = getelementptr inbounds %struct.option, %struct.option* %10, i64 1
%18 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 1
%20 = load i32, i32* @no_argument
%21 = trunc i32 %20 to i8
store i8 %21, i8* %19
%22 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 2
store i32 0, i32* %22
%23 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 3
store i32 118, i32* %23
store i32 0, i32* %8
store i32 0, i32* %9
br label %24
24: ; preds = %41, %2
%25 = load i32, i32* %3
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %5, i64 0, i64 0
%28 = call i32 @getopt_long(i32 %25, i8** %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* %27, i32* %6)
store i32 %28, i32* %7
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %42
30: ; preds = %24
%31 = load i32, i32* %7
switch i32 %31, label %36 [
i32 104, label %32
i32 118, label %34
]
32: ; preds = %30
%33 = call i32 (...) @usage()
store i32 -1, i32* %8
br label %37
34: ; preds = %30
%35 = call i32 (...) @version()
store i32 -1, i32* %8
br label %37
36: ; preds = %30
br label %37
37: ; preds = %36, %34, %32
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %37
br label %42
41: ; preds = %37
br label %24
42: ; preds = %40, %24
%43 = load i32, i32* %8
ret i32 %43
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [3 x i8] c"hv\00"
define i32 @check_commandline_args(i32 %0, i8** %1) {
%3 = alloca [2 x %struct.option]
%4 = alloca i32
%5 = bitcast [2 x %struct.option]* %3 to i8*
%6 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0
%7 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 1
%9 = load i32, i32* @no_argument
%10 = trunc i32 %9 to i8
store i8 %10, i8* %8
%11 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 2
store i32 0, i32* %11
%12 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 3
store i32 104, i32* %12
%13 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 1
store i8 %10, i8* %14
%15 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 2
store i32 0, i32* %15
%16 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 3
store i32 118, i32* %16
%17 = bitcast i32* %4 to i8*
br label %18
18: ; preds = %26, %2
%19 = phi i32 [ 0, %2 ], [ -1, %26 ]
br label %20
20: ; preds = %18, %20
%21 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* %6, i32* %4)
switch i32 %21, label %20 [
i32 -1, label %27
i32 104, label %22
i32 118, label %24
]
22: ; preds = %20
%23 = call i32 (...) @usage()
br label %26
24: ; preds = %20
%25 = call i32 (...) @version()
br label %26
26: ; preds = %24, %22
br label %18
27: ; preds = %20
ret i32 %19
}