#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*/ F_ADD_SEALS;
int /*<<< orphan*/ abort();
int fcntl(int, int /*<<< orphan*/, unsigned int);
unsigned int mfd_assert_get_seals(int);
int /*<<< orphan*/ printf(char *, int, unsigned int, unsigned int);
void mfd_assert_add_seals(int fd, unsigned int seals) {
  int r;
  unsigned int s;
  s = mfd_assert_get_seals(fd);
  r = fcntl(fd, F_ADD_SEALS, seals);
  if (r < 0) {
    printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals);
    abort();
  }
}


x86 assembly (clang, -O0):
<mfd_assert_add_seals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <mfd_assert_get_seals@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
call   1050 <fcntl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1196 <mfd_assert_add_seals+0x56>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe76(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mfd_assert_add_seals>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
call   1040 <mfd_assert_get_seals@plt>
mov    %eax,%r14d
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %ebx,%edx
call   1050 <fcntl@plt>
test   %eax,%eax
js     116b <mfd_assert_add_seals+0x2b>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe8e(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1060 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@F_ADD_SEALS = global i32 0
@.str = [36 x i8] c"ADD_SEALS(%d, %u -> %u) failed: %m\0A\00"
define void @mfd_assert_add_seals(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @mfd_assert_get_seals(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %3
%10 = load i32, i32* @F_ADD_SEALS
%11 = load i32, i32* %4
%12 = call i32 @fcntl(i32 %9, i32 %10, i32 %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i32, i32* %3
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i32 %18)
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %2
ret void
}

LLVM IR (-O2):
@F_ADD_SEALS = global i32 0
@.str = [36 x i8] c"ADD_SEALS(%d, %u -> %u) failed: %m\0A\00"
define void @mfd_assert_add_seals(i32 %0, i32 %1) {
%3 = tail call i32 @mfd_assert_get_seals(i32 %0)
%4 = load i32, i32* @F_ADD_SEALS
%5 = tail call i32 @fcntl(i32 %0, i32 %4, i32 %1)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %3, i32 %1)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %2
ret void
}