#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 char *uid_t;
struct passwd {
  int pw_gid;
  int pw_uid;
  int /*<<< orphan*/ pw_name;
};
typedef int /*<<< orphan*/ sg;
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int /*<<< orphan*/ _SC_GETPW_R_SIZE_MAX;
int /*<<< orphan*/ err_exit(char *);
int /*<<< orphan*/ errn_exit(int, char *, char *);
scalar_t__ errno;
int /*<<< orphan*/ free(char *);
int getgrouplist(int /*<<< orphan*/, int, int /*<<< orphan*/ *, int *);
int getpwnam_r(char *, struct passwd *, char *, int, struct passwd **);
int getpwuid_r(char *, struct passwd *, char *, int, struct passwd **);
char *malloc(int);
int /*<<< orphan*/ msg_exit(char *, ...);
scalar_t__ setgroups(int, int /*<<< orphan*/ *);
scalar_t__ setregid(int, int);
scalar_t__ setreuid(int, int);
char *strtoul(char *, char **, int);
int sysconf(int /*<<< orphan*/);
void _become_user(char *name, uid_t uid, int realtoo) {
  int err;
  struct passwd pw, *pwd;
  int len = sysconf(_SC_GETPW_R_SIZE_MAX);
  char *buf;
  int nsg;
  gid_t sg[64];
  char *endptr;
  if (len == -1)
    len = 4096;
  if (!(buf = malloc(len)))
    msg_exit("out of memory");
  if (name) {
    errno = 0;
    uid = strtoul(name, &endptr, 10);
    if (errno == 0 && *name != '\0' && *endptr == '\0')
      name = NULL;
  }
  if (name) {
    if ((err = getpwnam_r(name, &pw, buf, len, &pwd)) != 0)
      errn_exit(err, "error looking up user %s", name);
    if (!pwd)
      msg_exit("error looking up user %s", name);
  } else {
    if ((err = getpwuid_r(uid, &pw, buf, len, &pwd)) != 0)
      errn_exit(err, "error looking up uid %d", uid);
    if (!pwd)
      msg_exit("error looking up uid %d", uid);
  }
  nsg = sizeof(sg) / sizeof(sg[0]);
  if (getgrouplist(pwd->pw_name, pwd->pw_gid, sg, &nsg) == -1)
    err_exit("user is in too many groups");
  if (setgroups(nsg, sg) < 0)
    err_exit("setgroups");
  if (setregid(realtoo ? pwd->pw_gid : -1, pwd->pw_gid) < 0)
    err_exit("setreuid");
  if (setreuid(realtoo ? pwd->pw_uid : -1, pwd->pw_uid) < 0)
    err_exit("setreuid");
  free(buf);
}


