#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 */
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork_command(int, int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_command_from_argv(int /*<<< orphan*/, int, char **,
                                         char *, char *);
int getopt(int, char **, char *);
scalar_t__ getuid();
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ optind;
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  char gid_string[5] = "";
  gid_t gid;
  int c;
  char command[4096] = "";
  char llstat_file[100] = "";
  if (getuid()) {
    fprintf(stderr, "Error: You need to be root\n");
    exit(1);
  }
  opterr = 0;
  while ((c = getopt(argc, argv, "l:g:c:i:a:h")) != 1)
    switch (c) {
    case 'l':
      strcpy(llstat_file, optarg);
      if (strlen(llstat_file) > 1024) {
        fprintf(stderr, "length of outfile file"
                        " is too long\n");
        exit(1);
      }
      break;
    case 'g':
      strcpy(gid_string, optarg);
      get_command_from_argv(optind, argc, argv, "", command);
      gid = atoi(gid_string);
      fork_command(0, gid, command, llstat_file);
      return (0);
    case 'c':
      get_command_from_argv(optind, argc, argv, optarg, command);
      fork_command(1, 0, command, llstat_file);
      return (0);
    case 'i':
      get_command_from_argv(optind, argc, argv, optarg, command);
      fork_command(2, 0, command, llstat_file);
      return (0);
    case 'a':
      get_command_from_argv(optind, argc, argv, optarg, command);
      fork_command(3, 0, command, llstat_file);
      return (0);
    case 'h':
      print_usage();
      return (0);
    default:
      print_usage();
      return (1);
    }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x15(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1070 <memset@plt>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1070 <memset@plt>
lea    -0x1090(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
mov    $0x0,%al
call   1050 <getuid@plt>
cmp    $0x0,%rax
je     122f <main+0x7f>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d92(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe01(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x1,%eax
je     1451 <main+0x2a1>
mov    -0x20(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x1098(%rbp)
sub    $0xb,%eax
ja     1439 <main+0x289>
mov    -0x1098(%rbp),%rax
lea    0xd7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x1090(%rbp),%rdi
mov    0x2d5f(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x1090(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x400,%eax
jle    12d7 <main+0x127>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    144c <main+0x29c>
lea    -0x15(%rbp),%rdi
mov    0x2d11(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    -0x1020(%rbp),%r8
lea    0xd6e(%rip),%rcx
call   1060 <get_command_from_argv@plt>
lea    -0x15(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    -0x1020(%rbp),%rdx
lea    -0x1090(%rbp),%rcx
xor    %edi,%edi
call   1090 <fork_command@plt>
movl   $0x0,-0x4(%rbp)
jmp    1458 <main+0x2a8>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    0x2c9f(%rip),%rax
mov    (%rax),%rcx
lea    -0x1020(%rbp),%r8
call   1060 <get_command_from_argv@plt>
lea    -0x1020(%rbp),%rdx
lea    -0x1090(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <fork_command@plt>
movl   $0x0,-0x4(%rbp)
jmp    1458 <main+0x2a8>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    0x2c53(%rip),%rax
mov    (%rax),%rcx
lea    -0x1020(%rbp),%r8
call   1060 <get_command_from_argv@plt>
lea    -0x1020(%rbp),%rdx
lea    -0x1090(%rbp),%rcx
mov    $0x2,%edi
xor    %esi,%esi
call   1090 <fork_command@plt>
movl   $0x0,-0x4(%rbp)
jmp    1458 <main+0x2a8>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    0x2c07(%rip),%rax
mov    (%rax),%rcx
lea    -0x1020(%rbp),%r8
call   1060 <get_command_from_argv@plt>
lea    -0x1020(%rbp),%rdx
lea    -0x1090(%rbp),%rcx
mov    $0x3,%edi
xor    %esi,%esi
call   1090 <fork_command@plt>
movl   $0x0,-0x4(%rbp)
jmp    1458 <main+0x2a8>
mov    $0x0,%al
call   10d0 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1458 <main+0x2a8>
mov    $0x0,%al
call   10d0 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1458 <main+0x2a8>
jmp    123d <main+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1080,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x80(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1070 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
xor    %eax,%eax
call   1050 <getuid@plt>
test   %rax,%rax
jne    13cc <main+0x21c>
mov    0x2da2(%rip),%rax
movq   $0x0,(%rax)
lea    0xe0c(%rip),%rbx
mov    0x2dbd(%rip),%r12
lea    0x10(%rsp),%rbp
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10a0 <getopt@plt>
cmp    $0x6c,%eax
jne    128d <main+0xdd>
mov    (%r12),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    $0x401,%eax
jl     1240 <main+0x90>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x61(%rax),%ecx
cmp    $0x8,%ecx
ja     12d9 <main+0x129>
lea    0xd64(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rcx
lea    0x80(%rsp),%rbp
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbp,%r8
call   1060 <get_command_from_argv@plt>
xor    %ebx,%ebx
lea    0x10(%rsp),%rcx
mov    $0x3,%edi
jmp    13b0 <main+0x200>
cmp    $0x1,%eax
jne    12e5 <main+0x135>
xor    %ebx,%ebx
jmp    13ba <main+0x20a>
xor    %eax,%eax
call   10d0 <print_usage@plt>
mov    $0x1,%ebx
jmp    13ba <main+0x20a>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rcx
lea    0x80(%rsp),%rbp
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbp,%r8
call   1060 <get_command_from_argv@plt>
xor    %ebx,%ebx
lea    0x10(%rsp),%rcx
mov    $0x1,%edi
jmp    13b0 <main+0x200>
mov    (%r12),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
lea    0xd24(%rip),%rcx
lea    0x80(%rsp),%rbp
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbp,%r8
call   1060 <get_command_from_argv@plt>
mov    %rbx,%rdi
call   10b0 <atoi@plt>
xor    %ebx,%ebx
lea    0x10(%rsp),%rcx
xor    %edi,%edi
mov    %eax,%esi
jmp    13b2 <main+0x202>
xor    %ebx,%ebx
xor    %eax,%eax
call   10d0 <print_usage@plt>
jmp    13ba <main+0x20a>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rcx
lea    0x80(%rsp),%rbp
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbp,%r8
call   1060 <get_command_from_argv@plt>
xor    %ebx,%ebx
lea    0x10(%rsp),%rcx
mov    $0x2,%edi
xor    %esi,%esi
mov    %rbp,%rdx
call   1090 <fork_command@plt>
mov    %ebx,%eax
add    $0x1080,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xc48(%rip),%rsi
jmp    127e <main+0xce>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Error: You need to be root\0A\00"
@opterr = global i64 0
@.str.1 = [12 x i8] c"l:g:c:i:a:h\00"
@optarg = global i8* null
@.str.2 = [36 x i8] c"length of outfile file is too long\0A\00"
@optind = global i32 0
@.str.3 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4096 x i8]
%10 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [5 x i8]* %6 to i8*
%12 = bitcast [4096 x i8]* %9 to i8*
%13 = bitcast [100 x i8]* %10 to i8*
%14 = call i64 (...) @getuid()
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
store i64 0, i64* @opterr
br label %21
21: ; preds = %89, %20
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 %24, i32* %8
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %90
26: ; preds = %21
%27 = load i32, i32* %8
switch i32 %27, label %87 [
i32 108, label %28
i32 103, label %40
i32 99, label %55
i32 105, label %65
i32 97, label %75
i32 104, label %85
]
28: ; preds = %26
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%30 = load i8*, i8** @optarg
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = icmp sgt i32 %33, 1024
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %28
br label %89
40: ; preds = %26
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%42 = load i8*, i8** @optarg
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i32, i32* @optind
%45 = load i32, i32* %4
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%48 = call i32 @get_command_from_argv(i32 %44, i32 %45, i8** %46, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %7
%51 = load i32, i32* %7
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%54 = call i32 @fork_command(i32 0, i32 %51, i8* %52, i8* %53)
store i32 0, i32* %3
br label %91
55: ; preds = %26
%56 = load i32, i32* @optind
%57 = load i32, i32* %4
%58 = load i8**, i8*** %5
%59 = load i8*, i8** @optarg
%60 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%61 = call i32 @get_command_from_argv(i32 %56, i32 %57, i8** %58, i8* %59, i8* %60)
%62 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%63 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%64 = call i32 @fork_command(i32 1, i32 0, i8* %62, i8* %63)
store i32 0, i32* %3
br label %91
65: ; preds = %26
%66 = load i32, i32* @optind
%67 = load i32, i32* %4
%68 = load i8**, i8*** %5
%69 = load i8*, i8** @optarg
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%71 = call i32 @get_command_from_argv(i32 %66, i32 %67, i8** %68, i8* %69, i8* %70)
%72 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%73 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%74 = call i32 @fork_command(i32 2, i32 0, i8* %72, i8* %73)
store i32 0, i32* %3
br label %91
75: ; preds = %26
%76 = load i32, i32* @optind
%77 = load i32, i32* %4
%78 = load i8**, i8*** %5
%79 = load i8*, i8** @optarg
%80 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%81 = call i32 @get_command_from_argv(i32 %76, i32 %77, i8** %78, i8* %79, i8* %80)
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%83 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%84 = call i32 @fork_command(i32 3, i32 0, i8* %82, i8* %83)
store i32 0, i32* %3
br label %91
85: ; preds = %26
%86 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %91
87: ; preds = %26
%88 = call i32 (...) @print_usage()
store i32 1, i32* %3
br label %91
89: ; preds = %39
br label %21
90: ; preds = %21
store i32 0, i32* %3
br label %91
91: ; preds = %90, %87, %85, %75, %65, %55, %40
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Error: You need to be root\0A\00"
@opterr = global i64 0
@.str.1 = [12 x i8] c"l:g:c:i:a:h\00"
@optarg = global i8* null
@.str.2 = [36 x i8] c"length of outfile file is too long\0A\00"
@optind = global i32 0
@.str.3 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [5 x i8]
%4 = alloca [4096 x i8]
%5 = alloca [100 x i8]
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%9 = tail call i64 (...) @getuid()
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i64 0, i64* @opterr
br label %16
16: ; preds = %18, %15
%17 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
switch i32 %17, label %51 [
i32 1, label %53
i32 108, label %18
i32 103, label %27
i32 99, label %34
i32 105, label %39
i32 97, label %44
i32 104, label %49
]
18: ; preds = %16
%19 = load i8*, i8** @optarg
%20 = call i32 @strcpy(i8* %8, i8* %19)
%21 = call i32 @strlen(i8* %8)
%22 = icmp sgt i32 %21, 1024
br i1 %22, label %23, label %16
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %16
%28 = load i8*, i8** @optarg
%29 = call i32 @strcpy(i8* %6, i8* %28)
%30 = load i32, i32* @optind
%31 = call i32 @get_command_from_argv(i32 %30, i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%32 = call i32 @atoi(i8* %6)
%33 = call i32 @fork_command(i32 0, i32 %32, i8* %7, i8* %8)
br label %53
34: ; preds = %16
%35 = load i32, i32* @optind
%36 = load i8*, i8** @optarg
%37 = call i32 @get_command_from_argv(i32 %35, i32 %0, i8** %1, i8* %36, i8* %7)
%38 = call i32 @fork_command(i32 1, i32 0, i8* %7, i8* %8)
br label %53
39: ; preds = %16
%40 = load i32, i32* @optind
%41 = load i8*, i8** @optarg
%42 = call i32 @get_command_from_argv(i32 %40, i32 %0, i8** %1, i8* %41, i8* %7)
%43 = call i32 @fork_command(i32 2, i32 0, i8* %7, i8* %8)
br label %53
44: ; preds = %16
%45 = load i32, i32* @optind
%46 = load i8*, i8** @optarg
%47 = call i32 @get_command_from_argv(i32 %45, i32 %0, i8** %1, i8* %46, i8* %7)
%48 = call i32 @fork_command(i32 3, i32 0, i8* %7, i8* %8)
br label %53
49: ; preds = %16
%50 = call i32 (...) @print_usage()
br label %53
51: ; preds = %16
%52 = call i32 (...) @print_usage()
br label %53
53: ; preds = %16, %51, %49, %44, %39, %34, %27
%54 = phi i32 [ 1, %51 ], [ 0, %49 ], [ 0, %44 ], [ 0, %39 ], [ 0, %34 ], [ 0, %27 ], [ 0, %16 ]
ret i32 %54
}