#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 {
  scalar_t__ pw_uid;
};

/* Variables and functions */
scalar_t__ EPERM;
int /*<<< orphan*/ MAP_ANON;
char *MAP_FAILED;
int PROT_READ;
int PROT_WRITE;
scalar_t__ errno;
int /*<<< orphan*/ errx(int, char *, ...);
scalar_t__ geteuid();
int getpagesize();
struct passwd *getpwnam(char *);
scalar_t__ mlock(char *, int);
char *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
scalar_t__ munlock(char *, int);
scalar_t__ seteuid(scalar_t__);
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  struct passwd *pwd;
  int pagesize;
  char *page;
  if (geteuid() != 0)
    errx(-1, "mlock must run as root");
  errno = 0;
  pwd = getpwnam("nobody");
  if (pwd == NULL && errno == 0)
    errx(-1, "getpwnam: user \"%s\" not found", "nobody");
  if (pwd == NULL)
    errx(-1, "getpwnam: %s", strerror(errno));
  if (pwd->pw_uid == 0)
    errx(-1, "getpwnam: user \"%s\" has uid 0", "nobody");
  pagesize = getpagesize();
  page = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
  if (page == MAP_FAILED)
    errx(-1, "mmap: %s", strerror(errno));
  if (mlock(page, pagesize) < 0)
    errx(-1, "mlock privileged: %s", strerror(errno));
  if (munlock(page, pagesize) < 0)
    errx(-1, "munlock privileged: %s", strerror(errno));
  if (seteuid(pwd->pw_uid) < 0)
    errx(-1, "seteuid: %s", strerror(errno));
  if (mlock(page, pagesize) == 0)
    errx(-1, "mlock unprivileged: succeeded but shouldn't have");
  if (errno != EPERM)
    errx(-1, "mlock unprivileged: %s", strerror(errno));
  if (munlock(page, pagesize) == 0)
    errx(-1, "munlock unprivileged: succeeded but shouldn't have");
  if (errno != EPERM)
    errx(-1, "munlock unprivileged: %s", strerror(errno));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <geteuid@plt>
