#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 */

/* Variables and functions */
int MAP_ANONYMOUS;
char *MAP_FAILED;
int MAP_PRIVATE;
int MCL_CURRENT;
int MCL_FUTURE;
int PROT_READ;
int PROT_WRITE;
unsigned long getpagesize();
scalar_t__ lock_check(char *);
scalar_t__ mlockall(int);
char *mmap(int /*<<< orphan*/ *, int, int, int, int /*<<< orphan*/,
           int /*<<< orphan*/);
scalar_t__ munlockall();
int /*<<< orphan*/ munmap(char *, int);
scalar_t__ onfault_check(char *);
int /*<<< orphan*/ perror(char *);
int unlock_lock_check(char *);
scalar_t__ unlock_onfault_check(char *);
int test_munlockall() {
  char *map;
  int ret = 1;
  unsigned long page_size = getpagesize();
  map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE,
             MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
  if (map == MAP_FAILED) {
    perror("test_munlockall mmap");
    goto out;
  }
  if (mlockall(MCL_CURRENT)) {
    perror("mlockall(MCL_CURRENT)");
    goto out;
  }
  if (lock_check(map))
    goto unmap;
  if (munlockall()) {
    perror("munlockall()");
    goto unmap;
  }
  if (unlock_lock_check(map))
    goto unmap;
  munmap(map, 2 * page_size);
  map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE,
             MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
  if (map == MAP_FAILED) {
    perror("test_munlockall second mmap");
    goto out;
  }
  if (mlockall(MCL_CURRENT | (MCL_FUTURE << 1))) {
    perror("mlockall(MCL_CURRENT | MCL_ONFAULT)");
    goto unmap;
  }
  if (onfault_check(map))
    goto unmap;
  if (munlockall()) {
    perror("munlockall()");
    goto unmap;
  }
  if (unlock_onfault_check(map))
    goto unmap;
  if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
    perror("mlockall(MCL_CURRENT | MCL_FUTURE)");
    goto out;
  }
  if (lock_check(map))
    goto unmap;
  if (munlockall()) {
    perror("munlockall()");
    goto unmap;
  }
  ret = unlock_lock_check(map);
unmap:
  munmap(map, 2 * page_size);
out:
  munlockall();
  return ret;
}


