#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 passwd {
  int /*<<< orphan*/ pw_uid;
  int /*<<< orphan*/ pw_gid;
};

/* Variables and functions */
int ERANGE;
int errno;
int getpwnam_r(char const *, struct passwd *, char *, size_t, struct passwd **);
int /*<<< orphan*/ set_errbuf(char *, size_t, char *, ...);
scalar_t__ setgid(int /*<<< orphan*/);
scalar_t__ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int);
int run_as(const char *user, char *errbuf, size_t errbuf_size) {
  if (errbuf != NULL && errbuf_size >= 1)
    errbuf[0] = '0';
  if (user == NULL)
    return 0;
  struct passwd pwdbuf, *pwd;
  size_t buflen;
  int err;
  for (buflen = 128;; buflen *= 2) {
    char buf[buflen];
    err = getpwnam_r(user, &pwdbuf, buf, buflen, &pwd);
    if (err == 0 && pwd) {
      if (setgid(pwd->pw_gid) != 0) {
        set_errbuf(errbuf, errbuf_size,
                   "Could not change group id to that of run_as user '%s': %s",
                   user, strerror(errno));
        goto err;
      }
      if (setuid(pwd->pw_uid) != 0) {
        set_errbuf(errbuf, errbuf_size,
                   "Could not change user id to that of run_as user '%s': %s",
                   user, strerror(errno));
        goto err;
      }
      break;
    } else if (err != ERANGE) {
      if (err) {
        set_errbuf(errbuf, errbuf_size,
                   "run_as user '%s' could not be found: %s", user,
                   strerror(err));
      } else {
        set_errbuf(errbuf, errbuf_size, "run_as user '%s' could not be found.",
                   user);
      }
      goto err;
    } else if (buflen >= 16 * 1024) {
      set_errbuf(errbuf, errbuf_size,
                 "getpwnam_r() requires more than %u bytes of buffer space.",
                 (unsigned)buflen);
      goto err;
    }
  }
  return 0;
err:
  return -1;
}


