#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 EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int c;
  int digit_optind = 0;
  while (1) {
    int this_option_optind = optind ? optind : 1;
    c = getopt(argc, argv, "abc:d:0123456789");
    if (c == EOF)
      break;
    switch (c) {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      if (digit_optind != 0 && digit_optind != this_option_optind)
        printf("digits occur in two different argv-elements.\n");
      digit_optind = this_option_optind;
      printf("option %c\n", c);
      break;
    case 'a':
      printf("option a\n");
      break;
    case 'b':
      printf("option b\n");
      break;
    case 'c':
      printf("option c with value `%s'\n", optarg);
      break;
    case '?':
      break;
    default:
      printf("?? getopt returned character code 0%o ??\n", c);
    }
  }
  if (optind < argc) {
    printf("non-option ARGV-elements: ");
    while (optind < argc)
      printf("%s ", argv[optind++]);
    printf("\n");
  }
  exit(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)
movl   $0x0,-0x18(%rbp)
mov    0x2e84(%rip),%rax
cmpl   $0x0,(%rax)
je     116e <main+0x3e>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    117b <main+0x4b>
mov    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117b <main+0x4b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf41(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%eax
jne    11ae <main+0x7e>
jmp    1275 <main+0x145>
mov    -0x14(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x33,%eax
ja     125f <main+0x12f>
mov    -0x28(%rbp),%rax
lea    0xe32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x18(%rbp)
je     11fb <main+0xcb>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11fb <main+0xcb>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x140>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x140>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x140>
mov    0x2db4(%rip),%rax
mov    (%rax),%rsi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x140>
jmp    1270 <main+0x140>
mov    -0x14(%rbp),%esi
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12ea <main+0x1ba>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12dc <main+0x1ac>
mov    -0x10(%rbp),%rax
mov    0x2d26(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d18(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1295 <main+0x165>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

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    0x2e71(%rip),%r15
mov    (%r15),%r14d
lea    0xf23(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,%r13d
mov    0x2e60(%rip),%rax
cmp    (%rax),%r13d
jne    11de <main+0x8e>
cmp    %ebp,(%r15)
jge    11d7 <main+0x87>
lea    0xf63(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%eax
cmp    %ebp,%eax
jge    11cd <main+0x7d>
lea    0xf69(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rax),%ecx
mov    %ecx,(%r15)
cltq
mov    (%rbx,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%eax
cmp    %ebp,%eax
jl     11b0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1070 <exit@plt>
test   %r14d,%r14d
mov    $0x1,%eax
cmove  %eax,%r14d
xor    %r12d,%r12d
jmp    1237 <main+0xe7>
nop
lea    0xeae(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%r12d
mov    (%r15),%r14d
test   %r14d,%r14d
mov    $0x1,%eax
cmove  %eax,%r14d
mov    %ebp,%edi
mov    %rbx,%rsi
lea    0xe75(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,%r13d
mov    0x2db2(%rip),%rax
cmp    (%rax),%r13d
je     1185 <main+0x35>
lea    -0x30(%r13),%eax
cmp    $0xa,%eax
jae    1260 <main+0x110>
test   %r12d,%r12d
je     11f0 <main+0xa0>
cmp    %r14d,%r12d
je     11f0 <main+0xa0>
lea    0xed4(%rip),%rdi
call   1040 <puts@plt>
jmp    11f0 <main+0xa0>
nopl   0x0(%rax,%rax,1)
lea    -0x3f(%r13),%eax
cmp    $0x24,%eax
ja     12b8 <main+0x168>
lea    0xd90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
jmp    1204 <main+0xb4>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
jmp    1204 <main+0xb4>
mov    0x2d56(%rip),%rax
mov    (%rax),%rsi
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1204 <main+0xb4>
lea    0xe0b(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1204 <main+0xb4>

LLVM IR (-O0):
@optind = global i32 0
@.str = [17 x i8] c"abc:d:0123456789\00"
@EOF = global i32 0
@.str.1 = [46 x i8] c"digits occur in two different argv-elements.\0A\00"
@.str.2 = [11 x i8] c"option %c\0A\00"
@.str.3 = [10 x i8] c"option a\0A\00"
@.str.4 = [10 x i8] c"option b\0A\00"
@.str.5 = [26 x i8] c"option c with value `%s'\0A\00"
@optarg = global i8* null
@.str.6 = [42 x i8] c"?? getopt returned character code 0%o ??\0A\00"
@.str.7 = [27 x i8] c"non-option ARGV-elements: \00"
@.str.8 = [4 x i8] c"%s \00"
@.str.9 = [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
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %9
9: ; preds = %2, %50
%10 = load i32, i32* @optind
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i32, i32* @optind
br label %15
14: ; preds = %9
br label %15
15: ; preds = %14, %12
%16 = phi i32 [ %13, %12 ], [ 1, %14 ]
store i32 %16, i32* %8
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %15
br label %51
24: ; preds = %15
%25 = load i32, i32* %6
switch i32 %25, label %47 [
i32 48, label %26
i32 49, label %26
i32 50, label %26
i32 51, label %26
i32 52, label %26
i32 53, label %26
i32 54, label %26
i32 55, label %26
i32 56, label %26
i32 57, label %26
i32 97, label %39
i32 98, label %41
i32 99, label %43
i32 63, label %46
]
26: ; preds = %24, %24, %24, %24, %24, %24, %24, %24, %24, %24
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %29, %26
%36 = load i32, i32* %8
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %50
39: ; preds = %24
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %50
41: ; preds = %24
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %50
43: ; preds = %24
%44 = load i8*, i8** @optarg
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %44)
br label %50
46: ; preds = %24
br label %50
47: ; preds = %24
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %47, %46, %43, %41, %39, %35
br label %9
51: ; preds = %23
%52 = load i32, i32* @optind
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %71
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %57
57: ; preds = %61, %55
%58 = load i32, i32* @optind
%59 = load i32, i32* %4
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %69
61: ; preds = %57
%62 = load i8**, i8*** %5
%63 = load i32, i32* @optind
%64 = add nsw i32 %63, 1
store i32 %64, i32* @optind
%65 = sext i32 %63 to i64
%66 = getelementptr inbounds i8*, i8** %62, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %67)
br label %57
69: ; preds = %57
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %71
71: ; preds = %69, %51
%72 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@optind = global i32 0
@.str = [17 x i8] c"abc:d:0123456789\00"
@EOF = global i32 0
@.str.2 = [11 x i8] c"option %c\0A\00"
@.str.5 = [26 x i8] c"option c with value `%s'\0A\00"
@optarg = global i8* null
@.str.6 = [42 x i8] c"?? getopt returned character code 0%o ??\0A\00"
@.str.7 = [27 x i8] c"non-option ARGV-elements: \00"
@.str.8 = [4 x i8] c"%s \00"
@str = [9 x i8] c"option b\00"
@str.10 = [9 x i8] c"option a\00"
@str.11 = [45 x i8] c"digits occur in two different argv-elements.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @optind
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %39, label %7
7: ; preds = %2
%8 = icmp eq i32 %3, 0
%9 = select i1 %8, i32 1, i32 %3
br label %10
10: ; preds = %7, %31
%11 = phi i32 [ %36, %31 ], [ %4, %7 ]
%12 = phi i32 [ %35, %31 ], [ %9, %7 ]
%13 = phi i32 [ %32, %31 ], [ 0, %7 ]
switch i32 %11, label %29 [
i32 48, label %14
i32 49, label %14
i32 50, label %14
i32 51, label %14
i32 52, label %14
i32 53, label %14
i32 54, label %14
i32 55, label %14
i32 56, label %14
i32 57, label %14
i32 97, label %22
i32 98, label %24
i32 99, label %26
i32 63, label %31
]
14: ; preds = %10, %10, %10, %10, %10, %10, %10, %10, %10, %10
%15 = icmp eq i32 %13, 0
%16 = icmp eq i32 %13, %12
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.11, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %31
22: ; preds = %10
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.10, i64 0, i64 0))
br label %31
24: ; preds = %10
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %31
26: ; preds = %10
%27 = load i8*, i8** @optarg
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %27)
br label %31
29: ; preds = %10
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %11)
br label %31
31: ; preds = %20, %22, %24, %26, %10, %29
%32 = phi i32 [ %13, %29 ], [ %13, %10 ], [ %13, %26 ], [ %13, %24 ], [ %13, %22 ], [ %12, %20 ]
%33 = load i32, i32* @optind
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i32 1, i32 %33
%36 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %10
39: ; preds = %31, %2
%40 = load i32, i32* @optind
%41 = icmp slt i32 %40, %0
br i1 %41, label %42, label %57
42: ; preds = %39
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%44 = load i32, i32* @optind
%45 = icmp slt i32 %44, %0
br i1 %45, label %46, label %55
46: ; preds = %42, %46
%47 = phi i32 [ %53, %46 ], [ %44, %42 ]
%48 = add nsw i32 %47, 1
store i32 %48, i32* @optind
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %51)
%53 = load i32, i32* @optind
%54 = icmp slt i32 %53, %0
br i1 %54, label %46, label %55
55: ; preds = %46, %42
%56 = tail call i32 @putchar(i32 10)
br label %57
57: ; preds = %55, %39
%58 = tail call i32 @exit(i32 0)
unreachable
}