#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 scalar_t__ uid_t;
typedef scalar_t__ gid_t;

/* Variables and functions */
int NGROUPS_MAX;
char *_PATH_BSHELL;
int chdir(char *);
int chroot(char *);
int /*<<< orphan*/ err(int, char *, ...);
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ execlp(char const *, char const *, char *,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ execvp(char *, char **);
char *getenv(char *);
scalar_t__ getgroup(char *);
int getopt(int, char **, char *);
scalar_t__ getuser(char *);
char *optarg;
scalar_t__ optind;
int setgid(scalar_t__);
int setgroups(int, scalar_t__ *);
int setuid(scalar_t__);
char *strsep(char **, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char *user;
  char *group;
  char *grouplist;
  char *p;
  const char *shell;
  gid_t gid, gidlist[NGROUPS_MAX];
  uid_t uid;
  int ch, gids;
  user = NULL;
  group = NULL;
  grouplist = NULL;
  gid = 0;
  uid = 0;
  gids = 0;
  while ((ch = getopt(argc, argv, "G:g:u:")) != -1) {
    switch (ch) {
    case 'u':
      user = optarg;
      if (*user == '\0')
        usage();
      break;
    case 'g':
      group = optarg;
      if (*group == '\0')
        usage();
      break;
    case 'G':
      grouplist = optarg;
      if (*grouplist == '\0')
        usage();
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  if (argc < 1)
    usage();
  if (user != NULL)
    uid = getuser(user);
  if (group != NULL)
    gid = getgroup(group);
  if (grouplist != NULL) {
    while ((p = strsep(&grouplist, ",")) != NULL) {
      if (*p == '\0')
        continue;
      if (gids == NGROUPS_MAX)
        errx(1, "too many supplementary groups provided");
      gidlist[gids++] = getgroup(p);
    }
  }
  if (chdir(argv[0]) == -1 || chroot(".") == -1)
    err(1, "%s", argv[0]);
  if (gids && setgroups(gids, gidlist) == -1)
    err(1, "setgroups");
  if (group && setgid(gid) == -1)
    err(1, "setgid");
  if (user && setuid(uid) == -1)
    err(1, "setuid");
  if (argv[1]) {
    execvp(argv[1], &argv[1]);
    err(1, "%s", argv[1]);
  }
  if ((shell = getenv("SHELL")) == NULL)
    shell = _PATH_BSHELL;
  execlp(shell, shell, "-i", NULL);
  err(1, "%s", shell);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd90(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x5c(%rbp)
cmp    $0xffffffff,%eax
je     1357 <main+0x167>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x3f,%eax
je     1346 <main+0x156>
jmp    1295 <main+0xa5>
mov    -0x6c(%rbp),%eax
sub    $0x47,%eax
je     131c <main+0x12c>
jmp    12a6 <main+0xb6>
mov    -0x6c(%rbp),%eax
sub    $0x67,%eax
je     12f2 <main+0x102>
jmp    12b7 <main+0xc7>
mov    -0x6c(%rbp),%eax
sub    $0x75,%eax
jne    134b <main+0x15b>
jmp    12c8 <main+0xd8>
mov    0x2d29(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12ed <main+0xfd>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    1352 <main+0x162>
mov    0x2cff(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1317 <main+0x127>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    1352 <main+0x162>
mov    0x2cd5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1341 <main+0x151>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    1352 <main+0x162>
jmp    134b <main+0x15b>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    1262 <main+0x72>
mov    0x2c7a(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2c66(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1392 <main+0x1a2>
mov    $0x0,%al
call   10b0 <usage@plt>
cmpq   $0x0,-0x18(%rbp)
je     13aa <main+0x1ba>
mov    -0x18(%rbp),%rdi
call   10c0 <getuser@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     13c2 <main+0x1d2>
mov    -0x20(%rbp),%rdi
call   10a0 <getgroup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1454 <main+0x264>
jmp    13d2 <main+0x1e2>
lea    -0x28(%rbp),%rdi
lea    0xc2a(%rip),%rsi
call   1090 <strsep@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     144f <main+0x25f>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1405 <main+0x215>
jmp    13d2 <main+0x1e2>
mov    -0x60(%rbp),%eax
mov    0x2bc1(%rip),%rcx
cmp    (%rcx),%eax
jne    1428 <main+0x238>
mov    $0x1,%edi
lea    0xbe6(%rip),%rsi
call   1060 <errx@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <getgroup@plt>
mov    %rax,%rdx
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x60(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    13d2 <main+0x1e2>
jmp    1454 <main+0x264>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <chdir@plt>
cmp    $0xffffffff,%eax
je     147e <main+0x28e>
lea    0xbc0(%rip),%rdi
call   1040 <chroot@plt>
cmp    $0xffffffff,%eax
jne    1498 <main+0x2a8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xba1(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
cmpl   $0x0,-0x60(%rbp)
je     14ca <main+0x2da>
mov    -0x68(%rbp),%rsi
mov    -0x60(%rbp),%edi
call   1070 <setgroups@plt>
cmp    $0xffffffff,%eax
jne    14ca <main+0x2da>
mov    $0x1,%edi
lea    0xb72(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
cmpq   $0x0,-0x20(%rbp)
je     14fa <main+0x30a>
mov    -0x40(%rbp),%rdi
call   10d0 <setgid@plt>
cmp    $0xffffffff,%eax
jne    14fa <main+0x30a>
mov    $0x1,%edi
lea    0xb4c(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
cmpq   $0x0,-0x18(%rbp)
je     152a <main+0x33a>
mov    -0x58(%rbp),%rdi
call   1100 <setuid@plt>
cmp    $0xffffffff,%eax
jne    152a <main+0x33a>
mov    $0x1,%edi
lea    0xb23(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1569 <main+0x379>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   10f0 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    $0x1,%edi
lea    0xad0(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
lea    0xadd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1591 <main+0x3a1>
mov    0x2a56(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x38(%rbp),%rsi
lea    0xab3(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1110 <execlp@plt>
mov    -0x38(%rbp),%rdx
mov    $0x1,%edi
lea    0xa79(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r12
mov    %edi,%r13d
mov    %rsp,-0x60(%rbp)
mov    0x2dbe(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
movq   $0x0,-0x58(%rbp)
lea    0xdc4(%rip),%r15
mov    0x2db5(%rip),%r14
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %ebx,%ebx
jmp    1260 <main+0x70>
xor    %eax,%eax
call   10b0 <usage@plt>
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   10e0 <getopt@plt>
cmp    $0x75,%eax
jne    127d <main+0x8d>
mov    (%r14),%rbx
cmpb   $0x0,(%rbx)
jne    1260 <main+0x70>
jmp    1253 <main+0x63>
cmp    $0xffffffff,%eax
je     12ad <main+0xbd>
cmp    $0x47,%eax
je     1298 <main+0xa8>
cmp    $0x67,%eax
jne    1253 <main+0x63>
mov    (%r14),%rcx
mov    %rcx,%rax
mov    %rcx,-0x38(%rbp)
jmp    12a6 <main+0xb6>
mov    (%r14),%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rax
mov    %rcx,-0x30(%rbp)
cmpb   $0x0,(%rcx)
jne    1260 <main+0x70>
jmp    1253 <main+0x63>
mov    0x2d24(%rip),%rax
mov    (%rax),%r14
sub    %r14d,%r13d
test   %r13d,%r13d
jg     12c6 <main+0xd6>
xor    %eax,%eax
call   10b0 <usage@plt>
test   %rbx,%rbx
mov    -0x38(%rbp),%r15
je     12d9 <main+0xe9>
mov    %rbx,%rdi
call   10c0 <getuser@plt>
jmp    12db <main+0xeb>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
xor    %r13d,%r13d
test   %r15,%r15
je     12f1 <main+0x101>
mov    %r15,%rdi
call   10a0 <getgroup@plt>
jmp    12f3 <main+0x103>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
lea    (%r12,%r14,8),%r14
test   %rax,%rax
je     1375 <main+0x185>
mov    %r14,-0x30(%rbp)
xor    %r13d,%r13d
lea    0xcf5(%rip),%r15
lea    -0x58(%rbp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <strsep@plt>
test   %rax,%rax
je     136d <main+0x17d>
mov    %rax,%r12
cmpb   $0x0,(%rax)
je     1320 <main+0x130>
mov    0x2c91(%rip),%rax
mov    (%rax),%eax
cmp    %rax,%r13
jne    1357 <main+0x167>
mov    $0x1,%edi
lea    0xcb7(%rip),%rsi
call   1060 <errx@plt>
mov    %r12,%rdi
call   10a0 <getgroup@plt>
mov    -0x50(%rbp),%rcx
mov    %rax,(%rcx,%r13,8)
add    $0x1,%r13
jmp    1320 <main+0x130>
mov    -0x38(%rbp),%r15
mov    -0x30(%rbp),%r14
mov    (%r14),%rdi
call   1050 <chdir@plt>
cmp    $0xffffffff,%eax
je     1393 <main+0x1a3>
lea    0xca7(%rip),%rdi
call   1040 <chroot@plt>
cmp    $0xffffffff,%eax
jne    13a9 <main+0x1b9>
mov    (%r14),%rdx
lea    0xc95(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1080 <err@plt>
test   %r13d,%r13d
je     13bf <main+0x1cf>
mov    %r13d,%edi
mov    -0x50(%rbp),%rsi
call   1070 <setgroups@plt>
cmp    $0xffffffff,%eax
je     13e7 <main+0x1f7>
test   %r15,%r15
je     13ff <main+0x20f>
mov    -0x40(%rbp),%rdi
call   10d0 <setgid@plt>
cmp    $0xffffffff,%eax
jne    13ff <main+0x20f>
lea    0xc66(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1080 <err@plt>
jmp    13ff <main+0x20f>
lea    0xc47(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1080 <err@plt>
test   %r15,%r15
jne    13c4 <main+0x1d4>
test   %rbx,%rbx
je     1425 <main+0x235>
mov    -0x48(%rbp),%rdi
call   1100 <setuid@plt>
cmp    $0xffffffff,%eax
jne    1425 <main+0x235>
lea    0xc2d(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1080 <err@plt>
mov    0x8(%r14),%rdi
test   %rdi,%rdi
je     1450 <main+0x260>
add    $0x8,%r14
mov    %r14,%rsi
call   10f0 <execvp@plt>
mov    (%r14),%rdx
lea    0xbee(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1080 <err@plt>
lea    0xbf6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    146e <main+0x27e>
mov    0x2b75(%rip),%rax
mov    (%rax),%rbx
lea    0xbde(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1110 <execlp@plt>
lea    0xba9(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <err@plt>
mov    -0x60(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NGROUPS_MAX = global i32 0
@.str = [7 x i8] c"G:g:u:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.1 = [2 x i8] c",\00"
@.str.2 = [39 x i8] c"too many supplementary groups provided\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [10 x i8] c"setgroups\00"
@.str.6 = [7 x i8] c"setgid\00"
@.str.7 = [7 x i8] c"setuid\00"
@.str.8 = [6 x i8] c"SHELL\00"
@_PATH_BSHELL = global i8* null
@.str.9 = [3 x i8] c"-i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* @NGROUPS_MAX
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %12
%20 = alloca i64, i64 %18
store i64 %18, i64* %13
store i8* null, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i64 0, i64* %11
store i64 0, i64* %14
store i32 0, i32* %16
br label %21
21: ; preds = %58, %2
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %24, i32* %15
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %59
26: ; preds = %21
%27 = load i32, i32* %15
switch i32 %27, label %56 [
i32 117, label %28
i32 103, label %37
i32 71, label %46
i32 63, label %55
]
28: ; preds = %26
%29 = load i8*, i8** @optarg
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (...) @usage()
br label %36
36: ; preds = %34, %28
br label %58
37: ; preds = %26
%38 = load i8*, i8** @optarg
store i8* %38, i8** %7
%39 = load i8*, i8** %7
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 (...) @usage()
br label %45
45: ; preds = %43, %37
br label %58
46: ; preds = %26
%47 = load i8*, i8** @optarg
store i8* %47, i8** %8
%48 = load i8*, i8** %8
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = call i32 (...) @usage()
br label %54
54: ; preds = %52, %46
br label %58
55: ; preds = %26
br label %56
56: ; preds = %26, %55
%57 = call i32 (...) @usage()
br label %58
58: ; preds = %56, %54, %45, %36
br label %21
59: ; preds = %21
%60 = load i64, i64* @optind
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = sub nsw i64 %62, %60
%64 = trunc i64 %63 to i32
store i32 %64, i32* %4
%65 = load i64, i64* @optind
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 %65
store i8** %67, i8*** %5
%68 = load i32, i32* %4
%69 = icmp slt i32 %68, 1
br i1 %69, label %70, label %72
70: ; preds = %59
%71 = call i32 (...) @usage()
br label %72
72: ; preds = %70, %59
%73 = load i8*, i8** %6
%74 = icmp ne i8* %73, null
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = load i8*, i8** %6
%77 = call i64 @getuser(i8* %76)
store i64 %77, i64* %14
br label %78
78: ; preds = %75, %72
%79 = load i8*, i8** %7
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = load i8*, i8** %7
%83 = call i64 @getgroup(i8* %82)
store i64 %83, i64* %11
br label %84
84: ; preds = %81, %78
%85 = load i8*, i8** %8
%86 = icmp ne i8* %85, null
br i1 %86, label %87, label %111
87: ; preds = %84
br label %88
88: ; preds = %103, %96, %87
%89 = call i8* @strsep(i8** %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %89, i8** %9
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %110
91: ; preds = %88
%92 = load i8*, i8** %9
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %97
96: ; preds = %91
br label %88
97: ; preds = %91
%98 = load i32, i32* %16
%99 = load i32, i32* @NGROUPS_MAX
%100 = icmp eq i32 %98, %99
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = call i32 @errx(i32 1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %103
103: ; preds = %101, %97
%104 = load i8*, i8** %9
%105 = call i64 @getgroup(i8* %104)
%106 = load i32, i32* %16
%107 = add nsw i32 %106, 1
store i32 %107, i32* %16
%108 = sext i32 %106 to i64
%109 = getelementptr inbounds i64, i64* %20, i64 %108
store i64 %105, i64* %109
br label %88
110: ; preds = %88
br label %111
111: ; preds = %110, %84
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 0
%114 = load i8*, i8** %113
%115 = call i32 @chdir(i8* %114)
%116 = icmp eq i32 %115, -1
br i1 %116, label %120, label %117
117: ; preds = %111
%118 = call i32 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %125
120: ; preds = %117, %111
%121 = load i8**, i8*** %5
%122 = getelementptr inbounds i8*, i8** %121, i64 0
%123 = load i8*, i8** %122
%124 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %123)
br label %125
125: ; preds = %120, %117
%126 = load i32, i32* %16
%127 = icmp ne i32 %126, 0
br i1 %127, label %128, label %134
128: ; preds = %125
%129 = load i32, i32* %16
%130 = call i32 @setgroups(i32 %129, i64* %20)
%131 = icmp eq i32 %130, -1
br i1 %131, label %132, label %134
132: ; preds = %128
%133 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %134
134: ; preds = %132, %128, %125
%135 = load i8*, i8** %7
%136 = icmp ne i8* %135, null
br i1 %136, label %137, label %143
137: ; preds = %134
%138 = load i64, i64* %11
%139 = call i32 @setgid(i64 %138)
%140 = icmp eq i32 %139, -1
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %143
143: ; preds = %141, %137, %134
%144 = load i8*, i8** %6
%145 = icmp ne i8* %144, null
br i1 %145, label %146, label %152
146: ; preds = %143
%147 = load i64, i64* %14
%148 = call i32 @setuid(i64 %147)
%149 = icmp eq i32 %148, -1
br i1 %149, label %150, label %152
150: ; preds = %146
%151 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %152
152: ; preds = %150, %146, %143
%153 = load i8**, i8*** %5
%154 = getelementptr inbounds i8*, i8** %153, i64 1
%155 = load i8*, i8** %154
%156 = icmp ne i8* %155, null
br i1 %156, label %157, label %168
157: ; preds = %152
%158 = load i8**, i8*** %5
%159 = getelementptr inbounds i8*, i8** %158, i64 1
%160 = load i8*, i8** %159
%161 = load i8**, i8*** %5
%162 = getelementptr inbounds i8*, i8** %161, i64 1
%163 = call i32 @execvp(i8* %160, i8** %162)
%164 = load i8**, i8*** %5
%165 = getelementptr inbounds i8*, i8** %164, i64 1
%166 = load i8*, i8** %165
%167 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %166)
br label %168
168: ; preds = %157, %152
%169 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
store i8* %169, i8** %10
%170 = icmp eq i8* %169, null
br i1 %170, label %171, label %173
171: ; preds = %168
%172 = load i8*, i8** @_PATH_BSHELL
store i8* %172, i8** %10
br label %173
173: ; preds = %171, %168
%174 = load i8*, i8** %10
%175 = load i8*, i8** %10
%176 = call i32 @execlp(i8* %174, i8* %175, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* null)
%177 = load i8*, i8** %10
%178 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %177)
%179 = load i8*, i8** %12
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
@NGROUPS_MAX = global i32 0
@.str = [7 x i8] c"G:g:u:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.1 = [2 x i8] c",\00"
@.str.2 = [39 x i8] c"too many supplementary groups provided\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [10 x i8] c"setgroups\00"
@.str.6 = [7 x i8] c"setgid\00"
@.str.7 = [7 x i8] c"setuid\00"
@.str.8 = [6 x i8] c"SHELL\00"
@_PATH_BSHELL = global i8* null
@.str.9 = [3 x i8] c"-i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i32, i32* @NGROUPS_MAX
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i64, i64 %6
store i8* null, i8** %3
br label %9
9: ; preds = %31, %2
%10 = phi i8* [ null, %2 ], [ %32, %31 ]
%11 = phi i8* [ null, %2 ], [ %33, %31 ]
%12 = phi i8* [ null, %2 ], [ %34, %31 ]
br label %13
13: ; preds = %9, %23
%14 = phi i8* [ %11, %9 ], [ %24, %23 ]
%15 = phi i8* [ %12, %9 ], [ %17, %23 ]
br label %16
16: ; preds = %13, %19
%17 = phi i8* [ %20, %19 ], [ %15, %13 ]
%18 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %18, label %35 [
i32 -1, label %40
i32 117, label %19
i32 103, label %23
i32 71, label %27
]
19: ; preds = %16
%20 = load i8*, i8** @optarg
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %35, label %16
23: ; preds = %16
%24 = load i8*, i8** @optarg
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %35, label %13
27: ; preds = %16
%28 = load i8*, i8** @optarg
store i8* %28, i8** %3
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27, %35
%32 = phi i8* [ %36, %35 ], [ %28, %27 ]
%33 = phi i8* [ %37, %35 ], [ %14, %27 ]
%34 = phi i8* [ %38, %35 ], [ %17, %27 ]
br label %9
35: ; preds = %16, %19, %23, %27
%36 = phi i8* [ %28, %27 ], [ %10, %23 ], [ %10, %19 ], [ %10, %16 ]
%37 = phi i8* [ %14, %27 ], [ %14, %16 ], [ %14, %19 ], [ %24, %23 ]
%38 = phi i8* [ %17, %27 ], [ %20, %19 ], [ %17, %16 ], [ %17, %23 ]
%39 = tail call i32 (...) @usage()
br label %31
40: ; preds = %16
%41 = load i64, i64* @optind
%42 = trunc i64 %41 to i32
%43 = sub i32 %0, %42
%44 = getelementptr inbounds i8*, i8** %1, i64 %41
%45 = icmp slt i32 %43, 1
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = tail call i32 (...) @usage()
br label %48
48: ; preds = %46, %40
%49 = icmp eq i8* %17, null
br i1 %49, label %52, label %50
50: ; preds = %48
%51 = tail call i64 @getuser(i8* %17)
br label %52
52: ; preds = %50, %48
%53 = phi i64 [ %51, %50 ], [ 0, %48 ]
%54 = icmp eq i8* %14, null
br i1 %54, label %57, label %55
55: ; preds = %52
%56 = tail call i64 @getgroup(i8* %14)
br label %57
57: ; preds = %55, %52
%58 = phi i64 [ %56, %55 ], [ 0, %52 ]
%59 = icmp eq i8* %10, null
br i1 %59, label %80, label %60
60: ; preds = %57, %74
%61 = phi i64 [ %76, %74 ], [ 0, %57 ]
br label %62
62: ; preds = %60, %65
%63 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp eq i8* %63, null
br i1 %64, label %78, label %65
65: ; preds = %62
%66 = load i8, i8* %63
%67 = icmp eq i8 %66, 0
br i1 %67, label %62, label %68
68: ; preds = %65
%69 = load i32, i32* @NGROUPS_MAX
%70 = zext i32 %69 to i64
%71 = icmp eq i64 %61, %70
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 @errx(i32 1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %74
74: ; preds = %72, %68
%75 = call i64 @getgroup(i8* %63)
%76 = add nuw i64 %61, 1
%77 = getelementptr inbounds i64, i64* %8, i64 %61
store i64 %75, i64* %77
br label %60
78: ; preds = %62
%79 = trunc i64 %61 to i32
br label %80
80: ; preds = %78, %57
%81 = phi i32 [ 0, %57 ], [ %79, %78 ]
%82 = load i8*, i8** %44
%83 = call i32 @chdir(i8* %82)
%84 = icmp eq i32 %83, -1
br i1 %84, label %88, label %85
85: ; preds = %80
%86 = call i32 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %91
88: ; preds = %85, %80
%89 = load i8*, i8** %44
%90 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %89)
br label %91
91: ; preds = %88, %85
%92 = icmp eq i32 %81, 0
br i1 %92, label %98, label %93
93: ; preds = %91
%94 = call i32 @setgroups(i32 %81, i64* %8)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %93
%97 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %98
98: ; preds = %96, %93, %91
br i1 %54, label %104, label %99
99: ; preds = %98
%100 = call i32 @setgid(i64 %58)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %104
102: ; preds = %99
%103 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %104
104: ; preds = %102, %99, %98
br i1 %49, label %110, label %105
105: ; preds = %104
%106 = call i32 @setuid(i64 %53)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %110
110: ; preds = %108, %105, %104
%111 = getelementptr inbounds i8*, i8** %44, i64 1
%112 = load i8*, i8** %111
%113 = icmp eq i8* %112, null
br i1 %113, label %118, label %114
114: ; preds = %110
%115 = call i32 @execvp(i8* %112, i8** %111)
%116 = load i8*, i8** %111
%117 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %116)
br label %118
118: ; preds = %114, %110
%119 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%120 = icmp eq i8* %119, null
%121 = load i8*, i8** @_PATH_BSHELL
%122 = select i1 %120, i8* %121, i8* %119
%123 = call i32 @execlp(i8* %122, i8* %122, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* null)
%124 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %122)
ret i32 0
}