#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 */
typedef scalar_t__ __u64;

/* Variables and functions */
int /*<<< orphan*/ F_ADD_SEALS;
int /*<<< orphan*/ abort();
long fcntl(int, int /*<<< orphan*/, scalar_t__);
scalar_t__ mfd_assert_get_seals(int);
int /*<<< orphan*/ printf(char *, int, unsigned long long, unsigned long long);
void mfd_assert_add_seals(int fd, __u64 seals) {
  long r;
  __u64 s;
  s = mfd_assert_get_seals(fd);
  r = fcntl(fd, F_ADD_SEALS, seals);
  if (r < 0) {
    printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", fd,
           (unsigned long long)s, (unsigned long long)seals);
    abort();
  }
}


x86 assembly (clang, -O0):
<mfd_assert_add_seals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <mfd_assert_get_seals@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1050 <fcntl@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    119d <mfd_assert_add_seals+0x5d>
mov    -0x4(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mfd_assert_add_seals>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1040 <mfd_assert_get_seals@plt>
mov    %rax,%r14
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %rbx,%rdx
call   1050 <fcntl@plt>
test   %rax,%rax
js     116e <mfd_assert_add_seals+0x2e>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe8b(%rip),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

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

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