#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*/ MFD_CLOEXEC;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ UDMABUF_CREATE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
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_CLOEXEC);
  if (memfd < 0) {
    printf("%s: [skip,no-memfd]\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    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0xe3a(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11f5 <main+0x55>
lea    0xe2e(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <printf@plt>
mov    $0x4d,%edi
call   10c0 <exit@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
lea    0xe37(%rip),%rdi
call   1030 <memfd_create@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1234 <main+0x94>
lea    0xe2b(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1040 <printf@plt>
mov    $0x4d,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10b0 <getpagesize@plt>
shl    $0x2,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   1050 <ftruncate@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    127a <main+0xda>
lea    0xdfa(%rip),%rdi
lea    0xdb9(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   10b0 <getpagesize@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   10b0 <getpagesize@plt>
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1070 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     12eb <main+0x14b>
lea    0xda4(%rip),%rdi
lea    0xd48(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   10b0 <getpagesize@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1070 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     1349 <main+0x1a9>
lea    0xd59(%rip),%rdi
lea    0xcea(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2c78(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1070 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     139d <main+0x1fd>
lea    0xd18(%rip),%rdi
lea    0xc96(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <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    0x2c25(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1070 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    13f0 <main+0x250>
lea    0xcd8(%rip),%rdi
lea    0xc43(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
lea    0xcc5(%rip),%rsi
lea    0xc1d(%rip),%rdx
call   1090 <fprintf@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
mov    -0x24(%rbp),%edi
call   1080 <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    0x2e35(%rip),%rax
mov    (%rax),%esi
lea    0xe44(%rip),%rdi
call   10a0 <open@plt>
test   %eax,%eax
js     131e <main+0x17e>
mov    %eax,%r14d
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
lea    0xe60(%rip),%rdi
call   1030 <memfd_create@plt>
test   %eax,%eax
js     1327 <main+0x187>
mov    %eax,%ebp
xor    %eax,%eax
call   10b0 <getpagesize@plt>
mov    %eax,%ebx
shl    $0x2,%ebx
movslq %ebx,%rsi
mov    %ebp,%edi
call   1050 <ftruncate@plt>
cmp    $0xffffffff,%eax
je     1344 <main+0x1a4>
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    %ebp,(%rsp)
xor    %eax,%eax
call   10b0 <getpagesize@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,0x4(%rsp)
xor    %eax,%eax
call   10b0 <getpagesize@plt>
mov    %eax,0x8(%rsp)
mov    0x2d9b(%rip),%r12
mov    (%r12),%esi
mov    %r14d,%edi
mov    %r15,%rdx
call   1070 <ioctl@plt>
test   %eax,%eax
jns    134d <main+0x1ad>
mov    %ebp,(%rsp)
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   10b0 <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   1070 <ioctl@plt>
test   %eax,%eax
jns    1356 <main+0x1b6>
movq   $0x0,(%rsp)
mov    %ebx,0x8(%rsp)
mov    (%r12),%esi
mov    %rsp,%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
test   %eax,%eax
jns    135f <main+0x1bf>
mov    %ebp,(%rsp)
movl   $0x0,0x4(%rsp)
mov    %ebx,0x8(%rsp)
mov    (%r12),%esi
mov    %rsp,%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
test   %eax,%eax
js     1368 <main+0x1c8>
mov    %eax,%ebx
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
lea    0xd30(%rip),%rdx
call   1090 <fprintf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    %ebp,%edi
call   1080 <close@plt>
mov    %r14d,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce8(%rip),%rdi
jmp    132e <main+0x18e>
lea    0xd1b(%rip),%rdi
lea    0xcef(%rip),%rsi
call   1040 <printf@plt>
mov    $0x4d,%edi
call   10c0 <exit@plt>
lea    0xd13(%rip),%rdi
jmp    136f <main+0x1cf>
lea    0xd25(%rip),%rdi
jmp    136f <main+0x1cf>
lea    0xd2f(%rip),%rdi
jmp    136f <main+0x1cf>
lea    0xd39(%rip),%rdi
jmp    136f <main+0x1cf>
lea    0xd43(%rip),%rdi
lea    0xcae(%rip),%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <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_CLOEXEC = global i32 0
@.str.4 = [21 x i8] c"%s: [skip,no-memfd]\0A\00"
@.str.5 = [27 x i8] c"%s: [FAIL,memfd-truncate]\0A\00"
@UDMABUF_CREATE = global i32 0
@.str.6 = [19 x i8] c"%s: [FAIL,test-1]\0A\00"
@.str.7 = [19 x i8] c"%s: [FAIL,test-2]\0A\00"
@.str.8 = [19 x i8] c"%s: [FAIL,test-3]\0A\00"
@.str.9 = [19 x i8] c"%s: [FAIL,test-4]\0A\00"
@stderr = global i32 0
@.str.10 = [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_CLOEXEC
%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 = call i32 (...) @getpagesize()
%30 = mul nsw i32 %29, 4
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %11
%33 = load i32, i32* %8
%34 = load i8*, i8** %11
%35 = call i32 @ftruncate(i32 %33, i8* %34)
store i32 %35, i32* %10
%36 = load i32, i32* %10
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %28
%39 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %28
%42 = call i32 @memset(%struct.udmabuf_create* %6, i32 0, i32 12)
%43 = load i32, i32* %8
%44 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 %43, i32* %44
%45 = call i32 (...) @getpagesize()
%46 = sdiv i32 %45, 2
%47 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 %46, i32* %47
%48 = call i32 (...) @getpagesize()
%49 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %48, i32* %49
%50 = load i32, i32* %7
%51 = load i32, i32* @UDMABUF_CREATE
%52 = call i32 @ioctl(i32 %50, i32 %51, %struct.udmabuf_create* %6)
store i32 %52, i32* %9
%53 = load i32, i32* %9
%54 = icmp sge i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %41
%56 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %41
%59 = load i32, i32* %8
%60 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 %59, i32* %60
%61 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 0, i32* %61
%62 = call i32 (...) @getpagesize()
%63 = sdiv i32 %62, 2
%64 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %63, i32* %64
%65 = load i32, i32* %7
%66 = load i32, i32* @UDMABUF_CREATE
%67 = call i32 @ioctl(i32 %65, i32 %66, %struct.udmabuf_create* %6)
store i32 %67, i32* %9
%68 = load i32, i32* %9
%69 = icmp sge i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %58
%71 = 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))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %58
%74 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 0, i32* %74
%75 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 0, i32* %75
%76 = load i8*, i8** %11
%77 = ptrtoint i8* %76 to i32
%78 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %77, i32* %78
%79 = load i32, i32* %7
%80 = load i32, i32* @UDMABUF_CREATE
%81 = call i32 @ioctl(i32 %79, i32 %80, %struct.udmabuf_create* %6)
store i32 %81, i32* %9
%82 = load i32, i32* %9
%83 = icmp sge i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %73
%85 = 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))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %73
%88 = load i32, i32* %8
%89 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 0
store i32 %88, i32* %89
%90 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 1
store i32 0, i32* %90
%91 = load i8*, i8** %11
%92 = ptrtoint i8* %91 to i32
%93 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %6, i32 0, i32 2
store i32 %92, i32* %93
%94 = load i32, i32* %7
%95 = load i32, i32* @UDMABUF_CREATE
%96 = call i32 @ioctl(i32 %94, i32 %95, %struct.udmabuf_create* %6)
store i32 %96, i32* %9
%97 = load i32, i32* %9
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %87
%100 = 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))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %87
%103 = load i32, i32* @stderr
%104 = call i32 @fprintf(i32 %103, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%105 = load i32, i32* %9
%106 = call i32 @close(i32 %105)
%107 = load i32, i32* %8
%108 = call i32 @close(i32 %107)
%109 = load i32, i32* %7
%110 = call i32 @close(i32 %109)
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_CLOEXEC = global i32 0
@.str.4 = [21 x i8] c"%s: [skip,no-memfd]\0A\00"
@.str.5 = [27 x i8] c"%s: [FAIL,memfd-truncate]\0A\00"
@UDMABUF_CREATE = global i32 0
@.str.6 = [19 x i8] c"%s: [FAIL,test-1]\0A\00"
@.str.7 = [19 x i8] c"%s: [FAIL,test-2]\0A\00"
@.str.8 = [19 x i8] c"%s: [FAIL,test-3]\0A\00"
@.str.9 = [19 x i8] c"%s: [FAIL,test-4]\0A\00"
@stderr = global i32 0
@.str.10 = [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_CLOEXEC
%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 = tail call i32 (...) @getpagesize()
%20 = shl nsw i32 %19, 2
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = tail call i32 @ftruncate(i32 %13, i8* %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %18
%29 = call i32 @memset(%struct.udmabuf_create* %3, i32 0, i32 12)
%30 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %3, i64 0, i32 0
store i32 %13, i32* %30
%31 = call i32 (...) @getpagesize()
%32 = sdiv i32 %31, 2
%33 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %3, i64 0, i32 1
store i32 %32, i32* %33
%34 = call i32 (...) @getpagesize()
%35 = getelementptr inbounds %struct.udmabuf_create, %struct.udmabuf_create* %3, i64 0, i32 2
store i32 %34, i32* %35
%36 = load i32, i32* @UDMABUF_CREATE
%37 = call i32 @ioctl(i32 %6, i32 %36, %struct.udmabuf_create* %3)
%38 = icmp sgt i32 %37, -1
br i1 %38, label %39, label %42
39: ; preds = %28
%40 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %28
store i32 %13, i32* %30
store i32 0, i32* %33
%43 = call i32 (...) @getpagesize()
%44 = sdiv i32 %43, 2
store i32 %44, i32* %35
%45 = load i32, i32* @UDMABUF_CREATE
%46 = call i32 @ioctl(i32 %6, i32 %45, %struct.udmabuf_create* %3)
%47 = icmp sgt i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = 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))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %42
store i32 0, i32* %30
store i32 0, i32* %33
store i32 %20, i32* %35
%52 = load i32, i32* @UDMABUF_CREATE
%53 = call i32 @ioctl(i32 %6, i32 %52, %struct.udmabuf_create* %3)
%54 = icmp sgt i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = 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))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %51
store i32 %13, i32* %30
store i32 0, i32* %33
store i32 %20, i32* %35
%59 = load i32, i32* @UDMABUF_CREATE
%60 = call i32 @ioctl(i32 %6, i32 %59, %struct.udmabuf_create* %3)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = 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))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %58
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @close(i32 %60)
%69 = call i32 @close(i32 %13)
%70 = call i32 @close(i32 %6)
ret i32 0
}