#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 */

/* Variables and functions */
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int c;
  int status = 0;
  optind = 2;
  while ((c = getopt(argc, argv, argv[1])) != -1)
    switch (c) {
    case '?':
      status = 1;
      break;
    default:
      if (optarg != NULL)
        printf(" -%c %s", c, optarg);
      else
        printf(" -%c", c);
      break;
    }
  printf(" --");
  for (; optind < argc; optind++)
    printf(" %s", argv[optind]);
  printf("\n");
  return (status);
}


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)
mov    0x2e9c(%rip),%rax
movl   $0x2,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11d3 <main+0xb3>
mov    -0x14(%rbp),%eax
sub    $0x3f,%eax
jne    1187 <main+0x67>
jmp    117b <main+0x5b>
movl   $0x1,-0x18(%rbp)
jmp    11ce <main+0xae>
mov    0x2e6a(%rip),%rax
cmpq   $0x0,(%rax)
je     11b8 <main+0x98>
mov    -0x14(%rbp),%esi
mov    0x2e56(%rip),%rax
mov    (%rax),%rdx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <main+0xa9>
mov    -0x14(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <main+0xae>
jmp    114a <main+0x2a>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    122d <main+0x10d>
mov    -0x10(%rbp),%rax
mov    0x2de2(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2dba(%rip),%rax
mov    %ecx,(%rax)
jmp    11e1 <main+0xc1>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%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,%rbx
mov    %edi,%ebp
mov    0x2e99(%rip),%r13
movl   $0x2,0x0(%r13)
mov    0x2ea2(%rip),%r14
lea    0xeab(%rip),%r15
lea    0xe9c(%rip),%r12
movl   $0x0,0x4(%rsp)
jmp    117c <main+0x4c>
xchg   %ax,%ax
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <getopt@plt>
cmp    $0xffffffff,%eax
je     11b4 <main+0x84>
cmp    $0x3f,%eax
je     11aa <main+0x7a>
mov    (%r14),%rdx
test   %rdx,%rdx
jne    1170 <main+0x40>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117c <main+0x4c>
movl   $0x1,0x4(%rsp)
jmp    117c <main+0x4c>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%eax
cmp    %ebp,%eax
jge    11ff <main+0xcf>
lea    0xe33(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cltq
mov    (%rbx,%rax,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%eax
add    $0x1,%eax
mov    %eax,0x0(%r13)
cmp    %ebp,%eax
jl     11e0 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@optind = global i32 0
@optarg = global i8* null
@.str = [8 x i8] c" -%c %s\00"
@.str.1 = [5 x i8] c" -%c\00"
@.str.2 = [4 x i8] c" --\00"
@.str.3 = [4 x i8] c" %s\00"
define i32 @main(i32 %0, i8** %1) {
store i32 2, i32* @optind
%3 = getelementptr inbounds i8*, i8** %1, i64 1
br label %4
4: ; preds = %6, %2
%5 = phi i32 [ 0, %2 ], [ 1, %6 ]
br label %6
6: ; preds = %14, %4
%7 = load i8*, i8** %3
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* %7)
switch i32 %8, label %9 [
i32 -1, label %17
i32 63, label %4
]
9: ; preds = %6
%10 = load i8*, i8** @optarg
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %10)
br label %14
14: ; preds = %12, %15
br label %6
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %14
17: ; preds = %6
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @optind
%20 = icmp slt i32 %19, %0
br i1 %20, label %21, label %30
21: ; preds = %17, %21
%22 = phi i32 [ %28, %21 ], [ %19, %17 ]
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = load i8*, i8** %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @optind
%28 = add nsw i32 %27, 1
store i32 %28, i32* @optind
%29 = icmp slt i32 %28, %0
br i1 %29, label %21, label %30
30: ; preds = %21, %17
%31 = tail call i32 @putchar(i32 10)
ret i32 %5
}