#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 CAP_LAST_CAP;
int CAP_SETPCAP;
int /*<<< orphan*/ PR_CAPBSET_DROP;
int /*<<< orphan*/ _ensure(int, int /*<<< orphan*/);
int /*<<< orphan*/ _ensure_argc(int, int, int);
int /*<<< orphan*/ chain_command(int, int, char **);
int /*<<< orphan*/ in_list(int);
int /*<<< orphan*/ prctl(int /*<<< orphan*/, int, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  _ensure_argc(34, 2, argc);
  for (int cap = 0; cap <= CAP_LAST_CAP; ++cap)
    if (!in_list(cap) && cap != CAP_SETPCAP)
      _ensure(38, prctl(PR_CAPBSET_DROP, cap, 0, 0, 0));
  if (!in_list(CAP_SETPCAP))
    _ensure(41, prctl(PR_CAPBSET_DROP, CAP_SETPCAP, 0, 0, 0));
  _ensure(43, chain_command(1, argc, argv));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x22,%edi
mov    $0x2,%esi
call   1030 <_ensure_argc@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e67(%rip),%rcx
cmp    (%rcx),%eax
jg     11ed <main+0x9d>
mov    -0x14(%rbp),%edi
call   1050 <in_list@plt>
cmp    $0x0,%eax
jne    11da <main+0x8a>
mov    -0x14(%rbp),%eax
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%eax
je     11da <main+0x8a>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1040 <prctl@plt>
mov    %eax,%esi
mov    $0x26,%edi
call   1070 <_ensure@plt>
jmp    11df <main+0x8f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x2f>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
call   1050 <in_list@plt>
cmp    $0x0,%eax
jne    1230 <main+0xe0>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1040 <prctl@plt>
mov    %eax,%esi
mov    $0x29,%edi
call   1070 <_ensure@plt>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
call   1060 <chain_command@plt>
mov    %eax,%esi
mov    $0x2b,%edi
call   1070 <_ensure@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x22,%edi
mov    $0x2,%esi
mov    %r15d,%edx
call   1030 <_ensure_argc@plt>
mov    0x2e76(%rip),%rbp
cmpl   $0x0,0x0(%rbp)
js     11d9 <main+0x89>
mov    $0xffffffff,%ebx
mov    0x2e44(%rip),%r12
mov    0x2e45(%rip),%r13
jmp    11a5 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    0x0(%rbp),%ebx
jge    11d9 <main+0x89>
add    $0x1,%ebx
mov    %ebx,%edi
call   1050 <in_list@plt>
test   %eax,%eax
jne    11a0 <main+0x50>
cmp    (%r12),%ebx
je     11a0 <main+0x50>
mov    0x0(%r13),%edi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <prctl@plt>
mov    $0x26,%edi
mov    %eax,%esi
call   1070 <_ensure@plt>
jmp    11a0 <main+0x50>
mov    0x2df0(%rip),%rbx
mov    (%rbx),%edi
call   1050 <in_list@plt>
test   %eax,%eax
jne    120e <main+0xbe>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <prctl@plt>
mov    $0x29,%edi
mov    %eax,%esi
call   1070 <_ensure@plt>
mov    $0x1,%edi
mov    %r15d,%esi
mov    %r14,%rdx
call   1060 <chain_command@plt>
mov    $0x2b,%edi
mov    %eax,%esi
call   1070 <_ensure@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CAP_LAST_CAP = global i32 0
@CAP_SETPCAP = global i32 0
@PR_CAPBSET_DROP = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = call i32 @_ensure_argc(i32 34, i32 2, i32 %7)
store i32 0, i32* %6
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %6
%11 = load i32, i32* @CAP_LAST_CAP
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i32, i32* %6
%15 = call i32 @in_list(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %13
%18 = load i32, i32* %6
%19 = load i32, i32* @CAP_SETPCAP
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32, i32* @PR_CAPBSET_DROP
%23 = load i32, i32* %6
%24 = call i32 @prctl(i32 %22, i32 %23, i32 0, i32 0, i32 0)
%25 = call i32 @_ensure(i32 38, i32 %24)
br label %26
26: ; preds = %21, %17, %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %9
30: ; preds = %9
%31 = load i32, i32* @CAP_SETPCAP
%32 = call i32 @in_list(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %30
%35 = load i32, i32* @PR_CAPBSET_DROP
%36 = load i32, i32* @CAP_SETPCAP
%37 = call i32 @prctl(i32 %35, i32 %36, i32 0, i32 0, i32 0)
%38 = call i32 @_ensure(i32 41, i32 %37)
br label %39
39: ; preds = %34, %30
%40 = load i32, i32* %4
%41 = load i8**, i8*** %5
%42 = call i32 @chain_command(i32 1, i32 %40, i8** %41)
%43 = call i32 @_ensure(i32 43, i32 %42)
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@CAP_LAST_CAP = global i32 0
@CAP_SETPCAP = global i32 0
@PR_CAPBSET_DROP = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @_ensure_argc(i32 34, i32 2, i32 %0)
%4 = load i32, i32* @CAP_LAST_CAP
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %21, %2
%7 = load i32, i32* @CAP_SETPCAP
%8 = tail call i32 @in_list(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %25, label %30
10: ; preds = %2, %21
%11 = phi i32 [ %22, %21 ], [ 0, %2 ]
%12 = tail call i32 @in_list(i32 %11)
%13 = icmp ne i32 %12, 0
%14 = load i32, i32* @CAP_SETPCAP
%15 = icmp eq i32 %11, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %21, label %17
17: ; preds = %10
%18 = load i32, i32* @PR_CAPBSET_DROP
%19 = tail call i32 @prctl(i32 %18, i32 %11, i32 0, i32 0, i32 0)
%20 = tail call i32 @_ensure(i32 38, i32 %19)
br label %21
21: ; preds = %10, %17
%22 = add nuw nsw i32 %11, 1
%23 = load i32, i32* @CAP_LAST_CAP
%24 = icmp slt i32 %11, %23
br i1 %24, label %10, label %6
25: ; preds = %6
%26 = load i32, i32* @PR_CAPBSET_DROP
%27 = load i32, i32* @CAP_SETPCAP
%28 = tail call i32 @prctl(i32 %26, i32 %27, i32 0, i32 0, i32 0)
%29 = tail call i32 @_ensure(i32 41, i32 %28)
br label %30
30: ; preds = %25, %6
%31 = tail call i32 @chain_command(i32 1, i32 %0, i8** %1)
%32 = tail call i32 @_ensure(i32 43, i32 %31)
ret i32 0
}