cmp    $0x0,%rax
je     11ca <main+0x3a>
mov    $0xffffffff,%edi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    0x2e07(%rip),%rax
movq   $0x0,(%rax)
lea    0xe38(%rip),%rdi
call   1080 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121e <main+0x8e>
mov    0x2dde(%rip),%rax
cmpq   $0x0,(%rax)
jne    121e <main+0x8e>
mov    $0xffffffff,%edi
lea    0xe0e(%rip),%rsi
lea    0xe00(%rip),%rdx
mov    $0x0,%al
call   1060 <errx@plt>
cmpq   $0x0,-0x18(%rbp)
jne    124e <main+0xbe>
mov    0x2da8(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1276 <main+0xe6>
mov    $0xffffffff,%edi
lea    0xde1(%rip),%rsi
lea    0xda8(%rip),%rdx
mov    $0x0,%al
call   1060 <errx@plt>
mov    $0x0,%al
call   1090 <getpagesize@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    0x2d6e(%rip),%rax
mov    (%rax),%edx
mov    0x2d3d(%rip),%rax
or     (%rax),%edx
mov    0x2d2c(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2d01(%rip),%rcx
cmp    (%rcx),%rax
jne    12ed <main+0x15d>
mov    0x2d09(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <mlock@plt>
cmp    $0x0,%rax
jge    1328 <main+0x198>
mov    0x2cce(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xd4f(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <munlock@plt>
cmp    $0x0,%rax
jge    1363 <main+0x1d3>
mov    0x2c93(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <seteuid@plt>
cmp    $0x0,%rax
jge    139e <main+0x20e>
mov    0x2c58(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <mlock@plt>
cmp    $0x0,%rax
jne    13c7 <main+0x237>
mov    $0xffffffff,%edi
lea    0xce8(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%rax
mov    0x2bd8(%rip),%rcx
cmp    (%rcx),%rax
je     1406 <main+0x276>
mov    0x2bf0(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xcda(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <munlock@plt>
cmp    $0x0,%rax
jne    142f <main+0x29f>
mov    $0xffffffff,%edi
lea    0xcc8(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    0x2ba2(%rip),%rax
mov    (%rax),%rax
mov    0x2b70(%rip),%rcx
cmp    (%rcx),%rax
je     146e <main+0x2de>
mov    0x2b88(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rdx
mov    $0xffffffff,%edi
lea    0xcbc(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <geteuid@plt>
test   %rax,%rax
je     11b6 <main+0x26>
lea    0xe56(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1060 <errx@plt>
mov    0x2e1b(%rip),%r15
movq   $0x0,(%r15)
lea    0xe4c(%rip),%rdi
call   1080 <getpwnam@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11f8 <main+0x68>
cmpq   $0x0,(%r15)
jne    11f8 <main+0x68>
lea    0xe39(%rip),%rsi
lea    0xe2b(%rip),%rdx
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1060 <errx@plt>
test   %r14,%r14
je     1391 <main+0x201>
cmpq   $0x0,(%r14)
je     13b9 <main+0x229>
xor    %eax,%eax
call   1090 <getpagesize@plt>
mov    %eax,%ebp
mov    0x2ddd(%rip),%rax
mov    0x2dae(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d9b(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebp,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
mov    0x2d75(%rip),%rax
cmp    (%rax),%rbx
jne    126e <main+0xde>
mov    (%r15),%rdi
call   10a0 <strerror@plt>
lea    0xe08(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <mlock@plt>
test   %rax,%rax
jns    129b <main+0x10b>
mov    (%r15),%rdi
call   10a0 <strerror@plt>
lea    0xde4(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <munlock@plt>
test   %rax,%rax
jns    12c8 <main+0x138>
mov    (%r15),%rdi
call   10a0 <strerror@plt>
lea    0xdcc(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
mov    (%r14),%rdi
call   10b0 <seteuid@plt>
test   %rax,%rax
jns    12f3 <main+0x163>
mov    (%r15),%rdi
call   10a0 <strerror@plt>
lea    0xdb8(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <mlock@plt>
test   %rax,%rax
jne    1315 <main+0x185>
lea    0xd9f(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1060 <errx@plt>
mov    (%r15),%rdi
mov    0x2c91(%rip),%r14
cmp    (%r14),%rdi
je     133f <main+0x1af>
call   10a0 <strerror@plt>
lea    0xda9(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <munlock@plt>
test   %rax,%rax
jne    1361 <main+0x1d1>
lea    0xd9b(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1060 <errx@plt>
mov    (%r15),%rdi
cmp    (%r14),%rdi
je     1384 <main+0x1f4>
call   10a0 <strerror@plt>
lea    0xdae(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15),%rdi
call   10a0 <strerror@plt>
lea    0xc9c(%rip),%rsi
mov    $0xffffffff,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <errx@plt>
cmpq   $0x0,(%r14)
jne    120b <main+0x7b>
lea    0xc89(%rip),%rsi
lea    0xc50(%rip),%rdx
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1060 <errx@plt>
jmp    120b <main+0x7b>

LLVM IR (-O0):
%struct.passwd = type { i64 }
@.str = [23 x i8] c"mlock must run as root\00"
@errno = global i64 0
@.str.1 = [7 x i8] c"nobody\00"
@.str.2 = [30 x i8] c"getpwnam: user \22%s\22 not found\00"
@.str.3 = [13 x i8] c"getpwnam: %s\00"
@.str.4 = [30 x i8] c"getpwnam: user \22%s\22 has uid 0\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [9 x i8] c"mmap: %s\00"
@.str.6 = [21 x i8] c"mlock privileged: %s\00"
@.str.7 = [23 x i8] c"munlock privileged: %s\00"
@.str.8 = [12 x i8] c"seteuid: %s\00"
@.str.9 = [49 x i8] c"mlock unprivileged: succeeded but shouldn't have\00"
@EPERM = global i64 0
@.str.10 = [23 x i8] c"mlock unprivileged: %s\00"
@.str.11 = [51 x i8] c"munlock unprivileged: succeeded but shouldn't have\00"
@.str.12 = [25 x i8] c"munlock unprivileged: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 (...) @geteuid()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
store i64 0, i64* @errno
%14 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store %struct.passwd* %14, %struct.passwd** %6
%15 = load %struct.passwd*, %struct.passwd** %6
%16 = icmp eq %struct.passwd* %15, null
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i64, i64* @errno
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17, %13
%23 = load %struct.passwd*, %struct.passwd** %6
%24 = icmp eq %struct.passwd* %23, null
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i64, i64* @errno
%27 = call i8* @strerror(i64 %26)
%28 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %25, %22
%30 = load %struct.passwd*, %struct.passwd** %6
%31 = getelementptr inbounds %struct.passwd, %struct.passwd* %30, i32 0, i32 0
%32 = load i64, i64* %31
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = call i32 (...) @getpagesize()
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @PROT_WRITE
%41 = or i32 %39, %40
%42 = load i32, i32* @MAP_ANON
%43 = call i8* @mmap(i32* null, i32 %38, i32 %41, i32 %42, i32 -1, i32 0)
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = load i8*, i8** @MAP_FAILED
%46 = icmp eq i8* %44, %45
br i1 %46, label %47, label %51
47: ; preds = %36
%48 = load i64, i64* @errno
%49 = call i8* @strerror(i64 %48)
%50 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %36
%52 = load i8*, i8** %8
%53 = load i32, i32* %7
%54 = call i64 @mlock(i8* %52, i32 %53)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %51
%57 = load i64, i64* @errno
%58 = call i8* @strerror(i64 %57)
%59 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %56, %51
%61 = load i8*, i8** %8
%62 = load i32, i32* %7
%63 = call i64 @munlock(i8* %61, i32 %62)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %60
%66 = load i64, i64* @errno
%67 = call i8* @strerror(i64 %66)
%68 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %65, %60
%70 = load %struct.passwd*, %struct.passwd** %6
%71 = getelementptr inbounds %struct.passwd, %struct.passwd* %70, i32 0, i32 0
%72 = load i64, i64* %71
%73 = call i64 @seteuid(i64 %72)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %69
%76 = load i64, i64* @errno
%77 = call i8* @strerror(i64 %76)
%78 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %75, %69
%80 = load i8*, i8** %8
%81 = load i32, i32* %7
%82 = call i64 @mlock(i8* %80, i32 %81)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %79
%85 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
br label %86
86: ; preds = %84, %79
%87 = load i64, i64* @errno
%88 = load i64, i64* @EPERM
%89 = icmp ne i64 %87, %88
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = load i64, i64* @errno
%92 = call i8* @strerror(i64 %91)
%93 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %90, %86
%95 = load i8*, i8** %8
%96 = load i32, i32* %7
%97 = call i64 @munlock(i8* %95, i32 %96)
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i64 0, i64 0))
br label %101
101: ; preds = %99, %94
%102 = load i64, i64* @errno
%103 = load i64, i64* @EPERM
%104 = icmp ne i64 %102, %103
br i1 %104, label %105, label %109
105: ; preds = %101
%106 = load i64, i64* @errno
%107 = call i8* @strerror(i64 %106)
%108 = call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i8* %107)
br label %109
109: ; preds = %105, %101
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i64 }
@.str = [23 x i8] c"mlock must run as root\00"
@errno = global i64 0
@.str.1 = [7 x i8] c"nobody\00"
@.str.2 = [30 x i8] c"getpwnam: user \22%s\22 not found\00"
@.str.3 = [13 x i8] c"getpwnam: %s\00"
@.str.4 = [30 x i8] c"getpwnam: user \22%s\22 has uid 0\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [9 x i8] c"mmap: %s\00"
@.str.6 = [21 x i8] c"mlock privileged: %s\00"
@.str.7 = [23 x i8] c"munlock privileged: %s\00"
@.str.8 = [12 x i8] c"seteuid: %s\00"
@.str.9 = [49 x i8] c"mlock unprivileged: succeeded but shouldn't have\00"
@EPERM = global i64 0
@.str.10 = [23 x i8] c"mlock unprivileged: %s\00"
@.str.11 = [51 x i8] c"munlock unprivileged: succeeded but shouldn't have\00"
@.str.12 = [25 x i8] c"munlock unprivileged: %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @geteuid()
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
store i64 0, i64* @errno
%8 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq %struct.passwd* %8, null
%10 = load i64, i64* @errno
%11 = icmp eq i64 %10, 0
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
br i1 %9, label %16, label %20
16: ; preds = %15
%17 = load i64, i64* @errno
%18 = tail call i8* @strerror(i64 %17)
%19 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %15
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %8, i64 0, i32 0
%22 = load i64, i64* %21
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = tail call i32 (...) @getpagesize()
%28 = load i32, i32* @PROT_READ
%29 = load i32, i32* @PROT_WRITE
%30 = or i32 %29, %28
%31 = load i32, i32* @MAP_ANON
%32 = tail call i8* @mmap(i32* null, i32 %27, i32 %30, i32 %31, i32 -1, i32 0)
%33 = load i8*, i8** @MAP_FAILED
%34 = icmp eq i8* %32, %33
br i1 %34, label %35, label %39
35: ; preds = %26
%36 = load i64, i64* @errno
%37 = tail call i8* @strerror(i64 %36)
%38 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %35, %26
%40 = tail call i64 @mlock(i8* %32, i32 %27)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i64, i64* @errno
%44 = tail call i8* @strerror(i64 %43)
%45 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %42, %39
%47 = tail call i64 @munlock(i8* %32, i32 %27)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i64, i64* @errno
%51 = tail call i8* @strerror(i64 %50)
%52 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %46
%54 = load i64, i64* %21
%55 = tail call i64 @seteuid(i64 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i64, i64* @errno
%59 = tail call i8* @strerror(i64 %58)
%60 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %57, %53
%62 = tail call i64 @mlock(i8* %32, i32 %27)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
br label %66
66: ; preds = %64, %61
%67 = load i64, i64* @errno
%68 = load i64, i64* @EPERM
%69 = icmp eq i64 %67, %68
br i1 %69, label %73, label %70
70: ; preds = %66
%71 = tail call i8* @strerror(i64 %67)
%72 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %70, %66
%74 = tail call i64 @munlock(i8* %32, i32 %27)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i64 0, i64 0))
br label %78
78: ; preds = %76, %73
%79 = load i64, i64* @errno
%80 = load i64, i64* @EPERM
%81 = icmp eq i64 %79, %80
br i1 %81, label %85, label %82
82: ; preds = %78
%83 = tail call i8* @strerror(i64 %79)
%84 = tail call i32 (i32, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i8* %83)
br label %85
85: ; preds = %82, %78
ret i32 0
}