#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 /*<<< orphan*/ MCL_CURRENT;
int /*<<< orphan*/ PRIO_PGRP;
scalar_t__ adjust_oom_score(int const);
scalar_t__ mlockall(int /*<<< orphan*/);
scalar_t__ setpriority(int /*<<< orphan*/, int /*<<< orphan*/, int);
int become_bullet_proof(int prio) {
  const int kOOM_DISABLE = -17;
  int ret = 0;
  if (mlockall(MCL_CURRENT)) {
    ({});
    ret = -1;
  }
  if (adjust_oom_score(kOOM_DISABLE)) {
    ({});
    ret = -1;
  }
  if (setpriority(PRIO_PGRP, 0, prio)) {
    ({});
    ret = -1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<become_bullet_proof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffef,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1040 <mlockall@plt>
cmp    $0x0,%rax
je     1168 <become_bullet_proof+0x38>
movl   $0xffffffff,-0xc(%rbp)
mov    $0xffffffef,%edi
call   1050 <adjust_oom_score@plt>
cmp    $0x0,%rax
je     1183 <become_bullet_proof+0x53>
movl   $0xffffffff,-0xc(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
xor    %esi,%esi
call   1030 <setpriority@plt>
cmp    $0x0,%rax
je     11a7 <become_bullet_proof+0x77>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<become_bullet_proof>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
call   1040 <mlockall@plt>
mov    %rax,%r14
mov    $0xffffffef,%edi
call   1050 <adjust_oom_score@plt>
mov    %rax,%rbx
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <setpriority@plt>
or     %rbx,%rax
xor    %ecx,%ecx
or     %r14,%rax
setne  %cl
neg    %ecx
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@MCL_CURRENT = global i32 0
@PRIO_PGRP = global i32 0
define i32 @become_bullet_proof(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 -17, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* @MCL_CURRENT
%6 = call i64 @mlockall(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %4
br label %9
9: ; preds = %8, %1
%10 = call i64 @adjust_oom_score(i32 -17)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 -1, i32* %4
br label %13
13: ; preds = %12, %9
%14 = load i32, i32* @PRIO_PGRP
%15 = load i32, i32* %2
%16 = call i64 @setpriority(i32 %14, i32 0, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %4
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
@MCL_CURRENT = global i32 0
@PRIO_PGRP = global i32 0
define i32 @become_bullet_proof(i32 %0) {
%2 = load i32, i32* @MCL_CURRENT
%3 = tail call i64 @mlockall(i32 %2)
%4 = icmp ne i64 %3, 0
%5 = tail call i64 @adjust_oom_score(i32 -17)
%6 = icmp ne i64 %5, 0
%7 = load i32, i32* @PRIO_PGRP
%8 = tail call i64 @setpriority(i32 %7, i32 0, i32 %0)
%9 = icmp ne i64 %8, 0
%10 = select i1 %9, i1 true, i1 %6
%11 = select i1 %10, i1 true, i1 %4
%12 = sext i1 %11 to i32
ret i32 %12
}