#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*/ const member_1;
};

/* Variables and functions */
int /*<<< orphan*/ error();
int getopt_long_only(int, char **, char *, struct option *, int *);
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *);
#define required_argument 128
int main(int argc, char *argv[]) {
  int c;
  int counter = 0;
  int option_index = 0;
  static struct option long_options[] = {{"name", required_argument, 0, 'a'},
                                         {"b", required_argument, 0, 'b'},
                                         {0, 0, 0, 0}};
  while ((c = getopt_long_only(argc, argv, "a:b:", long_options,
                               &option_index)) != -1)
    switch (c) {
    case 'a':
      printf("-name %s\n", optarg);
      break;
    case 'b':
      printf("-b %s\n", optarg);
      break;
    case '?':
      error();
    }
  argv += optind;
  argc -= optind;
  while (counter < argc)
    printf("Remaining arg:  %s\n", argv[counter++]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdx
lea    0x2ed7(%rip),%rcx
lea    -0x1c(%rbp),%r8
call   1040 <getopt_long_only@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11f6 <main+0xc6>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x3f,%eax
je     11ea <main+0xba>
jmp    1192 <main+0x62>
mov    -0x20(%rbp),%eax
sub    $0x61,%eax
je     11b4 <main+0x84>
jmp    11a3 <main+0x73>
mov    -0x20(%rbp),%eax
sub    $0x62,%eax
je     11cf <main+0x9f>
jmp    11f1 <main+0xc1>
mov    0x2e3d(%rip),%rax
mov    (%rax),%rsi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    11f1 <main+0xc1>
mov    0x2e22(%rip),%rax
mov    (%rax),%rsi
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
jmp    11f1 <main+0xc1>
mov    $0x0,%al
call   1050 <error@plt>
jmp    1154 <main+0x24>
mov    0x2de3(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1253 <main+0x123>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdd4(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <main+0xf0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
movl   $0x0,0x4(%rsp)
lea    0xeb8(%rip),%r15
lea    0x2eea(%rip),%r12
lea    0x4(%rsp),%r13
mov    0x2e96(%rip),%rbp
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1040 <getopt_long_only@plt>
cmp    $0x60,%eax
jle    11c0 <main+0x90>
cmp    $0x62,%eax
je     1170 <main+0x40>
cmp    $0x61,%eax
jne    1180 <main+0x50>
mov    0x0(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x3f,%eax
jne    11ce <main+0x9e>
xor    %eax,%eax
call   1050 <error@plt>
jmp    1180 <main+0x50>
cmp    $0xffffffff,%eax
jne    1180 <main+0x50>
mov    0x2e06(%rip),%rax
mov    (%rax),%rax
sub    %eax,%ebx
test   %ebx,%ebx
jle    1215 <main+0xe5>
lea    (%r14,%rax,8),%r15
mov    %ebx,%ebx
xor    %ebp,%ebp
lea    0xe2b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rsi
add    $0x1,%rbp
mov    %r14,%rdi
call   1030 <printf@plt>
cmp    %rbp,%rbx
jne    1200 <main+0xd0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 98 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"name\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [5 x i8] c"a:b:\00"
@.str.3 = [10 x i8] c"-name %s\0A\00"
@optarg = global i8* null
@.str.4 = [7 x i8] c"-b %s\0A\00"
@optind = global i64 0
@.str.5 = [20 x i8] c"Remaining arg: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt_long_only(i32 %10, i8** %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %8)
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %24 [
i32 97, label %16
i32 98, label %19
i32 63, label %22
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %24
19: ; preds = %14
%20 = load i8*, i8** @optarg
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %20)
br label %24
22: ; preds = %14
%23 = call i32 (...) @error()
br label %24
24: ; preds = %22, %14, %19, %16
br label %9
25: ; preds = %9
%26 = load i64, i64* @optind
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 %26
store i8** %28, i8*** %5
%29 = load i64, i64* @optind
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = sub nsw i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %4
br label %34
34: ; preds = %38, %25
%35 = load i32, i32* %7
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8*, i8** %39, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %44)
br label %34
46: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 98 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"name\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [5 x i8] c"a:b:\00"
@.str.3 = [10 x i8] c"-name %s\0A\00"
@optarg = global i8* null
@.str.4 = [7 x i8] c"-b %s\0A\00"
@optind = global i64 0
@.str.5 = [20 x i8] c"Remaining arg: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %7, %2
%6 = call i32 @getopt_long_only(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %3)
switch i32 %6, label %7 [
i32 -1, label %16
i32 97, label %8
i32 98, label %11
i32 63, label %14
]
7: ; preds = %5, %14, %11, %8
br label %5
8: ; preds = %5
%9 = load i8*, i8** @optarg
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %7
11: ; preds = %5
%12 = load i8*, i8** @optarg
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %7
14: ; preds = %5
%15 = call i32 (...) @error()
br label %7
16: ; preds = %5
%17 = load i64, i64* @optind
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = trunc i64 %17 to i32
%20 = sub i32 %0, %19
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %16
%23 = zext i32 %20 to i64
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ 0, %22 ], [ %26, %24 ]
%26 = add nuw nsw i64 %25, 1
%27 = getelementptr inbounds i8*, i8** %18, i64 %25
%28 = load i8*, i8** %27
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = icmp eq i64 %26, %23
br i1 %30, label %31, label %24
31: ; preds = %24, %16
ret i32 0
}