#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
char *optarg;
scalar_t__ opterr;
int optind;
int optopt;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char *liste_options = "abc:XY";
  int option;
  opterr = 0;
  while ((option = getopt(argc, argv, liste_options)) != -1) {
    switch (option) {
    case 'a':
      fprintf(stdout, "Option a\n");
      break;
    case 'b':
      fprintf(stdout, "Option b\n");
      break;
    case 'c':
      fprintf(stdout, "Option c %s\n", optarg);
      break;
    case 'X':
    case 'Y':
      fprintf(stdout, "Option %c\n", option);
      break;
    case '?':
      fprintf(stderr, "Option %c fausse\n", optopt);
      break;
    }
  }
  if (optind != argc) {
    fprintf(stdout, "Arguments restants :\n");
    while (optind != argc)
      fprintf(stdout, "  %s\n", argv[optind++]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xf57(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e78(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1236 <main+0x116>
mov    -0x1c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x24,%eax
ja     1231 <main+0x111>
mov    -0x28(%rbp),%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xef7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1231 <main+0x111>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xee5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1231 <main+0x111>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    0x2e1c(%rip),%rax
mov    (%rax),%rdx
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1231 <main+0x111>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1231 <main+0x111>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    114f <main+0x2f>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     12b4 <main+0x194>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     12af <main+0x18f>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2d53(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d45(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125f <main+0x13f>
jmp    12b4 <main+0x194>
xor    %eax,%eax
add    $0x30,%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    0x2e89(%rip),%rax
movq   $0x0,(%rax)
lea    0xf4f(%rip),%r14
lea    0xeb4(%rip),%r13
mov    0x2e65(%rip),%r15
lea    0xf62(%rip),%r12
jmp    116d <main+0x4d>
mov    (%r15),%edi
lea    0xf35(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x24,%ecx
ja     11e1 <main+0xc1>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
mov    (%r15),%edi
mov    %r12,%rsi
mov    %eax,%edx
jmp    11af <main+0x8f>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
lea    0xf18(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    116d <main+0x4d>
mov    (%r15),%edi
lea    0xee3(%rip),%rsi
jmp    1166 <main+0x46>
mov    (%r15),%edi
mov    0x2e2a(%rip),%rax
mov    (%rax),%rdx
lea    0xed7(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    116d <main+0x4d>
cmp    $0xffffffff,%eax
jne    116d <main+0x4d>
mov    0x2deb(%rip),%r12
cmp    %ebp,(%r12)
je     1242 <main+0x122>
mov    (%r15),%edi
lea    0xedc(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r12),%eax
cmp    %ebp,%eax
je     1242 <main+0x122>
lea    0xedc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%edi
lea    0x1(%rax),%ecx
mov    %ecx,(%r12)
cltq
mov    (%rbx,%rax,8),%rdx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r12),%eax
cmp    %ebp,%eax
jne    1220 <main+0x100>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"abc:XY\00"
@opterr = global i64 0
@stdout = global i32 0
@.str.1 = [10 x i8] c"Option a\0A\00"
@.str.2 = [10 x i8] c"Option b\0A\00"
@.str.3 = [13 x i8] c"Option c %s\0A\00"
@optarg = global i8* null
@.str.4 = [11 x i8] c"Option %c\0A\00"
@stderr = global i32 0
@.str.5 = [18 x i8] c"Option %c fausse\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.6 = [22 x i8] c"Arguments restants :\0A\00"
@.str.7 = [6 x i8] c" %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
store i64 0, i64* @opterr
br label %8
8: ; preds = %34, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = load i8*, i8** %6
%12 = call i32 @getopt(i32 %9, i8** %10, i8* %11)
store i32 %12, i32* %7
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %35
14: ; preds = %8
%15 = load i32, i32* %7
switch i32 %15, label %34 [
i32 97, label %16
i32 98, label %19
i32 99, label %22
i32 88, label %26
i32 89, label %26
i32 63, label %30
]
16: ; preds = %14
%17 = load i32, i32* @stdout
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %34
19: ; preds = %14
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %34
22: ; preds = %14
%23 = load i32, i32* @stdout
%24 = load i8*, i8** @optarg
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %34
26: ; preds = %14, %14
%27 = load i32, i32* @stdout
%28 = load i32, i32* %7
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %34
30: ; preds = %14
%31 = load i32, i32* @stderr
%32 = load i32, i32* @optopt
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %14, %30, %26, %22, %19, %16
br label %8
35: ; preds = %8
%36 = load i32, i32* @optind
%37 = load i32, i32* %4
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = load i32, i32* @stdout
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %42
42: ; preds = %46, %39
%43 = load i32, i32* @optind
%44 = load i32, i32* %4
%45 = icmp ne i32 %43, %44
br i1 %45, label %46, label %55
46: ; preds = %42
%47 = load i32, i32* @stdout
%48 = load i8**, i8*** %5
%49 = load i32, i32* @optind
%50 = add nsw i32 %49, 1
store i32 %50, i32* @optind
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8*, i8** %48, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %53)
br label %42
55: ; preds = %42
br label %56
56: ; preds = %55, %35
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"abc:XY\00"
@opterr = global i64 0
@stdout = global i32 0
@.str.1 = [10 x i8] c"Option a\0A\00"
@.str.2 = [10 x i8] c"Option b\0A\00"
@.str.3 = [13 x i8] c"Option c %s\0A\00"
@optarg = global i8* null
@.str.4 = [11 x i8] c"Option %c\0A\00"
@stderr = global i32 0
@.str.5 = [18 x i8] c"Option %c fausse\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.6 = [22 x i8] c"Arguments restants :\0A\00"
@.str.7 = [6 x i8] c" %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %5 [
i32 -1, label %23
i32 97, label %6
i32 98, label %9
i32 99, label %12
i32 88, label %16
i32 89, label %16
i32 63, label %19
]
5: ; preds = %3, %19, %16, %12, %9, %6
br label %3
6: ; preds = %3
%7 = load i32, i32* @stdout
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %5
9: ; preds = %3
%10 = load i32, i32* @stdout
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %5
12: ; preds = %3
%13 = load i32, i32* @stdout
%14 = load i8*, i8** @optarg
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %5
16: ; preds = %3, %3
%17 = load i32, i32* @stdout
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %4)
br label %5
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = load i32, i32* @optopt
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %5
23: ; preds = %3
%24 = load i32, i32* @optind
%25 = icmp eq i32 %24, %0
br i1 %25, label %41, label %26
26: ; preds = %23
%27 = load i32, i32* @stdout
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%29 = load i32, i32* @optind
%30 = icmp eq i32 %29, %0
br i1 %30, label %41, label %31
31: ; preds = %26, %31
%32 = phi i32 [ %39, %31 ], [ %29, %26 ]
%33 = load i32, i32* @stdout
%34 = add nsw i32 %32, 1
store i32 %34, i32* @optind
%35 = sext i32 %32 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %37)
%39 = load i32, i32* @optind
%40 = icmp eq i32 %39, %0
br i1 %40, label %41, label %31
41: ; preds = %31, %26, %23
ret i32 0
}