x86 assembly (clang, -O0):
<run_as>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1184 <run_as+0x34>
cmpq   $0x1,-0x20(%rbp)
jb     1184 <run_as+0x34>
mov    -0x18(%rbp),%rax
movb   $0x30,(%rax)
cmpq   $0x0,-0x10(%rbp)
jne    119b <run_as+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    140a <run_as+0x2ba>
movq   $0x80,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rcx
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%r8
call   1040 <getpwnam_r@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    12ce <run_as+0x17e>
cmpq   $0x0,-0x30(%rbp)
je     12ce <run_as+0x17e>
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <setgid@plt>
cmp    $0x0,%rax
je     1258 <run_as+0x108>
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x60(%rbp),%rcx
mov    %eax,%r8d
lea    0xdbb(%rip),%rdx
mov    $0x0,%al
call   1030 <set_errbuf@plt>
movl   $0x5,-0x54(%rbp)
jmp    13ab <run_as+0x25b>
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
call   1060 <setuid@plt>
cmp    $0x0,%rax
je     12c2 <run_as+0x172>
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rcx
mov    %eax,%r8d
lea    0xd8b(%rip),%rdx
mov    $0x0,%al
call   1030 <set_errbuf@plt>
movl   $0x5,-0x54(%rbp)
jmp    13ab <run_as+0x25b>
movl   $0x2,-0x54(%rbp)
jmp    13ab <run_as+0x25b>
mov    -0x3c(%rbp),%eax
mov    0x2d10(%rip),%rcx
cmp    (%rcx),%eax
je     1364 <run_as+0x214>
cmpl   $0x0,-0x3c(%rbp)
je     133e <run_as+0x1ee>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x3c(%rbp),%edi
call   1070 <strerror@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    -0x90(%rbp),%rcx
mov    %eax,%r8d
lea    0xd41(%rip),%rdx
mov    $0x0,%al
call   1030 <set_errbuf@plt>
jmp    1358 <run_as+0x208>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rcx
lea    0xd4a(%rip),%rdx
mov    $0x0,%al
call   1030 <set_errbuf@plt>
movl   $0x5,-0x54(%rbp)
jmp    13ab <run_as+0x25b>
cmpq   $0x4000,-0x38(%rbp)
jb     139a <run_as+0x24a>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
lea    0xd39(%rip),%rdx
mov    $0x0,%al
call   1030 <set_errbuf@plt>
movl   $0x5,-0x54(%rbp)
jmp    13ab <run_as+0x25b>
jmp    139f <run_as+0x24f>
jmp    13a4 <run_as+0x254>
movl   $0x0,-0x54(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x54(%rbp),%eax
mov    %eax,-0xa4(%rbp)
test   %eax,%eax
je     13e1 <run_as+0x291>
jmp    13c8 <run_as+0x278>
mov    -0xa4(%rbp),%eax
sub    $0x2,%eax
je     13f7 <run_as+0x2a7>
jmp    13dc <run_as+0x28c>
jmp    1403 <run_as+0x2b3>
jmp    13e6 <run_as+0x296>
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a3 <run_as+0x53>
movl   $0x0,-0x4(%rbp)
jmp    140a <run_as+0x2ba>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_as>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rsi,%rsi
je     1178 <run_as+0x28>
test   %r14,%r14
je     1178 <run_as+0x28>
movb   $0x30,(%r15)
test   %rbx,%rbx
je     11d8 <run_as+0x88>
mov    %rsp,%r12
lea    -0x80(%rsp),%rdx
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x80,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    11df <run_as+0x8f>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
je     11df <run_as+0x8f>
mov    0x4(%rdx),%edi
call   1050 <setgid@plt>
test   %rax,%rax
je     13f8 <run_as+0x2a8>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe2d(%rip),%rdx
jmp    142d <run_as+0x2dd>
xor    %eax,%eax
jmp    1448 <run_as+0x2f8>
mov    0x2e02(%rip),%r13
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x100(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x100,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    1226 <run_as+0xd6>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x200(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x200,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    126a <run_as+0x11a>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x400(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x400,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    12ae <run_as+0x15e>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x800(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x800,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    12f2 <run_as+0x1a2>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x1000(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x1000,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    1336 <run_as+0x1e6>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x2000(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x2000,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    137a <run_as+0x22a>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
mov    %r12,%rsp
mov    %rsp,%r12
lea    -0x4000(%rsp),%rdx
ff
mov    %rdx,%rsp
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x4000,%ecx
mov    %rbx,%rdi
call   1040 <getpwnam_r@plt>
test   %eax,%eax
sete   %cl
jne    13ba <run_as+0x26a>
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
jne    11ad <run_as+0x5d>
cmp    0x0(%r13),%eax
jne    13db <run_as+0x28b>
lea    0xcf9(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4000,%ecx
xor    %eax,%eax
call   1030 <set_errbuf@plt>
jmp    1440 <run_as+0x2f0>
test   %cl,%cl
je     141f <run_as+0x2cf>
lea    0xcb5(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <set_errbuf@plt>
jmp    1440 <run_as+0x2f0>
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
call   1060 <setuid@plt>
test   %rax,%rax
je     1457 <run_as+0x307>
mov    0x2bc9(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xc1d(%rip),%rdx
jmp    142d <run_as+0x2dd>
mov    %eax,%edi
call   1070 <strerror@plt>
lea    0xc46(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <set_errbuf@plt>
mov    $0xffffffff,%eax
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    1445 <run_as+0x2f5>

LLVM IR (-O0):
%struct.passwd = type { i32, i32 }
@.str = [58 x i8] c"Could not change group id to that of run_as user '%s': %s\00"
@errno = global i32 0
@.str.1 = [57 x i8] c"Could not change user id to that of run_as user '%s': %s\00"
@ERANGE = global i32 0
@.str.2 = [40 x i8] c"run_as user '%s' could not be found: %s\00"
@.str.3 = [37 x i8] c"run_as user '%s' could not be found.\00"
@.str.4 = [58 x i8] c"getpwnam_r() requires more than %u bytes of buffer space.\00"
define i32 @run_as(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.passwd
%9 = alloca %struct.passwd*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %23
17: ; preds = %3
%18 = load i64, i64* %7
%19 = icmp uge i64 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 48, i8* %22
br label %23
23: ; preds = %20, %17, %3
%24 = load i8*, i8** %5
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 0, i32* %4
br label %108
27: ; preds = %23
store i64 128, i64* %10
br label %28
28: ; preds = %103, %27
%29 = load i64, i64* %10
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %12
%31 = alloca i8, i64 %29
store i64 %29, i64* %13
%32 = load i8*, i8** %5
%33 = load i64, i64* %10
%34 = call i32 @getpwnam_r(i8* %32, %struct.passwd* %8, i8* %31, i64 %33, %struct.passwd** %9)
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %67
37: ; preds = %28
%38 = load %struct.passwd*, %struct.passwd** %9
%39 = icmp ne %struct.passwd* %38, null
br i1 %39, label %40, label %67
40: ; preds = %37
%41 = load %struct.passwd*, %struct.passwd** %9
%42 = getelementptr inbounds %struct.passwd, %struct.passwd* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = call i64 @setgid(i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = load i8*, i8** %6
%48 = load i64, i64* %7
%49 = load i8*, i8** %5
%50 = load i32, i32* @errno
%51 = call i32 @strerror(i32 %50)
%52 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %47, i64 %48, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %49, i32 %51)
store i32 5, i32* %14
br label %99
53: ; preds = %40
%54 = load %struct.passwd*, %struct.passwd** %9
%55 = getelementptr inbounds %struct.passwd, %struct.passwd* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i64 @setuid(i32 %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %66
59: ; preds = %53
%60 = load i8*, i8** %6
%61 = load i64, i64* %7
%62 = load i8*, i8** %5
%63 = load i32, i32* @errno
%64 = call i32 @strerror(i32 %63)
%65 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %60, i64 %61, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i8* %62, i32 %64)
store i32 5, i32* %14
br label %99
66: ; preds = %53
store i32 2, i32* %14
br label %99
67: ; preds = %37, %28
%68 = load i32, i32* %11
%69 = load i32, i32* @ERANGE
%70 = icmp ne i32 %68, %69
br i1 %70, label %71, label %87
71: ; preds = %67
%72 = load i32, i32* %11
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %71
%75 = load i8*, i8** %6
%76 = load i64, i64* %7
%77 = load i8*, i8** %5
%78 = load i32, i32* %11
%79 = call i32 @strerror(i32 %78)
%80 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %75, i64 %76, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %77, i32 %79)
br label %86
81: ; preds = %71
%82 = load i8*, i8** %6
%83 = load i64, i64* %7
%84 = load i8*, i8** %5
%85 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %82, i64 %83, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %81, %74
store i32 5, i32* %14
br label %99
87: ; preds = %67
%88 = load i64, i64* %10
%89 = icmp uge i64 %88, 16384
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = load i8*, i8** %6
%92 = load i64, i64* %7
%93 = load i64, i64* %10
%94 = trunc i64 %93 to i32
%95 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %91, i64 %92, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %94)
store i32 5, i32* %14
br label %99
96: ; preds = %87
br label %97
97: ; preds = %96
br label %98
98: ; preds = %97
store i32 0, i32* %14
br label %99
99: ; preds = %90, %86, %59, %46, %98, %66
%100 = load i8*, i8** %12
%101 = load i32, i32* %14
switch i32 %101, label %110 [
i32 0, label %102
i32 2, label %106
i32 5, label %107
]
102: ; preds = %99
br label %103
103: ; preds = %102
%104 = load i64, i64* %10
%105 = mul i64 %104, 2
store i64 %105, i64* %10
br label %28
106: ; preds = %99
store i32 0, i32* %4
br label %108
107: ; preds = %99
store i32 -1, i32* %4
br label %108
108: ; preds = %107, %106, %26
%109 = load i32, i32* %4
ret i32 %109
110: ; preds = %99
unreachable
}

LLVM IR (-O2):
%struct.passwd = type { i32, i32 }
@.str = [58 x i8] c"Could not change group id to that of run_as user '%s': %s\00"
@errno = global i32 0
@.str.1 = [57 x i8] c"Could not change user id to that of run_as user '%s': %s\00"
@ERANGE = global i32 0
@.str.2 = [40 x i8] c"run_as user '%s' could not be found: %s\00"
@.str.3 = [37 x i8] c"run_as user '%s' could not be found.\00"
@.str.4 = [58 x i8] c"getpwnam_r() requires more than %u bytes of buffer space.\00"
define i32 @run_as(i8* %0, i8* %1, i64 %2) {
%4 = alloca %struct.passwd
%5 = alloca %struct.passwd*
%6 = icmp ne i8* %1, null
%7 = icmp ne i64 %2, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %3
store i8 48, i8* %1
br label %10
10: ; preds = %9, %3
%11 = icmp eq i8* %0, null
br i1 %11, label %145, label %12
12: ; preds = %10
%13 = bitcast %struct.passwd* %4 to i8*
%14 = bitcast %struct.passwd** %5 to i8*
%15 = call i8* @llvm.stacksave()
%16 = alloca [128 x i8]
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%18 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %17, i64 128, %struct.passwd** %5)
%19 = icmp eq i32 %18, 0
%20 = load %struct.passwd*, %struct.passwd** %5
%21 = icmp ne %struct.passwd* %20, null
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %26, label %23
23: ; preds = %12
%24 = load i32, i32* @ERANGE
%25 = icmp eq i32 %18, %24
br i1 %25, label %56, label %47
26: ; preds = %56, %70, %82, %94, %106, %118, %130, %12
%27 = phi i8* [ %15, %12 ], [ %57, %56 ], [ %71, %70 ], [ %83, %82 ], [ %95, %94 ], [ %107, %106 ], [ %119, %118 ], [ %131, %130 ]
%28 = phi %struct.passwd* [ %20, %12 ], [ %62, %56 ], [ %76, %70 ], [ %88, %82 ], [ %100, %94 ], [ %112, %106 ], [ %124, %118 ], [ %136, %130 ]
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i64 0, i32 1
%30 = load i32, i32* %29
%31 = call i64 @setgid(i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %26
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %1, i64 %2, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %35)
br label %142
37: ; preds = %26
%38 = load %struct.passwd*, %struct.passwd** %5
%39 = getelementptr inbounds %struct.passwd, %struct.passwd* %38, i64 0, i32 0
%40 = load i32, i32* %39
%41 = call i64 @setuid(i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %142, label %43
43: ; preds = %37
%44 = load i32, i32* @errno
%45 = call i32 @strerror(i32 %44)
%46 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %1, i64 %2, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %45)
br label %142
47: ; preds = %139, %127, %115, %103, %91, %79, %67, %23
%48 = phi i1 [ %19, %23 ], [ %61, %67 ], [ %75, %79 ], [ %87, %91 ], [ %99, %103 ], [ %111, %115 ], [ %123, %127 ], [ %135, %139 ]
%49 = phi i32 [ %18, %23 ], [ %60, %67 ], [ %74, %79 ], [ %86, %91 ], [ %98, %103 ], [ %110, %115 ], [ %122, %127 ], [ %134, %139 ]
%50 = phi i8* [ %15, %23 ], [ %57, %67 ], [ %71, %79 ], [ %83, %91 ], [ %95, %103 ], [ %107, %115 ], [ %119, %127 ], [ %131, %139 ]
br i1 %48, label %54, label %51
51: ; preds = %47
%52 = call i32 @strerror(i32 %49)
%53 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %1, i64 %2, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %52)
br label %142
54: ; preds = %47
%55 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %1, i64 %2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %142
56: ; preds = %23
%57 = call i8* @llvm.stacksave()
%58 = alloca [256 x i8]
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %58, i64 0, i64 0
%60 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %59, i64 256, %struct.passwd** %5)
%61 = icmp eq i32 %60, 0
%62 = load %struct.passwd*, %struct.passwd** %5
%63 = icmp ne %struct.passwd* %62, null
%64 = select i1 %61, i1 %63, i1 false
br i1 %64, label %26, label %67
65: ; preds = %139
%66 = call i32 (i8*, i64, i8*, ...) @set_errbuf(i8* %1, i64 %2, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 16384)
br label %142
67: ; preds = %56
%68 = load i32, i32* @ERANGE
%69 = icmp eq i32 %60, %68
br i1 %69, label %70, label %47
70: ; preds = %67
%71 = call i8* @llvm.stacksave()
%72 = alloca [512 x i8]
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %72, i64 0, i64 0
%74 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %73, i64 512, %struct.passwd** %5)
%75 = icmp eq i32 %74, 0
%76 = load %struct.passwd*, %struct.passwd** %5
%77 = icmp ne %struct.passwd* %76, null
%78 = select i1 %75, i1 %77, i1 false
br i1 %78, label %26, label %79
79: ; preds = %70
%80 = load i32, i32* @ERANGE
%81 = icmp eq i32 %74, %80
br i1 %81, label %82, label %47
82: ; preds = %79
%83 = call i8* @llvm.stacksave()
%84 = alloca [1024 x i8]
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %84, i64 0, i64 0
%86 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %85, i64 1024, %struct.passwd** %5)
%87 = icmp eq i32 %86, 0
%88 = load %struct.passwd*, %struct.passwd** %5
%89 = icmp ne %struct.passwd* %88, null
%90 = select i1 %87, i1 %89, i1 false
br i1 %90, label %26, label %91
91: ; preds = %82
%92 = load i32, i32* @ERANGE
%93 = icmp eq i32 %86, %92
br i1 %93, label %94, label %47
94: ; preds = %91
%95 = call i8* @llvm.stacksave()
%96 = alloca [2048 x i8]
%97 = getelementptr inbounds [2048 x i8], [2048 x i8]* %96, i64 0, i64 0
%98 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %97, i64 2048, %struct.passwd** %5)
%99 = icmp eq i32 %98, 0
%100 = load %struct.passwd*, %struct.passwd** %5
%101 = icmp ne %struct.passwd* %100, null
%102 = select i1 %99, i1 %101, i1 false
br i1 %102, label %26, label %103
103: ; preds = %94
%104 = load i32, i32* @ERANGE
%105 = icmp eq i32 %98, %104
br i1 %105, label %106, label %47
106: ; preds = %103
%107 = call i8* @llvm.stacksave()
%108 = alloca [4096 x i8]
%109 = getelementptr inbounds [4096 x i8], [4096 x i8]* %108, i64 0, i64 0
%110 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %109, i64 4096, %struct.passwd** %5)
%111 = icmp eq i32 %110, 0
%112 = load %struct.passwd*, %struct.passwd** %5
%113 = icmp ne %struct.passwd* %112, null
%114 = select i1 %111, i1 %113, i1 false
br i1 %114, label %26, label %115
115: ; preds = %106
%116 = load i32, i32* @ERANGE
%117 = icmp eq i32 %110, %116
br i1 %117, label %118, label %47
118: ; preds = %115
%119 = call i8* @llvm.stacksave()
%120 = alloca [8192 x i8]
%121 = getelementptr inbounds [8192 x i8], [8192 x i8]* %120, i64 0, i64 0
%122 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %121, i64 8192, %struct.passwd** %5)
%123 = icmp eq i32 %122, 0
%124 = load %struct.passwd*, %struct.passwd** %5
%125 = icmp ne %struct.passwd* %124, null
%126 = select i1 %123, i1 %125, i1 false
br i1 %126, label %26, label %127
127: ; preds = %118
%128 = load i32, i32* @ERANGE
%129 = icmp eq i32 %122, %128
br i1 %129, label %130, label %47
130: ; preds = %127
%131 = call i8* @llvm.stacksave()
%132 = alloca [16384 x i8]
%133 = getelementptr inbounds [16384 x i8], [16384 x i8]* %132, i64 0, i64 0
%134 = call i32 @getpwnam_r(i8* %0, %struct.passwd* %4, i8* %133, i64 16384, %struct.passwd** %5)
%135 = icmp eq i32 %134, 0
%136 = load %struct.passwd*, %struct.passwd** %5
%137 = icmp ne %struct.passwd* %136, null
%138 = select i1 %135, i1 %137, i1 false
br i1 %138, label %26, label %139
139: ; preds = %130
%140 = load i32, i32* @ERANGE
%141 = icmp eq i32 %134, %140
br i1 %141, label %65, label %47
142: ; preds = %51, %54, %65, %43, %33, %37
%143 = phi i8* [ %27, %37 ], [ %27, %33 ], [ %27, %43 ], [ %131, %65 ], [ %50, %54 ], [ %50, %51 ]
%144 = phi i32 [ 0, %37 ], [ -1, %33 ], [ -1, %43 ], [ -1, %65 ], [ -1, %54 ], [ -1, %51 ]
br label %145
145: ; preds = %10, %142
%146 = phi i32 [ %144, %142 ], [ 0, %10 ]
ret i32 %146
}