#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*/ _export_do(char *);
int /*<<< orphan*/ _export_list();
int _export_usage();
int /*<<< orphan*/ _getopt_reset(int, char **);
int getopt(int, char **, char *);
int optind;
int builtin_export(int argc, char *argv[]) {
  int prefs = 0;
  int o;
  int i;
  _getopt_reset(argc, argv);
  while ((o = getopt(argc, argv, "p")) != -1)
    switch (o) {
    case 'p':
      prefs = 1;
      break;
    default:
      return _export_usage();
    }
  if (prefs == 1 && optind == argc)
    _export_list();
  else if (prefs == 1 || optind == argc)
    return _export_usage();
  else
    for (i = optind; i < argc; i++)
      _export_do(argv[i]);
  return 0;
}


x86 assembly (clang, -O0):
<builtin_export>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <_getopt_reset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11c2 <builtin_export+0x72>
mov    -0x18(%rbp),%eax
sub    $0x70,%eax
jne    11ae <builtin_export+0x5e>
jmp    11a2 <builtin_export+0x52>
movl   $0x1,-0x14(%rbp)
jmp    11bd <builtin_export+0x6d>
mov    $0x0,%al
call   1060 <_export_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    125d <builtin_export+0x10d>
jmp    1172 <builtin_export+0x22>
cmpl   $0x1,-0x14(%rbp)
jne    11ea <builtin_export+0x9a>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    11ea <builtin_export+0x9a>
mov    $0x0,%al
call   1030 <_export_list@plt>
jmp    1256 <builtin_export+0x106>
cmpl   $0x1,-0x14(%rbp)
je     1206 <builtin_export+0xb6>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1215 <builtin_export+0xc5>
mov    $0x0,%al
call   1060 <_export_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    125d <builtin_export+0x10d>
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124c <builtin_export+0xfc>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <_export_do@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1221 <builtin_export+0xd1>
jmp    1251 <builtin_export+0x101>
jmp    1256 <builtin_export+0x106>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_export>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r14d
call   1050 <_getopt_reset@plt>
xor    %ecx,%ecx
lea    0xe94(%rip),%r15
nopl   0x0(%rax)
mov    %ecx,%ebx
mov    %r14d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
mov    $0x1,%cl
cmp    $0x70,%eax
je     1170 <builtin_export+0x20>
cmp    $0xffffffff,%eax
jne    11b9 <builtin_export+0x69>
mov    0x2e55(%rip),%rax
movslq (%rax),%rax
cmp    %r14d,%eax
sete   %cl
and    %bl,%cl
cmp    $0x1,%cl
jne    11ac <builtin_export+0x5c>
xor    %eax,%eax
call   1030 <_export_list@plt>
jmp    11f2 <builtin_export+0xa2>
cmp    %r14d,%eax
sete   %cl
or     %cl,%bl
test   $0x1,%bl
je     11cb <builtin_export+0x7b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <_export_usage@plt>
cmp    %r14d,%eax
jge    11f2 <builtin_export+0xa2>
lea    (%r12,%rax,8),%r15
sub    %eax,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
call   1040 <_export_do@plt>
add    $0x1,%rbx
cmp    %ebx,%r14d
jne    11e0 <builtin_export+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"p\00"
@optind = global i32 0
define i32 @builtin_export(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* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @_getopt_reset(i32 %9, i8** %10)
br label %12
12: ; preds = %22, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %7
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i32, i32* %7
switch i32 %18, label %20 [
i32 112, label %19
]
19: ; preds = %17
store i32 1, i32* %6
br label %22
20: ; preds = %17
%21 = call i32 (...) @_export_usage()
store i32 %21, i32* %3
br label %60
22: ; preds = %19
br label %12
23: ; preds = %12
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* @optind
%28 = load i32, i32* %4
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (...) @_export_list()
br label %59
32: ; preds = %26, %23
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 1
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = load i32, i32* @optind
%37 = load i32, i32* %4
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35, %32
%40 = call i32 (...) @_export_usage()
store i32 %40, i32* %3
br label %60
41: ; preds = %35
%42 = load i32, i32* @optind
store i32 %42, i32* %8
br label %43
43: ; preds = %54, %41
%44 = load i32, i32* %8
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %57
47: ; preds = %43
%48 = load i8**, i8*** %5
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @_export_do(i8* %52)
br label %54
54: ; preds = %47
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %43
57: ; preds = %43
br label %58
58: ; preds = %57
br label %59
59: ; preds = %58, %30
store i32 0, i32* %3
br label %60
60: ; preds = %59, %39, %20
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str = [2 x i8] c"p\00"
@optind = global i32 0
define i32 @builtin_export(i32 %0, i8** %1) {
%3 = tail call i32 @_getopt_reset(i32 %0, i8** %1)
br label %4
4: ; preds = %4, %2
%5 = phi i1 [ false, %2 ], [ true, %4 ]
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %7 [
i32 -1, label %9
i32 112, label %4
]
7: ; preds = %4
%8 = tail call i32 (...) @_export_usage()
br label %31
9: ; preds = %4
%10 = load i32, i32* @optind
%11 = icmp eq i32 %10, %0
%12 = select i1 %5, i1 %11, i1 false
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 (...) @_export_list()
br label %31
15: ; preds = %9
%16 = select i1 %5, i1 true, i1 %11
br i1 %16, label %21, label %17
17: ; preds = %15
%18 = icmp slt i32 %10, %0
br i1 %18, label %19, label %31
19: ; preds = %17
%20 = sext i32 %10 to i64
br label %23
21: ; preds = %15
%22 = tail call i32 (...) @_export_usage()
br label %31
23: ; preds = %19, %23
%24 = phi i64 [ %20, %19 ], [ %28, %23 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 @_export_do(i8* %26)
%28 = add nsw i64 %24, 1
%29 = trunc i64 %28 to i32
%30 = icmp eq i32 %29, %0
br i1 %30, label %31, label %23
31: ; preds = %23, %17, %13, %21, %7
%32 = phi i32 [ %8, %7 ], [ %22, %21 ], [ 0, %13 ], [ 0, %17 ], [ 0, %23 ]
ret i32 %32
}