#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;
  int *member_2;
  int member_3;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
char *getenv(char *);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ no_argument;
int optind;
int /*<<< orphan*/ print_env(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ version();
int main(int argc, char **argv) {
  int c;
  int option_index;
  int null_flag = 0, help_flag = 0, ver_flag = 0;
  struct option options[] = {{"null", no_argument, 0, '0'},
                             {"help", no_argument, &help_flag, 1},
                             {"version", no_argument, &ver_flag, 1},
                             {0, 0, 0, 0}};
  while (1) {
    c = getopt_long(argc, argv, "0", options, &option_index);
    if (c == -1)
      break;
    switch (c) {
    case 0:
      break;
    case '0':
      null_flag = 1;
      break;
    default:
      usage();
    }
  }
  if (help_flag)
    usage();
  if (ver_flag)
    version();
  if (optind >= argc)
    print_env(null_flag);
  else {
    while (optind < argc) {
      printf("%s", getenv(argv[optind]));
      if (!null_flag)
        putchar('\n');
      optind++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe44(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2e0e(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0x30,-0x7c(%rbp)
add    $0x18,%rdi
lea    0xe18(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0x2de0(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x70(%rbp)
lea    -0x20(%rbp),%rax
mov    %eax,-0x68(%rbp)
movl   $0x1,-0x64(%rbp)
add    $0x18,%rdi
lea    0xdf2(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2db5(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x58(%rbp)
lea    -0x24(%rbp),%rax
mov    %eax,-0x50(%rbp)
movl   $0x1,-0x4c(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    0xdb5(%rip),%rdx
lea    -0x18(%rbp),%r8
call   1050 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1278 <main+0xf8>
jmp    12bf <main+0x13f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x94(%rbp)
test   %eax,%eax
je     12a2 <main+0x122>
jmp    128e <main+0x10e>
mov    -0x94(%rbp),%eax
sub    $0x30,%eax
je     12a7 <main+0x127>
jmp    12b3 <main+0x133>
jmp    12ba <main+0x13a>
movl   $0x1,-0x1c(%rbp)
jmp    12ba <main+0x13a>
mov    $0x0,%al
call   10a0 <usage@plt>
jmp    1248 <main+0xc8>
cmpl   $0x0,-0x20(%rbp)
je     12d0 <main+0x150>
mov    $0x0,%al
call   10a0 <usage@plt>
cmpl   $0x0,-0x24(%rbp)
je     12e1 <main+0x161>
mov    $0x0,%al
call   1080 <version@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1300 <main+0x180>
mov    -0x1c(%rbp),%edi
call   1090 <print_env@plt>
jmp    1370 <main+0x1f0>
jmp    1305 <main+0x185>
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    136b <main+0x1eb>
mov    -0x10(%rbp),%rax
mov    0x2cc6(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xcdc(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    1351 <main+0x1d1>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2c90(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2c84(%rip),%rax
mov    %ecx,(%rax)
jmp    1305 <main+0x185>
jmp    1370 <main+0x1f0>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe66(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2e32(%rip),%rax
movslq (%rax),%rax
mov    %rax,0x18(%rsp)
movabs $0x3000000000,%rcx
mov    %rcx,0x20(%rsp)
lea    0xe41(%rip),%rcx
mov    %rcx,0x28(%rsp)
mov    %rax,0x30(%rsp)
lea    0x8(%rsp),%rcx
mov    %ecx,0x38(%rsp)
movl   $0x1,0x3c(%rsp)
lea    0xe24(%rip),%rcx
mov    %rcx,0x40(%rsp)
mov    %rax,0x48(%rsp)
lea    0x4(%rsp),%rax
mov    %eax,0x50(%rsp)
movl   $0x1,0x54(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x58(%rsp)
movq   $0x0,0x68(%rsp)
mov    $0x1,%r14b
lea    0xdf6(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
movl   $0x0,(%rsp)
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <getopt_long@plt>
test   %eax,%eax
je     1230 <main+0xc0>
cmp    $0xffffffff,%eax
je     1266 <main+0xf6>
cmp    $0x30,%eax
je     125a <main+0xea>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    1230 <main+0xc0>
movl   $0x1,(%rsp)
xor    %r14d,%r14d
jmp    1230 <main+0xc0>
cmpl   $0x0,0x8(%rsp)
je     1274 <main+0x104>
xor    %eax,%eax
call   1090 <usage@plt>
cmpl   $0x0,0x4(%rsp)
mov    %r14d,%r12d
je     1285 <main+0x115>
xor    %eax,%eax
call   1070 <version@plt>
mov    0x2d5c(%rip),%r15
mov    (%r15),%eax
cmp    %ebp,%eax
jge    12d5 <main+0x165>
lea    0xd7a(%rip),%r14
jmp    12ad <main+0x13d>
nopl   0x0(%rax)
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
cmp    %ebp,%eax
jge    12dd <main+0x16d>
cltq
mov    (%rbx,%rax,8),%rdi
call   1030 <getenv@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
test   $0x1,%r12b
je     12a0 <main+0x130>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    12a0 <main+0x130>
mov    (%rsp),%edi
call   1080 <print_env@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32*, i32, i32 }
@.str = [5 x i8] c"null\00"
@no_argument = global i32 0
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [8 x i8] c"version\00"
@.str.3 = [2 x i8] c"0\00"
@optind = global i32 0
@.str.4 = [3 x i8] c"%s\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
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%12 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %11, i64 0, i64 0
%13 = getelementptr inbounds %struct.option, %struct.option* %12, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds %struct.option, %struct.option* %12, i32 0, i32 1
%15 = load i32, i32* @no_argument
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %14
%18 = getelementptr inbounds %struct.option, %struct.option* %12, i32 0, i32 2
store i32 0, i32* %18
%19 = getelementptr inbounds %struct.option, %struct.option* %12, i32 0, i32 3
store i32 48, i32* %19
%20 = getelementptr inbounds %struct.option, %struct.option* %12, i64 1
%21 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 1
%23 = load i32, i32* @no_argument
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %22
%26 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 2
%27 = ptrtoint i32* %9 to i32
store i32 %27, i32* %26
%28 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 3
store i32 1, i32* %28
%29 = getelementptr inbounds %struct.option, %struct.option* %20, i64 1
%30 = getelementptr inbounds %struct.option, %struct.option* %29, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds %struct.option, %struct.option* %29, i32 0, i32 1
%32 = load i32, i32* @no_argument
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i32*
store i32* %34, i32** %31
%35 = getelementptr inbounds %struct.option, %struct.option* %29, i32 0, i32 2
%36 = ptrtoint i32* %10 to i32
store i32 %36, i32* %35
%37 = getelementptr inbounds %struct.option, %struct.option* %29, i32 0, i32 3
store i32 1, i32* %37
%38 = getelementptr inbounds %struct.option, %struct.option* %29, i64 1
%39 = bitcast %struct.option* %38 to i8*
br label %40
40: ; preds = %2, %54
%41 = load i32, i32* %4
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %11, i64 0, i64 0
%44 = call i32 @getopt_long(i32 %41, i8** %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %struct.option* %43, i32* %7)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %48
47: ; preds = %40
br label %55
48: ; preds = %40
%49 = load i32, i32* %6
switch i32 %49, label %52 [
i32 0, label %50
i32 48, label %51
]
50: ; preds = %48
br label %54
51: ; preds = %48
store i32 1, i32* %8
br label %54
52: ; preds = %48
%53 = call i32 (...) @usage()
br label %54
54: ; preds = %52, %51, %50
br label %40
55: ; preds = %47
%56 = load i32, i32* %9
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 (...) @usage()
br label %60
60: ; preds = %58, %55
%61 = load i32, i32* %10
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 (...) @version()
br label %65
65: ; preds = %63, %60
%66 = load i32, i32* @optind
%67 = load i32, i32* %4
%68 = icmp sge i32 %66, %67
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i32, i32* %8
%71 = call i32 @print_env(i32 %70)
br label %93
72: ; preds = %65
br label %73
73: ; preds = %89, %72
%74 = load i32, i32* @optind
%75 = load i32, i32* %4
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %92
77: ; preds = %73
%78 = load i8**, i8*** %5
%79 = load i32, i32* @optind
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = call i8* @getenv(i8* %82)
%84 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %83)
%85 = load i32, i32* %8
%86 = icmp ne i32 %85, 0
br i1 %86, label %89, label %87
87: ; preds = %77
%88 = call i32 @putchar(i8 signext 10)
br label %89
89: ; preds = %87, %77
%90 = load i32, i32* @optind
%91 = add nsw i32 %90, 1
store i32 %91, i32* @optind
br label %73
92: ; preds = %73
br label %93
93: ; preds = %92, %69
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i32*, i32, i32 }
@.str = [5 x i8] c"null\00"
@no_argument = global i32 0
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [8 x i8] c"version\00"
@.str.3 = [2 x i8] c"0\00"
@optind = global i32 0
@.str.4 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4 x %struct.option]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%10 = bitcast [4 x %struct.option]* %6 to i8*
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0
%12 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0, i32 1
%14 = load i32, i32* @no_argument
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %13
%17 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0, i32 2
store i32 0, i32* %17
%18 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0, i32 3
store i32 48, i32* %18
%19 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 1, i32 1
store i32* %16, i32** %20
%21 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 1, i32 2
%22 = ptrtoint i32* %4 to i64
%23 = trunc i64 %22 to i32
store i32 %23, i32* %21
%24 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 1, i32 3
store i32 1, i32* %24
%25 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 2, i32 1
store i32* %16, i32** %26
%27 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 2, i32 2
%28 = ptrtoint i32* %5 to i64
%29 = trunc i64 %28 to i32
store i32 %29, i32* %27
%30 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 2, i32 3
store i32 1, i32* %30
%31 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 3
%32 = bitcast %struct.option* %31 to i8*
br label %33
33: ; preds = %36, %2
%34 = phi i1 [ true, %2 ], [ false, %36 ]
%35 = phi i32 [ 0, %2 ], [ 1, %36 ]
br label %36
36: ; preds = %38, %33
%37 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %struct.option* %11, i32* %3)
switch i32 %37, label %39 [
i32 -1, label %41
i32 0, label %38
i32 48, label %33
]
38: ; preds = %36, %39
br label %36
39: ; preds = %36
%40 = call i32 (...) @usage()
br label %38
41: ; preds = %36
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = call i32 (...) @usage()
br label %46
46: ; preds = %44, %41
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 (...) @version()
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* @optind
%53 = icmp slt i32 %52, %0
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = call i32 @print_env(i32 %35)
br label %69
56: ; preds = %51, %65
%57 = phi i32 [ %67, %65 ], [ %52, %51 ]
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = call i8* @getenv(i8* %60)
%62 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %61)
br i1 %34, label %63, label %65
63: ; preds = %56
%64 = call i32 @putchar(i8 signext 10)
br label %65
65: ; preds = %63, %56
%66 = load i32, i32* @optind
%67 = add nsw i32 %66, 1
store i32 %67, i32* @optind
%68 = icmp slt i32 %67, %0
br i1 %68, label %56, label %69
69: ; preds = %65, %54
ret i32 0
}