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

/* Variables and functions */
char getopt(int, char *const *, char *);
int /*<<< orphan*/ getoptstr(struct conf_option *, char *);
int optind;
int /*<<< orphan*/ set_option(struct conf_option *, char);
int get_options(struct conf_option *opt, int argc, char *const argv[]) {
  char c;
  char opt_str[128];
  getoptstr(opt, opt_str);
  while ((c = getopt(argc, argv, opt_str)) != -1) {
    switch (c) {
    case '?':
      return -1;
      break;
    default:
      set_option(opt, c);
    }
  }
  return optind;
}


x86 assembly (clang, -O0):
<get_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1050 <getoptstr@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
call   1040 <getopt@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     11a6 <get_options+0x76>
mov    -0x21(%rbp),%al
sub    $0x3f,%al
jne    1194 <get_options+0x64>
jmp    1188 <get_options+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b2 <get_options+0x82>
mov    -0x10(%rbp),%rdi
movsbl -0x21(%rbp),%esi
call   1030 <set_option@plt>
jmp    1156 <get_options+0x26>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_options>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rsi
call   1050 <getoptstr@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <getopt@plt>
cmp    $0xff,%al
je     1172 <get_options+0x42>
cmp    $0x3f,%al
je     117d <get_options+0x4d>
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <set_option@plt>
jmp    1150 <get_options+0x20>
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
jmp    1182 <get_options+0x52>
mov    $0xffffffff,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.conf_option = type { i32 }
@optind = global i32 0
define i32 @get_options(%struct.conf_option* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.conf_option*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8
%9 = alloca [128 x i8]
store %struct.conf_option* %0, %struct.conf_option** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%10 = load %struct.conf_option*, %struct.conf_option** %5
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%12 = call i32 @getoptstr(%struct.conf_option* %10, i8* %11)
br label %13
13: ; preds = %28, %3
%14 = load i32, i32* %6
%15 = load i8**, i8*** %7
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%17 = call signext i8 @getopt(i32 %14, i8** %15, i8* %16)
store i8 %17, i8* %8
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = load i8, i8* %8
%22 = sext i8 %21 to i32
switch i32 %22, label %24 [
i32 63, label %23
]
23: ; preds = %20
store i32 -1, i32* %4
br label %31
24: ; preds = %20
%25 = load %struct.conf_option*, %struct.conf_option** %5
%26 = load i8, i8* %8
%27 = call i32 @set_option(%struct.conf_option* %25, i8 signext %26)
br label %28
28: ; preds = %24
br label %13
29: ; preds = %13
%30 = load i32, i32* @optind
store i32 %30, i32* %4
br label %31
31: ; preds = %29, %23
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
%struct.conf_option = type { i32 }
@optind = global i32 0
define i32 @get_options(%struct.conf_option* %0, i32 %1, i8** %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = call i32 @getoptstr(%struct.conf_option* %0, i8* %5)
br label %7
7: ; preds = %9, %3
%8 = call signext i8 @getopt(i32 %1, i8** %2, i8* %5)
switch i8 %8, label %9 [
i8 -1, label %11
i8 63, label %13
]
9: ; preds = %7
%10 = call i32 @set_option(%struct.conf_option* %0, i8 signext %8)
br label %7
11: ; preds = %7
%12 = load i32, i32* @optind
br label %13
13: ; preds = %7, %11
%14 = phi i32 [ %12, %11 ], [ -1, %7 ]
ret i32 %14
}