#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 */
scalar_t__ EPERM;
scalar_t__ capget(int *, int *);
scalar_t__ capset(int *, int const *);
scalar_t__ errno;
int main(void) {
  int unused[6];
  const int data[] = {2, 4, 0, 8, 16, 0};
  const int v3 = 0x20080522;
  int head[] = {v3, 0};
  if (capget(head, unused) || head[0] != v3 || capset(head, data) == 0 ||
      errno != EPERM)
    return 77;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x20080522,-0x44(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x4c(%rbp)
lea    -0x4c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <capget@plt>
cmp    $0x0,%rax
jne    11b7 <main+0x97>
cmpl   $0x20080522,-0x4c(%rbp)
jne    11b7 <main+0x97>
lea    -0x4c(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <capset@plt>
cmp    $0x0,%rax
je     11b7 <main+0x97>
mov    0x2e3c(%rip),%rax
mov    (%rax),%rax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
je     11c3 <main+0xa3>
movl   $0x4d,-0x4(%rbp)
jmp    11ca <main+0xaa>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
mov    0xee4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x20080522,0x8(%rsp)
08 20
lea    0x8(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1040 <capget@plt>
mov    $0x4d,%ebx
test   %rax,%rax
jne    119b <main+0x7b>
cmpl   $0x20080522,0x8(%rsp)
20
jne    119b <main+0x7b>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <capset@plt>
test   %rax,%rax
je     119b <main+0x7b>
mov    0x2e5c(%rip),%rax
mov    (%rax),%rax
mov    0x2e42(%rip),%rcx
xor    %edx,%edx
cmp    (%rcx),%rax
mov    $0x4d,%ebx
cmove  %edx,%ebx
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.data = [6 x i32] [i32 2, i32 4, i32 0, i32 8, i32 16, i32 0]
@__const.main.head = [2 x i32] [i32 537396514, i32 0]
@errno = global i64 0
@EPERM = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i32]
%3 = alloca [6 x i32]
%4 = alloca i32
%5 = alloca [2 x i32]
store i32 0, i32* %1
%6 = bitcast [6 x i32]* %3 to i8*
store i32 537396514, i32* %4
%7 = bitcast [2 x i32]* %5 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%10 = call i64 @capget(i32* %8, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %0
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, 537396514
br i1 %15, label %25, label %16
16: ; preds = %12
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%19 = call i64 @capset(i32* %17, i32* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = load i64, i64* @errno
%23 = load i64, i64* @EPERM
%24 = icmp ne i64 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %21, %16, %12, %0
store i32 77, i32* %1
br label %27
26: ; preds = %21
store i32 0, i32* %1
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@__const.main.data = [6 x i32] [i32 2, i32 4, i32 0, i32 8, i32 16, i32 0]
@errno = global i64 0
@EPERM = global i64 0
define i32 @main() {
%1 = alloca [6 x i32]
%2 = alloca [6 x i32]
%3 = alloca i64
%4 = bitcast [6 x i32]* %1 to i8*
%5 = bitcast [6 x i32]* %2 to i8*
%6 = bitcast i64* %3 to i8*
store i64 537396514, i64* %3
%7 = bitcast i64* %3 to i32*
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%9 = call i64 @capget(i32* %7, i32* %8)
%10 = icmp ne i64 %9, 0
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 537396514
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %23, label %14
14: ; preds = %0
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%16 = call i64 @capset(i32* %7, i32* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = load i64, i64* @errno
%20 = load i64, i64* @EPERM
%21 = icmp eq i64 %19, %20
%22 = select i1 %21, i32 0, i32 77
br label %23
23: ; preds = %18, %0, %14
%24 = phi i32 [ 77, %14 ], [ 77, %0 ], [ %22, %18 ]
ret i32 %24
}