#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 */
struct udmabuf_create {
  int memfd;
  int offset;
  int size;
};
typedef void *off_t;
typedef int /*<<< orphan*/ create;

/* Variables and functions */
int /*<<< orphan*/ F_ADD_SEALS;
int /*<<< orphan*/ F_SEAL_SHRINK;
int /*<<< orphan*/ MFD_ALLOW_SEALING;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ UDMABUF_CREATE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ftruncate(int, void *);
int getpagesize();
int ioctl(int, int /*<<< orphan*/, struct udmabuf_create *);
int memfd_create(char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct udmabuf_create *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct udmabuf_create create;
  int devfd, memfd, buf, ret;
  off_t size;
  void *mem;
  devfd = open("/dev/udmabuf", O_RDWR);
  if (devfd < 0) {
    printf("%s: [skip,no-udmabuf]\n", "drivers/dma-buf/udmabuf");
    exit(77);
  }
  memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING);
  if (memfd < 0) {
    printf("%s: [skip,no-memfd]\n", "drivers/dma-buf/udmabuf");
    exit(77);
  }
  ret = fcntl(memfd, F_ADD_SEALS, F_SEAL_SHRINK);
  if (ret < 0) {
    printf("%s: [skip,fcntl-add-seals]\n", "drivers/dma-buf/udmabuf");
    exit(77);
  }
  size = getpagesize() * 4;
  ret = ftruncate(memfd, size);
  if (ret == -1) {
    printf("%s: [FAIL,memfd-truncate]\n", "drivers/dma-buf/udmabuf");
    exit(1);
  }
  memset(&create, 0, sizeof(create));
  create.memfd = memfd;
  create.offset = getpagesize() / 2;
  create.size = getpagesize();
  buf = ioctl(devfd, UDMABUF_CREATE, &create);
  if (buf >= 0) {
    printf("%s: [FAIL,test-1]\n", "drivers/dma-buf/udmabuf");
    exit(1);
  }
  create.memfd = memfd;
  create.offset = 0;
  create.size = getpagesize() / 2;
  buf = ioctl(devfd, UDMABUF_CREATE, &create);
  if (buf >= 0) {
    printf("%s: [FAIL,test-2]\n", "drivers/dma-buf/udmabuf");
    exit(1);
  }
  create.memfd = 0;
  create.offset = 0;
  create.size = size;
  buf = ioctl(devfd, UDMABUF_CREATE, &create);
  if (buf >= 0) {
    printf("%s: [FAIL,test-3]\n", "drivers/dma-buf/udmabuf");
    exit(1);
  }
  create.memfd = memfd;
  create.offset = 0;
  create.size = size;
  buf = ioctl(devfd, UDMABUF_CREATE, &create);
  if (buf < 0) {
    printf("%s: [FAIL,test-4]\n", "drivers/dma-buf/udmabuf");
    exit(1);
  }
  fprintf(stderr, "%s: ok\n", "drivers/dma-buf/udmabuf");
  close(buf);
  close(memfd);
  close(devfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
lea    0xe2a(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1205 <main+0x55>
lea    0xe1e(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <printf@plt>
mov    $0x4d,%edi
call   10d0 <exit@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
lea    0xe27(%rip),%rdi
call   1030 <memfd_create@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1244 <main+0x94>
lea    0xe1b(%rip),%rdi
lea    0xdef(%rip),%rsi
call   1050 <printf@plt>
mov    $0x4d,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%edi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
mov    0x2d79(%rip),%rax
mov    (%rax),%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    1288 <main+0xd8>
lea    0xdec(%rip),%rdi
lea    0xdab(%rip),%rsi
call   1050 <printf@plt>
mov    $0x4d,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10c0 <getpagesize@plt>
shl    $0x2,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   1060 <ftruncate@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    12ce <main+0x11e>
lea    0xdc2(%rip),%rdi
lea    0xd65(%rip),%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   10c0 <getpagesize@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   10c0 <getpagesize@plt>
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2cbe(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     133f <main+0x18f>
lea    0xd6c(%rip),%rdi
lea    0xcf4(%rip),%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   10c0 <getpagesize@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     139d <main+0x1ed>
lea    0xd21(%rip),%rdi
lea    0xc96(%rip),%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2c0c(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     13f1 <main+0x241>
lea    0xce0(%rip),%rdi
lea    0xc42(%rip),%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2bb9(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1444 <main+0x294>
lea    0xca0(%rip),%rdi
lea    0xbef(%rip),%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
lea    0xc8d(%rip),%rsi
lea    0xbc9(%rip),%rdx
call   10a0 <fprintf@plt>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
lea    0xe34(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     134f <main+0x19f>
mov    %eax,%r14d
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
lea    0xe50(%rip),%rdi
call   1030 <memfd_create@plt>
test   %eax,%eax
js     1358 <main+0x1a8>
mov    %eax,%ebp
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
mov    0x2dc5(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1040 <fcntl@plt>
test   %eax,%eax
js     1361 <main+0x1b1>
xor    %eax,%eax
call   10c0 <getpagesize@plt>
mov    %eax,%ebx
shl    $0x2,%ebx
movslq %ebx,%rsi
mov    %ebp,%edi
call   1060 <ftruncate@plt>
cmp    $0xffffffff,%eax
je     137e <main+0x1ce>
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    %ebp,(%rsp)
xor    %eax,%eax
call   10c0 <getpagesize@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,0x4(%rsp)
xor    %eax,%eax
call   10c0 <getpagesize@plt>
mov    %eax,0x8(%rsp)
mov    0x2d52(%rip),%r12
mov    (%r12),%esi
mov    %r14d,%edi
mov    %r15,%rdx
call   1080 <ioctl@plt>
test   %eax,%eax
jns    1387 <main+0x1d7>
mov    %ebp,(%rsp)
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   10c0 <getpagesize@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,0x8(%rsp)
mov    (%r12),%esi
mov    %rsp,%rdx
mov    %r14d,%edi
call   1080 <ioctl@plt>
test   %eax,%eax
jns    1390 <main+0x1e0>
movq   $0x0,(%rsp)
mov    %ebx,0x8(%rsp)
mov    (%r12),%esi
mov    %rsp,%rdx
mov    %r14d,%edi
call   1080 <ioctl@plt>
test   %eax,%eax
jns    1399 <main+0x1e9>
mov    %ebp,(%rsp)
movl   $0x0,0x4(%rsp)
mov    %ebx,0x8(%rsp)
mov    (%r12),%esi
mov    %rsp,%rdx
mov    %r14d,%edi
call   1080 <ioctl@plt>
test   %eax,%eax
js     13a2 <main+0x1f2>
mov    %eax,%ebx
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
lea    0xcff(%rip),%rdx
call   10a0 <fprintf@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    %r14d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb7(%rip),%rdi
jmp    1368 <main+0x1b8>
lea    0xcea(%rip),%rdi
jmp    1368 <main+0x1b8>
lea    0xcf6(%rip),%rdi
lea    0xcb5(%rip),%rsi
call   1050 <printf@plt>
mov    $0x4d,%edi
call   10d0 <exit@plt>
lea    0xcf5(%rip),%rdi
jmp    13a9 <main+0x1f9>
lea    0xd07(%rip),%rdi
jmp    13a9 <main+0x1f9>
lea    0xd11(%rip),%rdi
jmp    13a9 <main+0x1f9>
lea    0xd1b(%rip),%rdi
jmp    13a9 <main+0x1f9>
lea    0xd25(%rip),%rdi
lea    0xc74(%rip),%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.udmabuf_create = type { i32, i32, i32 }
@.str = [13 x i8] c"/dev/udmabuf\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"%s: [skip,no-udmabuf]\0A\00"
@.str.2 = [24 x i8] c"drivers/dma-buf/udmabuf\00"
@.str.3 = [13 x i8] c"udmabuf-test\00"
@MFD_ALLOW_SEALING = global i32 0
@.str.4 = [21 x i8] c"%s: [skip,no-memfd]\0A\00"
@F_ADD_SEALS = global i32 0
@F_SEAL_SHRINK = global i32 0
@.str.5 = [28 x i8] c"%s: [skip,fcntl-add-seals]\0A\00"
@.str.6 = [27 x i8] c"%s: [FAIL,memfd-truncate]\0A\00"
@UDMABUF_CREATE = global i32 0
@.str.7 = [19 x i8] c"%s: [FAIL,test-1]\0A\00"
@.str.8 = [19 x i8] c"%s: [FAIL,test-2]\0A\00"
@.str.9 = [19 x i8] c"%s: [FAIL,test-3]\0A\00"
@.str.10 = [19 x i8] c"%s: [FAIL,test-4]\0A\00"
@stderr = global i32 0
@.str.11 = [8 x i8] c"%s: ok\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.udmabuf_create
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @O_RDWR
%14 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @exit(i32 77)
unreachable
20: ; preds = %2
%21 = load i32, i32* @MFD_ALLOW_SEALING
%22 = call i32 @memfd_create(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @exit(i32 77)
unreachable
28: ; preds = %20
%29 = load i32, i32* %8
%30 = load i32, i32* @F_ADD_SEALS
%31 = load i32, i32* @F_SEAL_SHRINK
%32 = call i32 @fcntl(i32 %29, i32 %30, i32 %31)
store i32 %32, i32* %10
%33 = load i32, i32* %10
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 77)
unreachable
38: ; preds = %28
%39 = call i32 (...) @getpagesize()
%40 = mul nsw i32 %39, 4
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %11
%43 = load i32, i32* %8
%44 = load i8*, i8** %11
%45 = call i32 @ftruncate(i32 %43, i8* %44)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %38
%49 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %38
%52 = call i32 @memset(%struct.udmabuf_create* %6, i32 0, i32 12)
%53 = load i32, i32* %8
%54 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 %53, i32* %54
%55 = call i32 (...) @getpagesize()
%56 = sdiv i32 %55, 2
%57 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 %56, i32* %57
%58 = call i32 (...) @getpagesize()
%59 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %58, i32* %59
%60 = load i32, i32* %7
%61 = load i32, i32* @UDMABUF_CREATE
%62 = call i32 @ioctl(i32 %60, i32 %61, %struct.udmabuf_create* %6)
store i32 %62, i32* %9
%63 = load i32, i32* %9
%64 = icmp sge i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %51
%66 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %51
%69 = load i32, i32* %8
%70 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 %69, i32* %70
%71 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 0, i32* %71
%72 = call i32 (...) @getpagesize()
%73 = sdiv i32 %72, 2
%74 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %73, i32* %74
%75 = load i32, i32* %7
%76 = load i32, i32* @UDMABUF_CREATE
%77 = call i32 @ioctl(i32 %75, i32 %76, %struct.udmabuf_create* %6)
store i32 %77, i32* %9
%78 = load i32, i32* %9
%79 = icmp sge i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %68
%81 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %68
%84 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 0, i32* %84
%85 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 0, i32* %85
%86 = load i8*, i8** %11
%87 = ptrtoint i8* %86 to i32
%88 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %87, i32* %88
%89 = load i32, i32* %7
%90 = load i32, i32* @UDMABUF_CREATE
%91 = call i32 @ioctl(i32 %89, i32 %90, %struct.udmabuf_create* %6)
store i32 %91, i32* %9
%92 = load i32, i32* %9
%93 = icmp sge i32 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %83
%95 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %83
%98 = load i32, i32* %8
%99 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 %98, i32* %99
%100 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 0, i32* %100
%101 = load i8*, i8** %11
%102 = ptrtoint i8* %101 to i32
%103 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %102, i32* %103
%104 = load i32, i32* %7
%105 = load i32, i32* @UDMABUF_CREATE
%106 = call i32 @ioctl(i32 %104, i32 %105, %struct.udmabuf_create* %6)
store i32 %106, i32* %9
%107 = load i32, i32* %9
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %97
%110 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %97
%113 = load i32, i32* @stderr
%114 = call i32 @fprintf(i32 %113, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%115 = load i32, i32* %9
%116 = call i32 @close(i32 %115)
%117 = load i32, i32* %8
%118 = call i32 @close(i32 %117)
%119 = load i32, i32* %7
%120 = call i32 @close(i32 %119)
ret i32 0
}

LLVM IR (-O2):
%struct.udmabuf_create = type { i32, i32, i32 }
@.str = [13 x i8] c"/dev/udmabuf\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"%s: [skip,no-udmabuf]\0A\00"
@.str.2 = [24 x i8] c"drivers/dma-buf/udmabuf\00"
@.str.3 = [13 x i8] c"udmabuf-test\00"
@MFD_ALLOW_SEALING = global i32 0
@.str.4 = [21 x i8] c"%s: [skip,no-memfd]\0A\00"
@F_ADD_SEALS = global i32 0
@F_SEAL_SHRINK = global i32 0
@.str.5 = [28 x i8] c"%s: [skip,fcntl-add-seals]\0A\00"
@.str.6 = [27 x i8] c"%s: [FAIL,memfd-truncate]\0A\00"
@UDMABUF_CREATE = global i32 0
@.str.7 = [19 x i8] c"%s: [FAIL,test-1]\0A\00"
@.str.8 = [19 x i8] c"%s: [FAIL,test-2]\0A\00"
@.str.9 = [19 x i8] c"%s: [FAIL,test-3]\0A\00"
@.str.10 = [19 x i8] c"%s: [FAIL,test-4]\0A\00"
@stderr = global i32 0
@.str.11 = [8 x i8] c"%s: ok\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.udmabuf_create
%4 = bitcast %struct.udmabuf_create* %3 to i8*
%5 = load i32, i32* @O_RDWR
%6 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @exit(i32 77)
unreachable
11: ; preds = %2
%12 = load i32, i32* @MFD_ALLOW_SEALING
%13 = tail call i32 @memfd_create(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 77)
unreachable
18: ; preds = %11
%19 = load i32, i32* @F_ADD_SEALS
%20 = load i32, i32* @F_SEAL_SHRINK
%21 = tail call i32 @fcntl(i32 %13, i32 %19, i32 %20)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @exit(i32 77)
unreachable
26: ; preds = %18
%27 = tail call i32 (...) @getpagesize()
%28 = shl nsw i32 %27, 2
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i8*
%31 = tail call i32 @ftruncate(i32 %13, i8* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %26
%37 = call i32 @memset(%struct.udmabuf_create* %3, i32 0, i32 12)
%38 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %3, i64 0, i32 0
store i32 %13, i32* %38
%39 = call i32 (...) @getpagesize()
%40 = sdiv i32 %39, 2
%41 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %3, i64 0, i32 1
store i32 %40, i32* %41
%42 = call i32 (...) @getpagesize()
%43 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %3, i64 0, i32 2
store i32 %42, i32* %43
%44 = load i32, i32* @UDMABUF_CREATE
%45 = call i32 @ioctl(i32 %6, i32 %44, %struct.udmabuf_create* %3)
%46 = icmp sgt i32 %45, -1
br i1 %46, label %47, label %50
47: ; preds = %36
%48 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %36
store i32 %13, i32* %38
store i32 0, i32* %41
%51 = call i32 (...) @getpagesize()
%52 = sdiv i32 %51, 2
store i32 %52, i32* %43
%53 = load i32, i32* @UDMABUF_CREATE
%54 = call i32 @ioctl(i32 %6, i32 %53, %struct.udmabuf_create* %3)
%55 = icmp sgt i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %50
store i32 0, i32* %38
store i32 0, i32* %41
store i32 %28, i32* %43
%60 = load i32, i32* @UDMABUF_CREATE
%61 = call i32 @ioctl(i32 %6, i32 %60, %struct.udmabuf_create* %3)
%62 = icmp sgt i32 %61, -1
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %59
store i32 %13, i32* %38
store i32 0, i32* %41
store i32 %28, i32* %43
%67 = load i32, i32* @UDMABUF_CREATE
%68 = call i32 @ioctl(i32 %6, i32 %67, %struct.udmabuf_create* %3)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %66
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%76 = call i32 @close(i32 %68)
%77 = call i32 @close(i32 %13)
%78 = call i32 @close(i32 %6)
ret i32 0
}