x86 assembly (clang, -O0):
<_become_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1208 <_become_user+0x38>
movl   $0x1000,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    122c <_become_user+0x5c>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1070 <msg_exit@plt>
cmpq   $0x0,-0x8(%rbp)
je     129f <_become_user+0xcf>
mov    0x2d9a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x158(%rbp),%rsi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %rax,-0x10(%rbp)
mov    0x2d73(%rip),%rax
cmpq   $0x0,(%rax)
jne    129a <_become_user+0xca>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     129a <_become_user+0xca>
mov    -0x158(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    129a <_become_user+0xca>
movq   $0x0,-0x8(%rbp)
jmp    129f <_become_user+0xcf>
cmpq   $0x0,-0x8(%rbp)
je     1303 <_become_user+0x133>
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%r8
call   10c0 <getpwnam_r@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     12e1 <_become_user+0x111>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%rdx
lea    0xd32(%rip),%rsi
call   1030 <errn_exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12fe <_become_user+0x12e>
mov    -0x8(%rbp),%rsi
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1070 <msg_exit@plt>
jmp    135c <_become_user+0x18c>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%r8
call   1050 <getpwuid_r@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     133a <_become_user+0x16a>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xcf2(%rip),%rsi
call   1030 <errn_exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    1357 <_become_user+0x187>
mov    -0x10(%rbp),%rsi
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1070 <msg_exit@plt>
jmp    135c <_become_user+0x18c>
movl   $0x40,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    -0x150(%rbp),%rdx
lea    -0x44(%rbp),%rcx
call   10d0 <getgrouplist@plt>
cmp    $0xffffffff,%eax
jne    1395 <_become_user+0x1c5>
lea    0xcaf(%rip),%rdi
call   1090 <err_exit@plt>
mov    -0x44(%rbp),%edi
lea    -0x150(%rbp),%rsi
call   1060 <setgroups@plt>
cmp    $0x0,%rax
jge    13ba <_become_user+0x1ea>
lea    0xca5(%rip),%rdi
call   1090 <err_exit@plt>
cmpl   $0x0,-0x14(%rbp)
je     13d5 <_become_user+0x205>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x15c(%rbp)
jmp    13e5 <_become_user+0x215>
mov    $0xffffffff,%eax
mov    %eax,-0x15c(%rbp)
jmp    13e5 <_become_user+0x215>
mov    -0x15c(%rbp),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
call   10b0 <setregid@plt>
cmp    $0x0,%rax
jge    140c <_become_user+0x23c>
lea    0xc5d(%rip),%rdi
call   1090 <err_exit@plt>
cmpl   $0x0,-0x14(%rbp)
je     1428 <_become_user+0x258>
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x160(%rbp)
jmp    1438 <_become_user+0x268>
mov    $0xffffffff,%eax
mov    %eax,-0x160(%rbp)
jmp    1438 <_become_user+0x268>
mov    -0x160(%rbp),%edi
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%esi
call   10a0 <setreuid@plt>
cmp    $0x0,%rax
jge    1460 <_become_user+0x290>
lea    0xc09(%rip),%rdi
call   1090 <err_exit@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_become_user>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%rbp
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
cmp    $0xffffffff,%eax
mov    $0x1000,%ebx
cmovne %eax,%ebx
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     121c <_become_user+0x4c>
test   %rbp,%rbp
jne    122f <_become_user+0x5f>
jmp    12aa <_become_user+0xda>
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1070 <msg_exit@plt>
test   %rbp,%rbp
je     12aa <_become_user+0xda>
mov    0x2da2(%rip),%r13
movq   $0x0,0x0(%r13)
lea    0x18(%rsp),%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
cmpq   $0x0,0x0(%r13)
je     1297 <_become_user+0xc7>
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%r8
mov    %rbp,%rdi
mov    %r15,%rdx
mov    %ebx,%ecx
call   10c0 <getpwnam_r@plt>
test   %eax,%eax
je     1283 <_become_user+0xb3>
lea    0xd95(%rip),%rsi
mov    %eax,%edi
mov    %rbp,%rdx
call   1030 <errn_exit@plt>
cmpq   $0x0,0x8(%rsp)
jne    12ef <_become_user+0x11f>
lea    0xd7c(%rip),%rdi
mov    %rbp,%rsi
jmp    12e8 <_become_user+0x118>
cmpb   $0x0,0x0(%rbp)
je     1257 <_become_user+0x87>
mov    %rax,%r12
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1257 <_become_user+0x87>
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%r8
mov    %r12,%rdi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1050 <getpwuid_r@plt>
test   %eax,%eax
je     12d6 <_become_user+0x106>
lea    0xd5b(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
call   1030 <errn_exit@plt>
cmpq   $0x0,0x8(%rsp)
jne    12ef <_become_user+0x11f>
lea    0xd42(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <msg_exit@plt>
movl   $0x40,0x14(%rsp)
mov    0x8(%rsp),%rax
mov    (%rax),%esi
mov    0x8(%rax),%edi
lea    0x30(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   10d0 <getgrouplist@plt>
cmp    $0xffffffff,%eax
jne    1321 <_become_user+0x151>
lea    0xd23(%rip),%rdi
call   1090 <err_exit@plt>
mov    0x14(%rsp),%edi
lea    0x30(%rsp),%rsi
call   1060 <setgroups@plt>
test   %rax,%rax
jns    1340 <_become_user+0x170>
lea    0xd1f(%rip),%rdi
call   1090 <err_exit@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%esi
cmp    $0x1,%r14d
sbb    %edi,%edi
or     %esi,%edi
call   10b0 <setregid@plt>
test   %rax,%rax
jns    1365 <_become_user+0x195>
lea    0xd04(%rip),%rdi
call   1090 <err_exit@plt>
mov    0x8(%rsp),%rax
mov    0x4(%rax),%esi
cmp    $0x1,%r14d
sbb    %edi,%edi
or     %esi,%edi
call   10a0 <setreuid@plt>
test   %rax,%rax
jns    138b <_become_user+0x1bb>
lea    0xcde(%rip),%rdi
call   1090 <err_exit@plt>
mov    %r15,%rdi
call   1040 <free@plt>
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i32, i32, i32 }
@_SC_GETPW_R_SIZE_MAX = global i32 0
@.str = [14 x i8] c"out of memory\00"
@errno = global i64 0
@.str.1 = [25 x i8] c"error looking up user %s\00"
@.str.2 = [24 x i8] c"error looking up uid %d\00"
@.str.3 = [27 x i8] c"user is in too many groups\00"
@.str.4 = [10 x i8] c"setgroups\00"
@.str.5 = [9 x i8] c"setreuid\00"
define void @_become_user(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.passwd
%9 = alloca %struct.passwd*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca [64 x i32]
%14 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%15 = load i32, i32* @_SC_GETPW_R_SIZE_MAX
%16 = call i32 @sysconf(i32 %15)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 4096, i32* %10
br label %20
20: ; preds = %19, %3
%21 = load i32, i32* %10
%22 = call i8* @malloc(i32 %21)
store i8* %22, i8** %11
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = call i32 (i8*, ...) @msg_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i8*, i8** %4
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %46
29: ; preds = %26
store i64 0, i64* @errno
%30 = load i8*, i8** %4
%31 = call i8* @strtoul(i8* %30, i8** %14, i32 10)
store i8* %31, i8** %5
%32 = load i64, i64* @errno
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %29
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = load i8*, i8** %14
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %39
store i8* null, i8** %4
br label %45
45: ; preds = %44, %39, %34, %29
br label %46
46: ; preds = %45, %26
%47 = load i8*, i8** %4
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %66
49: ; preds = %46
%50 = load i8*, i8** %4
%51 = load i8*, i8** %11
%52 = load i32, i32* %10
%53 = call i32 @getpwnam_r(i8* %50, %struct.passwd* %8, i8* %51, i32 %52, %struct.passwd** %9)
store i32 %53, i32* %7
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %49
%56 = load i32, i32* %7
%57 = load i8*, i8** %4
%58 = call i32 @errn_exit(i32 %56, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %55, %49
%60 = load %struct.passwd*, %struct.passwd** %9
%61 = icmp ne %struct.passwd* %60, null
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = load i8*, i8** %4
%64 = call i32 (i8*, ...) @msg_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %62, %59
br label %83
66: ; preds = %46
%67 = load i8*, i8** %5
%68 = load i8*, i8** %11
%69 = load i32, i32* %10
%70 = call i32 @getpwuid_r(i8* %67, %struct.passwd* %8, i8* %68, i32 %69, %struct.passwd** %9)
store i32 %70, i32* %7
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %66
%73 = load i32, i32* %7
%74 = load i8*, i8** %5
%75 = call i32 @errn_exit(i32 %73, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %72, %66
%77 = load %struct.passwd*, %struct.passwd** %9
%78 = icmp ne %struct.passwd* %77, null
br i1 %78, label %82, label %79
79: ; preds = %76
%80 = load i8*, i8** %5
%81 = call i32 (i8*, ...) @msg_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %79, %76
br label %83
83: ; preds = %82, %65
store i32 64, i32* %12
%84 = load %struct.passwd*, %struct.passwd** %9
%85 = getelementptr inbounds %struct.passwd, %struct.passwd* %84, i32 0, i32 2
%86 = load i32, i32* %85
%87 = load %struct.passwd*, %struct.passwd** %9
%88 = getelementptr inbounds %struct.passwd, %struct.passwd* %87, i32 0, i32 0
%89 = load i32, i32* %88
%90 = getelementptr inbounds [64 x i32], [64 x i32]* %13, i64 0, i64 0
%91 = call i32 @getgrouplist(i32 %86, i32 %89, i32* %90, i32* %12)
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %95
93: ; preds = %83
%94 = call i32 @err_exit(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %95
95: ; preds = %93, %83
%96 = load i32, i32* %12
%97 = getelementptr inbounds [64 x i32], [64 x i32]* %13, i64 0, i64 0
%98 = call i64 @setgroups(i32 %96, i32* %97)
%99 = icmp slt i64 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %95
%101 = call i32 @err_exit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %102
102: ; preds = %100, %95
%103 = load i32, i32* %6
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %102
%106 = load %struct.passwd*, %struct.passwd** %9
%107 = getelementptr inbounds %struct.passwd, %struct.passwd* %106, i32 0, i32 0
%108 = load i32, i32* %107
br label %110
109: ; preds = %102
br label %110
110: ; preds = %109, %105
%111 = phi i32 [ %108, %105 ], [ -1, %109 ]
%112 = load %struct.passwd*, %struct.passwd** %9
%113 = getelementptr inbounds %struct.passwd, %struct.passwd* %112, i32 0, i32 0
%114 = load i32, i32* %113
%115 = call i64 @setregid(i32 %111, i32 %114)
%116 = icmp slt i64 %115, 0
br i1 %116, label %117, label %119
117: ; preds = %110
%118 = call i32 @err_exit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %119
119: ; preds = %117, %110
%120 = load i32, i32* %6
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %126
122: ; preds = %119
%123 = load %struct.passwd*, %struct.passwd** %9
%124 = getelementptr inbounds %struct.passwd, %struct.passwd* %123, i32 0, i32 1
%125 = load i32, i32* %124
br label %127
126: ; preds = %119
br label %127
127: ; preds = %126, %122
%128 = phi i32 [ %125, %122 ], [ -1, %126 ]
%129 = load %struct.passwd*, %struct.passwd** %9
%130 = getelementptr inbounds %struct.passwd, %struct.passwd* %129, i32 0, i32 1
%131 = load i32, i32* %130
%132 = call i64 @setreuid(i32 %128, i32 %131)
%133 = icmp slt i64 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %127
%135 = call i32 @err_exit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %136
136: ; preds = %134, %127
%137 = load i8*, i8** %11
%138 = call i32 @free(i8* %137)
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i32, i32, i32 }
@_SC_GETPW_R_SIZE_MAX = global i32 0
@.str = [14 x i8] c"out of memory\00"
@errno = global i64 0
@.str.1 = [25 x i8] c"error looking up user %s\00"
@.str.2 = [24 x i8] c"error looking up uid %d\00"
@.str.3 = [27 x i8] c"user is in too many groups\00"
@.str.4 = [10 x i8] c"setgroups\00"
@.str.5 = [9 x i8] c"setreuid\00"
define void @_become_user(i8* %0, i8* %1, i32 %2) {
%4 = alloca %struct.passwd
%5 = alloca %struct.passwd*
%6 = alloca i32
%7 = alloca [64 x i32]
%8 = alloca i8*
%9 = bitcast %struct.passwd* %4 to i8*
%10 = bitcast %struct.passwd** %5 to i8*
%11 = load i32, i32* @_SC_GETPW_R_SIZE_MAX
%12 = tail call i32 @sysconf(i32 %11)
%13 = bitcast i32* %6 to i8*
%14 = bitcast [64 x i32]* %7 to i8*
%15 = bitcast i8** %8 to i8*
%16 = icmp eq i32 %12, -1
%17 = select i1 %16, i32 4096, i32 %12
%18 = tail call i8* @malloc(i32 %17)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %3
%21 = tail call i32 (i8*, ...) @msg_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %3
%23 = icmp eq i8* %0, null
br i1 %23, label %45, label %24
24: ; preds = %22
store i64 0, i64* @errno
%25 = call i8* @strtoul(i8* %0, i8** %8, i32 10)
%26 = load i64, i64* @errno
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i8, i8* %0
%30 = icmp eq i8 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = load i8*, i8** %8
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %28, %24, %31
%36 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %18, i32 %17, %struct.passwd** %5)
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @errn_exit(i32 %36, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %40
40: ; preds = %38, %35
%41 = load %struct.passwd*, %struct.passwd** %5
%42 = icmp eq %struct.passwd* %41, null
br i1 %42, label %43, label %56
43: ; preds = %40
%44 = call i32 (i8*, ...) @msg_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %56
45: ; preds = %31, %22
%46 = phi i8* [ %1, %22 ], [ %25, %31 ]
%47 = call i32 @getpwuid_r(i8* %46, %struct.passwd* %4, i8* %18, i32 %17, %struct.passwd** %5)
%48 = icmp eq i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %45
%50 = call i32 @errn_exit(i32 %47, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %46)
br label %51
51: ; preds = %49, %45
%52 = load %struct.passwd*, %struct.passwd** %5
%53 = icmp eq %struct.passwd* %52, null
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, ...) @msg_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %46)
br label %56
56: ; preds = %51, %54, %40, %43
store i32 64, i32* %6
%57 = load %struct.passwd*, %struct.passwd** %5
%58 = getelementptr inbounds %struct.passwd, %struct.passwd* %57, i64 0, i32 2
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.passwd, %struct.passwd* %57, i64 0, i32 0
%61 = load i32, i32* %60
%62 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%63 = call i32 @getgrouplist(i32 %59, i32 %61, i32* %62, i32* %6)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %67
65: ; preds = %56
%66 = call i32 @err_exit(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %56
%68 = load i32, i32* %6
%69 = call i64 @setgroups(i32 %68, i32* %62)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 @err_exit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %73
73: ; preds = %71, %67
%74 = icmp eq i32 %2, 0
%75 = load %struct.passwd*, %struct.passwd** %5
%76 = getelementptr inbounds %struct.passwd, %struct.passwd* %75, i64 0, i32 0
%77 = load i32, i32* %76
%78 = select i1 %74, i32 -1, i32 %77
%79 = call i64 @setregid(i32 %78, i32 %77)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %73
%82 = call i32 @err_exit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %83
83: ; preds = %81, %73
%84 = load %struct.passwd*, %struct.passwd** %5
%85 = getelementptr inbounds %struct.passwd, %struct.passwd* %84, i64 0, i32 1
%86 = load i32, i32* %85
%87 = select i1 %74, i32 -1, i32 %86
%88 = call i64 @setreuid(i32 %87, i32 %86)
%89 = icmp slt i64 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %83
%91 = call i32 @err_exit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %92
92: ; preds = %90, %83
%93 = call i32 @free(i8* %18)
ret void
}