x86 assembly (clang, -O0):
<test_munlockall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   10a0 <getpagesize@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%esi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    0x2dec(%rip),%rax
or     (%rax),%edx
mov    0x2dfb(%rip),%rax
mov    (%rax),%ecx
mov    0x2dd2(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1040 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2daa(%rip),%rcx
cmp    (%rcx),%rax
jne    1220 <test_munlockall+0x80>
lea    0xdea(%rip),%rdi
call   1080 <perror@plt>
jmp    1427 <test_munlockall+0x287>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   1070 <mlockall@plt>
cmp    $0x0,%rax
je     1249 <test_munlockall+0xa9>
lea    0xdd6(%rip),%rdi
call   1080 <perror@plt>
jmp    1427 <test_munlockall+0x287>
mov    -0x8(%rbp),%rdi
call   10c0 <lock_check@plt>
cmp    $0x0,%rax
je     1261 <test_munlockall+0xc1>
jmp    1414 <test_munlockall+0x274>
mov    $0x0,%al
call   10b0 <munlockall@plt>
cmp    $0x0,%rax
je     1283 <test_munlockall+0xe3>
lea    0xdb2(%rip),%rdi
call   1080 <perror@plt>
jmp    1414 <test_munlockall+0x274>
mov    -0x8(%rbp),%rdi
call   1050 <unlock_lock_check@plt>
cmp    $0x0,%eax
je     129a <test_munlockall+0xfa>
jmp    1414 <test_munlockall+0x274>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%esi
call   1060 <munmap@plt>
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%esi
mov    0x2d3a(%rip),%rax
mov    (%rax),%edx
mov    0x2cf9(%rip),%rax
or     (%rax),%edx
mov    0x2d08(%rip),%rax
mov    (%rax),%ecx
mov    0x2cdf(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1040 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2cb7(%rip),%rcx
cmp    (%rcx),%rax
jne    1313 <test_munlockall+0x173>
lea    0xd2f(%rip),%rdi
call   1080 <perror@plt>
jmp    1427 <test_munlockall+0x287>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
mov    0x2cc5(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
or     %eax,%edi
call   1070 <mlockall@plt>
cmp    $0x0,%rax
je     134a <test_munlockall+0x1aa>
lea    0xd14(%rip),%rdi
call   1080 <perror@plt>
jmp    1414 <test_munlockall+0x274>
mov    -0x8(%rbp),%rdi
call   1030 <onfault_check@plt>
cmp    $0x0,%rax
je     1362 <test_munlockall+0x1c2>
jmp    1414 <test_munlockall+0x274>
mov    $0x0,%al
call   10b0 <munlockall@plt>
cmp    $0x0,%rax
je     1384 <test_munlockall+0x1e4>
lea    0xcb1(%rip),%rdi
call   1080 <perror@plt>
jmp    1414 <test_munlockall+0x274>
mov    -0x8(%rbp),%rdi
call   1090 <unlock_onfault_check@plt>
cmp    $0x0,%rax
je     139c <test_munlockall+0x1fc>
jmp    1414 <test_munlockall+0x274>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
mov    0x2c3c(%rip),%rax
or     (%rax),%edi
call   1070 <mlockall@plt>
cmp    $0x0,%rax
je     13ce <test_munlockall+0x22e>
lea    0xcb4(%rip),%rdi
call   1080 <perror@plt>
jmp    1427 <test_munlockall+0x287>
mov    -0x8(%rbp),%rdi
call   10c0 <lock_check@plt>
cmp    $0x0,%rax
je     13e6 <test_munlockall+0x246>
jmp    1414 <test_munlockall+0x274>
mov    $0x0,%al
call   10b0 <munlockall@plt>
cmp    $0x0,%rax
je     1408 <test_munlockall+0x268>
lea    0xc2d(%rip),%rdi
call   1080 <perror@plt>
jmp    1414 <test_munlockall+0x274>
mov    -0x8(%rbp),%rdi
call   1050 <unlock_lock_check@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%esi
call   1060 <munmap@plt>
mov    $0x0,%al
call   10b0 <munlockall@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_munlockall>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <getpagesize@plt>
mov    %rax,%r13
add    %r13d,%r13d
mov    0x2e39(%rip),%rax
mov    0x2dfa(%rip),%r15
mov    (%r15),%edx
or     (%rax),%edx
mov    0x2e06(%rip),%rbx
mov    0x2ddf(%rip),%r14
mov    (%r14),%ecx
or     (%rbx),%ecx
xor    %edi,%edi
mov    %r13d,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    0x2dbb(%rip),%r12
cmp    (%r12),%rax
je     130d <test_munlockall+0x16d>
mov    %rax,%rbp
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1070 <mlockall@plt>
test   %rax,%rax
jne    1316 <test_munlockall+0x176>
mov    %rbp,%rdi
call   10c0 <lock_check@plt>
test   %rax,%rax
jne    1347 <test_munlockall+0x1a7>
xor    %eax,%eax
call   10b0 <munlockall@plt>
test   %rax,%rax
jne    1329 <test_munlockall+0x189>
mov    %rbp,%rdi
call   1050 <unlock_lock_check@plt>
test   %eax,%eax
jne    1347 <test_munlockall+0x1a7>
mov    %rbp,%rdi
mov    %r13d,%esi
call   1060 <munmap@plt>
mov    (%r15),%edx
mov    0x2d99(%rip),%rax
or     (%rax),%edx
mov    (%r14),%ecx
or     (%rbx),%ecx
xor    %edi,%edi
mov    %r13d,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    (%r12),%rax
je     1332 <test_munlockall+0x192>
mov    %rax,%rbp
mov    0x2d5e(%rip),%r14
mov    (%r14),%edi
add    %edi,%edi
mov    0x2d32(%rip),%rbx
or     (%rbx),%edi
call   1070 <mlockall@plt>
test   %rax,%rax
jne    133b <test_munlockall+0x19b>
mov    %rbp,%rdi
call   1030 <onfault_check@plt>
test   %rax,%rax
jne    1347 <test_munlockall+0x1a7>
xor    %eax,%eax
call   10b0 <munlockall@plt>
test   %rax,%rax
jne    1329 <test_munlockall+0x189>
mov    %rbp,%rdi
call   1090 <unlock_onfault_check@plt>
test   %rax,%rax
jne    1347 <test_munlockall+0x1a7>
mov    (%r14),%edi
or     (%rbx),%edi
call   1070 <mlockall@plt>
test   %rax,%rax
jne    136f <test_munlockall+0x1cf>
mov    %rbp,%rdi
call   10c0 <lock_check@plt>
test   %rax,%rax
mov    $0x1,%ebx
jne    134c <test_munlockall+0x1ac>
xor    %eax,%eax
call   10b0 <munlockall@plt>
test   %rax,%rax
jne    1378 <test_munlockall+0x1d8>
mov    %rbp,%rdi
call   1050 <unlock_lock_check@plt>
mov    %eax,%ebx
jmp    134c <test_munlockall+0x1ac>
lea    0xcec(%rip),%rdi
jmp    131d <test_munlockall+0x17d>
lea    0xcf8(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%ebx
jmp    1357 <test_munlockall+0x1b7>
lea    0xcfb(%rip),%rdi
jmp    1342 <test_munlockall+0x1a2>
lea    0xcff(%rip),%rdi
jmp    131d <test_munlockall+0x17d>
lea    0xd12(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%ebx
mov    %rbp,%rdi
mov    %r13d,%esi
call   1060 <munmap@plt>
xor    %eax,%eax
call   10b0 <munlockall@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd02(%rip),%rdi
jmp    131d <test_munlockall+0x17d>
lea    0xcac(%rip),%rdi
call   1080 <perror@plt>
jmp    134c <test_munlockall+0x1ac>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [21 x i8] c"test_munlockall mmap\00"
@MCL_CURRENT = global i32 0
@.str.1 = [22 x i8] c"mlockall(MCL_CURRENT)\00"
@.str.2 = [13 x i8] c"munlockall()\00"
@.str.3 = [28 x i8] c"test_munlockall second mmap\00"
@MCL_FUTURE = global i32 0
@.str.4 = [36 x i8] c"mlockall(MCL_CURRENT | MCL_ONFAULT)\00"
@.str.5 = [35 x i8] c"mlockall(MCL_CURRENT | MCL_FUTURE)\00"
define i32 @test_munlockall() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i64
store i32 1, i32* %2
%4 = call i64 (...) @getpagesize()
store i64 %4, i64* %3
%5 = load i64, i64* %3
%6 = mul i64 2, %5
%7 = trunc i64 %6 to i32
%8 = load i32, i32* @PROT_READ
%9 = load i32, i32* @PROT_WRITE
%10 = or i32 %8, %9
%11 = load i32, i32* @MAP_ANONYMOUS
%12 = load i32, i32* @MAP_PRIVATE
%13 = or i32 %11, %12
%14 = call i8* @mmap(i32* null, i32 %7, i32 %10, i32 %13, i32 0, i32 0)
store i8* %14, i8** %1
%15 = load i8*, i8** %1
%16 = load i8*, i8** @MAP_FAILED
%17 = icmp eq i8* %15, %16
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %113
20: ; preds = %0
%21 = load i32, i32* @MCL_CURRENT
%22 = call i64 @mlockall(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %113
26: ; preds = %20
%27 = load i8*, i8** %1
%28 = call i64 @lock_check(i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %107
31: ; preds = %26
%32 = call i64 (...) @munlockall()
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %107
36: ; preds = %31
%37 = load i8*, i8** %1
%38 = call i32 @unlock_lock_check(i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
br label %107
41: ; preds = %36
%42 = load i8*, i8** %1
%43 = load i64, i64* %3
%44 = mul i64 2, %43
%45 = trunc i64 %44 to i32
%46 = call i32 @munmap(i8* %42, i32 %45)
%47 = load i64, i64* %3
%48 = mul i64 2, %47
%49 = trunc i64 %48 to i32
%50 = load i32, i32* @PROT_READ
%51 = load i32, i32* @PROT_WRITE
%52 = or i32 %50, %51
%53 = load i32, i32* @MAP_ANONYMOUS
%54 = load i32, i32* @MAP_PRIVATE
%55 = or i32 %53, %54
%56 = call i8* @mmap(i32* null, i32 %49, i32 %52, i32 %55, i32 0, i32 0)
store i8* %56, i8** %1
%57 = load i8*, i8** %1
%58 = load i8*, i8** @MAP_FAILED
%59 = icmp eq i8* %57, %58
br i1 %59, label %60, label %62
60: ; preds = %41
%61 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %113
62: ; preds = %41
%63 = load i32, i32* @MCL_CURRENT
%64 = load i32, i32* @MCL_FUTURE
%65 = shl i32 %64, 1
%66 = or i32 %63, %65
%67 = call i64 @mlockall(i32 %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %62
%70 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
br label %107
71: ; preds = %62
%72 = load i8*, i8** %1
%73 = call i64 @onfault_check(i8* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %71
br label %107
76: ; preds = %71
%77 = call i64 (...) @munlockall()
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %107
81: ; preds = %76
%82 = load i8*, i8** %1
%83 = call i64 @unlock_onfault_check(i8* %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %81
br label %107
86: ; preds = %81
%87 = load i32, i32* @MCL_CURRENT
%88 = load i32, i32* @MCL_FUTURE
%89 = or i32 %87, %88
%90 = call i64 @mlockall(i32 %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %86
%93 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %113
94: ; preds = %86
%95 = load i8*, i8** %1
%96 = call i64 @lock_check(i8* %95)
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %94
br label %107
99: ; preds = %94
%100 = call i64 (...) @munlockall()
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %99
%103 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %107
104: ; preds = %99
%105 = load i8*, i8** %1
%106 = call i32 @unlock_lock_check(i8* %105)
store i32 %106, i32* %2
br label %107
107: ; preds = %104, %102, %98, %85, %79, %75, %69, %40, %34, %30
%108 = load i8*, i8** %1
%109 = load i64, i64* %3
%110 = mul i64 2, %109
%111 = trunc i64 %110 to i32
%112 = call i32 @munmap(i8* %108, i32 %111)
br label %113
113: ; preds = %107, %92, %60, %24, %18
%114 = call i64 (...) @munlockall()
%115 = load i32, i32* %2
ret i32 %115
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [21 x i8] c"test_munlockall mmap\00"
@MCL_CURRENT = global i32 0
@.str.1 = [22 x i8] c"mlockall(MCL_CURRENT)\00"
@.str.2 = [13 x i8] c"munlockall()\00"
@.str.3 = [28 x i8] c"test_munlockall second mmap\00"
@MCL_FUTURE = global i32 0
@.str.4 = [36 x i8] c"mlockall(MCL_CURRENT | MCL_ONFAULT)\00"
@.str.5 = [35 x i8] c"mlockall(MCL_CURRENT | MCL_FUTURE)\00"
define i32 @test_munlockall() {
%1 = tail call i64 (...) @getpagesize()
%2 = trunc i64 %1 to i32
%3 = shl i32 %2, 1
%4 = load i32, i32* @PROT_READ
%5 = load i32, i32* @PROT_WRITE
%6 = or i32 %5, %4
%7 = load i32, i32* @MAP_ANONYMOUS
%8 = load i32, i32* @MAP_PRIVATE
%9 = or i32 %8, %7
%10 = tail call i8* @mmap(i32* null, i32 %3, i32 %6, i32 %9, i32 0, i32 0)
%11 = load i8*, i8** @MAP_FAILED
%12 = icmp eq i8* %10, %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %87
15: ; preds = %0
%16 = load i32, i32* @MCL_CURRENT
%17 = tail call i64 @mlockall(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %87
21: ; preds = %15
%22 = tail call i64 @lock_check(i8* %10)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %83
24: ; preds = %21
%25 = tail call i64 (...) @munlockall()
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %83
29: ; preds = %24
%30 = tail call i32 @unlock_lock_check(i8* %10)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %83
32: ; preds = %29
%33 = tail call i32 @munmap(i8* %10, i32 %3)
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @PROT_WRITE
%36 = or i32 %35, %34
%37 = load i32, i32* @MAP_ANONYMOUS
%38 = load i32, i32* @MAP_PRIVATE
%39 = or i32 %38, %37
%40 = tail call i8* @mmap(i32* null, i32 %3, i32 %36, i32 %39, i32 0, i32 0)
%41 = load i8*, i8** @MAP_FAILED
%42 = icmp eq i8* %40, %41
br i1 %42, label %43, label %45
43: ; preds = %32
%44 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %87
45: ; preds = %32
%46 = load i32, i32* @MCL_CURRENT
%47 = load i32, i32* @MCL_FUTURE
%48 = shl i32 %47, 1
%49 = or i32 %48, %46
%50 = tail call i64 @mlockall(i32 %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %45
%53 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
br label %83
54: ; preds = %45
%55 = tail call i64 @onfault_check(i8* %40)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %83
57: ; preds = %54
%58 = tail call i64 (...) @munlockall()
%59 = icmp eq i64 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %57
%61 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %83
62: ; preds = %57
%63 = tail call i64 @unlock_onfault_check(i8* %40)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %83
65: ; preds = %62
%66 = load i32, i32* @MCL_CURRENT
%67 = load i32, i32* @MCL_FUTURE
%68 = or i32 %67, %66
%69 = tail call i64 @mlockall(i32 %68)
%70 = icmp eq i64 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %65
%72 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %87
73: ; preds = %65
%74 = tail call i64 @lock_check(i8* %40)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %83
76: ; preds = %73
%77 = tail call i64 (...) @munlockall()
%78 = icmp eq i64 %77, 0
br i1 %78, label %81, label %79
79: ; preds = %76
%80 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %83
81: ; preds = %76
%82 = tail call i32 @unlock_lock_check(i8* %40)
br label %83
83: ; preds = %73, %62, %54, %29, %21, %81, %79, %60, %52, %27
%84 = phi i32 [ 1, %21 ], [ 1, %27 ], [ 1, %29 ], [ 1, %52 ], [ 1, %54 ], [ 1, %60 ], [ 1, %62 ], [ 1, %73 ], [ 1, %79 ], [ %82, %81 ]
%85 = phi i8* [ %10, %21 ], [ %10, %27 ], [ %10, %29 ], [ %40, %52 ], [ %40, %54 ], [ %40, %60 ], [ %40, %62 ], [ %40, %73 ], [ %40, %79 ], [ %40, %81 ]
%86 = tail call i32 @munmap(i8* %85, i32 %3)
br label %87
87: ; preds = %83, %71, %43, %19, %13
%88 = phi i32 [ 1, %13 ], [ 1, %19 ], [ %84, %83 ], [ 1, %43 ], [ 1, %71 ]
%89 = tail call i64 (...) @munlockall()
ret i32 %88
}