#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, 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, -1, 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, -1, 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
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2da7(%rip),%rcx
cmp    (%rcx),%rax
jne    1223 <test_munlockall+0x83>
lea    0xde7(%rip),%rdi
call   1080 <perror@plt>
jmp    142d <test_munlockall+0x28d>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1070 <mlockall@plt>
cmp    $0x0,%rax
je     124c <test_munlockall+0xac>
lea    0xdd3(%rip),%rdi
call   1080 <perror@plt>
jmp    142d <test_munlockall+0x28d>
mov    -0x8(%rbp),%rdi
call   10c0 <lock_check@plt>
cmp    $0x0,%rax
je     1264 <test_munlockall+0xc4>
jmp    141a <test_munlockall+0x27a>
mov    $0x0,%al
call   10b0 <munlockall@plt>
cmp    $0x0,%rax
je     1286 <test_munlockall+0xe6>
lea    0xdaf(%rip),%rdi
call   1080 <perror@plt>
jmp    141a <test_munlockall+0x27a>
mov    -0x8(%rbp),%rdi
call   1050 <unlock_lock_check@plt>
cmp    $0x0,%eax
je     129d <test_munlockall+0xfd>
jmp    141a <test_munlockall+0x27a>
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    0x2d37(%rip),%rax
mov    (%rax),%edx
mov    0x2cf6(%rip),%rax
or     (%rax),%edx
mov    0x2d05(%rip),%rax
mov    (%rax),%ecx
mov    0x2cdc(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2cb1(%rip),%rcx
cmp    (%rcx),%rax
jne    1319 <test_munlockall+0x179>
lea    0xd29(%rip),%rdi
call   1080 <perror@plt>
jmp    142d <test_munlockall+0x28d>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
or     %eax,%edi
call   1070 <mlockall@plt>
cmp    $0x0,%rax
je     1350 <test_munlockall+0x1b0>
lea    0xd0e(%rip),%rdi
call   1080 <perror@plt>
jmp    141a <test_munlockall+0x27a>
mov    -0x8(%rbp),%rdi
call   1030 <onfault_check@plt>
cmp    $0x0,%rax
je     1368 <test_munlockall+0x1c8>
jmp    141a <test_munlockall+0x27a>
mov    $0x0,%al
call   10b0 <munlockall@plt>
cmp    $0x0,%rax
je     138a <test_munlockall+0x1ea>
lea    0xcab(%rip),%rdi
call   1080 <perror@plt>
jmp    141a <test_munlockall+0x27a>
mov    -0x8(%rbp),%rdi
call   1090 <unlock_onfault_check@plt>
cmp    $0x0,%rax
je     13a2 <test_munlockall+0x202>
jmp    141a <test_munlockall+0x27a>
mov    0x2c1f(%rip),%rax
mov    (%rax),%edi
mov    0x2c36(%rip),%rax
or     (%rax),%edi
call   1070 <mlockall@plt>
cmp    $0x0,%rax
je     13d4 <test_munlockall+0x234>
lea    0xcae(%rip),%rdi
call   1080 <perror@plt>
jmp    142d <test_munlockall+0x28d>
mov    -0x8(%rbp),%rdi
call   10c0 <lock_check@plt>
cmp    $0x0,%rax
je     13ec <test_munlockall+0x24c>
jmp    141a <test_munlockall+0x27a>
mov    $0x0,%al
call   10b0 <munlockall@plt>
cmp    $0x0,%rax
je     140e <test_munlockall+0x26e>
lea    0xc27(%rip),%rdi
call   1080 <perror@plt>
jmp    141a <test_munlockall+0x27a>
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
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    0x2db8(%rip),%r12
cmp    (%r12),%rax
je     1313 <test_munlockall+0x173>
mov    %rax,%rbp
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
call   1070 <mlockall@plt>
test   %rax,%rax
jne    131c <test_munlockall+0x17c>
mov    %rbp,%rdi
call   10c0 <lock_check@plt>
test   %rax,%rax
jne    134d <test_munlockall+0x1ad>
xor    %eax,%eax
call   10b0 <munlockall@plt>
test   %rax,%rax
jne    132f <test_munlockall+0x18f>
mov    %rbp,%rdi
call   1050 <unlock_lock_check@plt>
test   %eax,%eax
jne    134d <test_munlockall+0x1ad>
mov    %rbp,%rdi
mov    %r13d,%esi
call   1060 <munmap@plt>
mov    (%r15),%edx
mov    0x2d96(%rip),%rax
or     (%rax),%edx
mov    (%r14),%ecx
or     (%rbx),%ecx
xor    %edi,%edi
mov    %r13d,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    (%r12),%rax
je     1338 <test_munlockall+0x198>
mov    %rax,%rbp
mov    0x2d58(%rip),%r14
mov    (%r14),%edi
add    %edi,%edi
mov    0x2d2c(%rip),%rbx
or     (%rbx),%edi
call   1070 <mlockall@plt>
test   %rax,%rax
jne    1341 <test_munlockall+0x1a1>
mov    %rbp,%rdi
call   1030 <onfault_check@plt>
test   %rax,%rax
jne    134d <test_munlockall+0x1ad>
xor    %eax,%eax
call   10b0 <munlockall@plt>
test   %rax,%rax
jne    132f <test_munlockall+0x18f>
mov    %rbp,%rdi
call   1090 <unlock_onfault_check@plt>
test   %rax,%rax
jne    134d <test_munlockall+0x1ad>
mov    (%r14),%edi
or     (%rbx),%edi
call   1070 <mlockall@plt>
test   %rax,%rax
jne    1375 <test_munlockall+0x1d5>
mov    %rbp,%rdi
call   10c0 <lock_check@plt>
test   %rax,%rax
mov    $0x1,%ebx
jne    1352 <test_munlockall+0x1b2>
xor    %eax,%eax
call   10b0 <munlockall@plt>
test   %rax,%rax
jne    137e <test_munlockall+0x1de>
mov    %rbp,%rdi
call   1050 <unlock_lock_check@plt>
mov    %eax,%ebx
jmp    1352 <test_munlockall+0x1b2>
lea    0xce6(%rip),%rdi
jmp    1323 <test_munlockall+0x183>
lea    0xcf2(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%ebx
jmp    135d <test_munlockall+0x1bd>
lea    0xcf5(%rip),%rdi
jmp    1348 <test_munlockall+0x1a8>
lea    0xcf9(%rip),%rdi
jmp    1323 <test_munlockall+0x183>
lea    0xd0c(%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    0xcfc(%rip),%rdi
jmp    1323 <test_munlockall+0x183>
lea    0xca6(%rip),%rdi
call   1080 <perror@plt>
jmp    1352 <test_munlockall+0x1b2>

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 -1, 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 -1, 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 -1, 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 -1, 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
}