#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;
scalar_t__ optopt;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int oc;
  char ec;
  char *b_opt_arg;
  while ((oc = getopt(argc, argv, ":ngl:")) != -1) {
    switch (oc) {
    case 'n':
      printf("new.\n");
      break;
    case 'g':
      printf("great.\n");
      break;
    case 'l':
      b_opt_arg = optarg;
      printf("l is %s\n", b_opt_arg);
      break;
    case '?':
      ec = (char)optopt;
      printf("无效的选项字符 \'%c\'\n", ec);
      break;
    case ':':
      printf("缺少选项参数！\n");
      break;
    }
  }
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xebc(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     122f <main+0x10f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3a,%eax
je     121c <main+0xfc>
jmp    1169 <main+0x49>
mov    -0x24(%rbp),%eax
sub    $0x3f,%eax
je     11f8 <main+0xd8>
jmp    117a <main+0x5a>
mov    -0x24(%rbp),%eax
sub    $0x67,%eax
je     11c0 <main+0xa0>
jmp    118b <main+0x6b>
mov    -0x24(%rbp),%eax
sub    $0x6c,%eax
je     11d3 <main+0xb3>
jmp    119c <main+0x7c>
mov    -0x24(%rbp),%eax
sub    $0x6e,%eax
jne    122a <main+0x10a>
jmp    11ad <main+0x8d>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <main+0x10a>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <main+0x10a>
mov    0x2e1e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <main+0x10a>
mov    0x2de1(%rip),%rax
mov    (%rax),%rax
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <main+0x10a>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
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
lea    0xeb9(%rip),%r14
lea    0xef3(%rip),%r13
lea    0xeb1(%rip),%r15
lea    0xeec(%rip),%r12
jmp    1170 <main+0x40>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    $0x66,%eax
jle    11a0 <main+0x70>
cmp    $0x67,%eax
je     11c4 <main+0x94>
cmp    $0x6c,%eax
je     11ce <main+0x9e>
cmp    $0x6e,%eax
jne    1170 <main+0x40>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1170 <main+0x40>
nopl   0x0(%rax,%rax,1)
cmp    $0x3a,%eax
je     115e <main+0x2e>
cmp    $0x3f,%eax
jne    11e4 <main+0xb4>
mov    0x2e2f(%rip),%rax
movsbl (%rax),%esi
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    1170 <main+0x40>
mov    0x2e23(%rip),%rax
mov    (%rax),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
cmp    $0xffffffff,%eax
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c":ngl:\00"
@.str.1 = [6 x i8] c"new.\0A\00"
@.str.2 = [8 x i8] c"great.\0A\00"
@optarg = global i8* null
@.str.3 = [9 x i8] c"l is %s\0A\00"
@optopt = global i64 0
@.str.4 = [28 x i8] c"\E6\97\A0\E6\95\88\E7\9A\84\E9\80\89\E9\A1\B9\E5\AD\97\E7\AC\A6 '%c'\0A\00"
@.str.5 = [23 x i8] c"\E7\BC\BA\E5\B0\91\E9\80\89\E9\A1\B9\E5\8F\82\E6\95\B0\EF\BC\81\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %32, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %33
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %32 [
i32 110, label %16
i32 103, label %18
i32 108, label %20
i32 63, label %24
i32 58, label %30
]
16: ; preds = %14
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %32
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %32
20: ; preds = %14
%21 = load i8*, i8** @optarg
store i8* %21, i8** %8
%22 = load i8*, i8** %8
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %32
24: ; preds = %14
%25 = load i64, i64* @optopt
%26 = trunc i64 %25 to i8
store i8 %26, i8* %7
%27 = load i8, i8* %7
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %32
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %14, %30, %24, %20, %18, %16
br label %9
33: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c":ngl:\00"
@optarg = global i8* null
@.str.3 = [9 x i8] c"l is %s\0A\00"
@optopt = global i64 0
@.str.4 = [28 x i8] c"\E6\97\A0\E6\95\88\E7\9A\84\E9\80\89\E9\A1\B9\E5\AD\97\E7\AC\A6 '%c'\0A\00"
@str = [22 x i8] c"\E7\BC\BA\E5\B0\91\E9\80\89\E9\A1\B9\E5\8F\82\E6\95\B0\EF\BC\81\00"
@str.6 = [7 x i8] c"great.\00"
@str.7 = [5 x i8] c"new.\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %5 [
i32 -1, label %21
i32 110, label %6
i32 103, label %8
i32 108, label %10
i32 63, label %13
i32 58, label %19
]
5: ; preds = %3, %19, %13, %10, %8, %6
br label %3
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.7, i64 0, i64 0))
br label %5
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.6, i64 0, i64 0))
br label %5
10: ; preds = %3
%11 = load i8*, i8** @optarg
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %5
13: ; preds = %3
%14 = load i64, i64* @optopt
%15 = trunc i64 %14 to i32
%16 = shl i32 %15, 24
%17 = ashr exact i32 %16, 24
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %5
19: ; preds = %3
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %5
21: ; preds = %3
ret i32 0
}