#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__ KCMP_FILE;
scalar_t__ KCMP_FILES;
scalar_t__ KCMP_FS;
scalar_t__ KCMP_IO;
scalar_t__ KCMP_SIGHAND;
scalar_t__ KCMP_SYSVSEM;
scalar_t__ KCMP_TYPES;
scalar_t__ KCMP_VM;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ P_ALL;
int /*<<< orphan*/ errno;
int fork();
int getpid();
int /*<<< orphan*/ ksft_exit_fail();
int ksft_exit_pass();
int /*<<< orphan*/ ksft_inc_fail_cnt();
int /*<<< orphan*/ ksft_inc_pass_cnt();
int /*<<< orphan*/ ksft_print_cnts();
int open(char const *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
int sys_kcmp(int, int, scalar_t__, int, int);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char kpath[] = "kcmp-test-file";
  int pid1, pid2;
  int fd1, fd2;
  int status;
  fd1 = open(kpath, O_RDWR | O_CREAT | O_TRUNC, 0644);
  pid1 = getpid();
  if (fd1 < 0) {
    perror("Can't create file");
    ksft_exit_fail();
  }
  pid2 = fork();
  if (pid2 < 0) {
    perror("fork failed");
    ksft_exit_fail();
  }
  if (!pid2) {
    int pid2 = getpid();
    int ret;
    fd2 = open(kpath, O_RDWR, 0644);
    if (fd2 < 0) {
      perror("Can't open file");
      ksft_exit_fail();
    }
    printf("pid1: %6d pid2: %6d FD: %2ld FILES: %2ld VM: %2ld "
           "FS: %2ld SIGHAND: %2ld IO: %2ld SYSVSEM: %2ld "
           "INV: %2ld\n",
           pid1, pid2, sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd2),
           sys_kcmp(pid1, pid2, KCMP_FILES, 0, 0),
           sys_kcmp(pid1, pid2, KCMP_VM, 0, 0),
           sys_kcmp(pid1, pid2, KCMP_FS, 0, 0),
           sys_kcmp(pid1, pid2, KCMP_SIGHAND, 0, 0),
           sys_kcmp(pid1, pid2, KCMP_IO, 0, 0),
           sys_kcmp(pid1, pid2, KCMP_SYSVSEM, 0, 0),
           sys_kcmp(pid1, pid2, KCMP_TYPES + 1, 0, 0));
    ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1);
    if (ret) {
      printf("FAIL: 0 expected but %d returned (%s)\n", ret, strerror(errno));
      ksft_inc_fail_cnt();
      ret = -1;
    } else {
      printf("PASS: 0 returned as expected\n");
      ksft_inc_pass_cnt();
    }
    ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0);
    if (ret) {
      printf("FAIL: 0 expected but %d returned (%s)\n", ret, strerror(errno));
      ksft_inc_fail_cnt();
      ret = -1;
    } else {
      printf("PASS: 0 returned as expected\n");
      ksft_inc_pass_cnt();
    }
    ksft_print_cnts();
    if (ret) {
      ksft_exit_fail();
    } else {
      ksft_exit_pass();
    }
  }
  waitpid(pid2, &status, P_ALL);
  return ksft_exit_pass();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
movl   $0x0,-0x14(%rbp)
mov    %edi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    0xe0d(%rip),%rax
mov    %rax,-0x2f(%rbp)
mov    0xe0b(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xe05(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xdfd(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x2f(%rbp),%rdi
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
mov    0x2dd0(%rip),%rax
or     (%rax),%esi
mov    0x2dbf(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10a0 <open@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1267 <main+0x97>
lea    0xdb4(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x0,%al
call   1070 <ksft_exit_fail@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    128e <main+0xbe>
lea    0xd9f(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x0,%al
call   1070 <ksft_exit_fail@plt>
cmpl   $0x0,-0x38(%rbp)
jne    152d <main+0x35d>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,-0x48(%rbp)
lea    -0x2f(%rbp),%rdi
mov    0x2d23(%rip),%rax
mov    (%rax),%esi
mov    $0x1a4,%edx
call   10a0 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    12d9 <main+0x109>
lea    0xd60(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x0,%al
call   1070 <ksft_exit_fail@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2cb6(%rip),%rax
mov    (%rax),%rdx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,-0x60(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c77(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c71(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,-0x58(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c43(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,%r14d
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c15(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,%ebx
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c30(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,-0x54(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c42(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,-0x50(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2c04(%rip),%rax
mov    (%rax),%rdx
add    $0x1,%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    -0x68(%rbp),%esi
mov    -0x64(%rbp),%edx
mov    -0x60(%rbp),%ecx
mov    -0x5c(%rbp),%r8d
mov    -0x58(%rbp),%r9d
mov    -0x54(%rbp),%r11d
mov    -0x50(%rbp),%r10d
lea    0xc47(%rip),%rdi
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x34(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    0x2b88(%rip),%rax
mov    (%rax),%rdx
mov    -0x3c(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1477 <main+0x2a7>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2b67(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x6c(%rbp),%esi
mov    %rax,%rdx
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10e0 <ksft_inc_fail_cnt@plt>
movl   $0xffffffff,-0x4c(%rbp)
jmp    148c <main+0x2bc>
lea    0xc51(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1040 <ksft_inc_pass_cnt@plt>
mov    -0x34(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    0x2b07(%rip),%rax
mov    (%rax),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <sys_kcmp@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     14ef <main+0x31f>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    0x2aef(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x70(%rbp),%esi
mov    %rax,%rdx
lea    0xbd3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10e0 <ksft_inc_fail_cnt@plt>
movl   $0xffffffff,-0x4c(%rbp)
jmp    1504 <main+0x334>
lea    0xbd9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1040 <ksft_inc_pass_cnt@plt>
mov    $0x0,%al
call   10c0 <ksft_print_cnts@plt>
cmpl   $0x0,-0x4c(%rbp)
je     1521 <main+0x351>
mov    $0x0,%al
call   1070 <ksft_exit_fail@plt>
jmp    1528 <main+0x358>
mov    $0x0,%al
call   1060 <ksft_exit_pass@plt>
jmp    152d <main+0x35d>
mov    -0x38(%rbp),%edi
mov    0x2a61(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rsi
call   1090 <waitpid@plt>
mov    $0x0,%al
call   1060 <ksft_exit_pass@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movabs $0x656c69662d7473,%rax
mov    %rax,0x17(%rsp)
movabs $0x7365742d706d636b,%rax
74 65 73
mov    0x2dc2(%rip),%rbp
mov    0x2de3(%rip),%rcx
mov    (%rcx),%esi
or     0x0(%rbp),%esi
mov    %rax,0x10(%rsp)
mov    0x2dca(%rip),%rax
or     (%rax),%esi
lea    0x10(%rsp),%rdi
mov    $0x1a4,%edx
call   10b0 <open@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%r12d
test   %r15d,%r15d
js     14b1 <main+0x2d1>
xor    %eax,%eax
call   1100 <fork@plt>
mov    %eax,%ebx
test   %eax,%eax
js     14c9 <main+0x2e9>
jne    1486 <main+0x2a6>
mov    %ebx,(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%esi
lea    0x10(%rsp),%rdi
mov    $0x1a4,%edx
call   10b0 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     14de <main+0x2fe>
mov    0x2d15(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,0xc(%rsp)
mov    0x2cd7(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,0x8(%rsp)
mov    0x2cd2(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,0x4(%rsp)
mov    0x2ca5(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %rax,0x28(%rsp)
mov    0x2c77(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %rax,0x20(%rsp)
mov    0x2c91(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,%r13d
mov    0x2ca5(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,%r14d
mov    0x2c69(%rip),%rax
mov    (%rax),%rdx
add    $0x1,%rdx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
mov    %eax,%ebp
sub    $0x8,%rsp
lea    0xcbb(%rip),%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
xor    %eax,%eax
push   %rbp
push   %r14
push   %r13
push   0x40(%rsp)
push   0x50(%rsp)
call   1090 <printf@plt>
add    $0x30,%rsp
mov    0x2bf4(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %ebx,%esi
mov    %r15d,%ecx
mov    %r15d,%r8d
call   1030 <sys_kcmp@plt>
test   %eax,%eax
je     13f7 <main+0x217>
mov    %eax,%ebx
mov    0x2bdc(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcc6(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   10f0 <ksft_inc_fail_cnt@plt>
jmp    140a <main+0x22a>
lea    0xcd1(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <ksft_inc_pass_cnt@plt>
mov    0x2b8f(%rip),%rax
mov    (%rax),%rdx
mov    %r12d,%edi
mov    %r12d,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <sys_kcmp@plt>
test   %eax,%eax
je     1462 <main+0x282>
mov    %eax,%ebx
mov    0x2b7f(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc69(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   10f0 <ksft_inc_fail_cnt@plt>
xor    %eax,%eax
call   10d0 <ksft_print_cnts@plt>
xor    %eax,%eax
call   1080 <ksft_exit_fail@plt>
jmp    1483 <main+0x2a3>
lea    0xc66(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <ksft_inc_pass_cnt@plt>
xor    %eax,%eax
call   10d0 <ksft_print_cnts@plt>
xor    %eax,%eax
call   1070 <ksft_exit_pass@plt>
mov    (%rsp),%ebx
mov    0x2b0b(%rip),%rax
mov    (%rax),%edx
lea    0x34(%rsp),%rsi
mov    %ebx,%edi
call   10a0 <waitpid@plt>
xor    %eax,%eax
call   1070 <ksft_exit_pass@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb57(%rip),%rdi
call   10c0 <perror@plt>
xor    %eax,%eax
call   1080 <ksft_exit_fail@plt>
jmp    124d <main+0x6d>
lea    0xb51(%rip),%rdi
call   10c0 <perror@plt>
xor    %eax,%eax
call   1080 <ksft_exit_fail@plt>
jmp    1486 <main+0x2a6>
lea    0xb48(%rip),%rdi
call   10c0 <perror@plt>
xor    %eax,%eax
call   1080 <ksft_exit_fail@plt>
jmp    128c <main+0xac>

LLVM IR (-O0):
@__const.main.kpath = [15 x i8] c"kcmp-test-file\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str = [18 x i8] c"Can't create file\00"
@.str.1 = [12 x i8] c"fork failed\00"
@.str.2 = [16 x i8] c"Can't open file\00"
@.str.3 = [107 x i8] c"pid1: %6d pid2: %6d FD: %2ld FILES: %2ld VM: %2ld FS: %2ld SIGHAND: %2ld IO: %2ld SYSVSEM: %2ld INV: %2ld\0A\00"
@KCMP_FILE = global i64 0
@KCMP_FILES = global i64 0
@KCMP_VM = global i64 0
@KCMP_FS = global i64 0
@KCMP_SIGHAND = global i64 0
@KCMP_IO = global i64 0
@KCMP_SYSVSEM = global i64 0
@KCMP_TYPES = global i64 0
@.str.4 = [39 x i8] c"FAIL: 0 expected but %d returned (%s)\0A\00"
@errno = global i32 0
@.str.5 = [30 x i8] c"PASS: 0 returned as expected\0A\00"
@P_ALL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [15 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [15 x i8]* %6 to i8*
%15 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%16 = load i32, i32* @O_RDWR
%17 = load i32, i32* @O_CREAT
%18 = or i32 %16, %17
%19 = load i32, i32* @O_TRUNC
%20 = or i32 %18, %19
%21 = call i32 @open(i8* %15, i32 %20, i32 420)
store i32 %21, i32* %9
%22 = call i32 (...) @getpid()
store i32 %22, i32* %7
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (...) @ksft_exit_fail()
br label %28
28: ; preds = %25, %2
%29 = call i32 (...) @fork()
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 (...) @ksft_exit_fail()
br label %35
35: ; preds = %32, %28
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %129, label %38
38: ; preds = %35
%39 = call i32 (...) @getpid()
store i32 %39, i32* %12
%40 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%41 = load i32, i32* @O_RDWR
%42 = call i32 @open(i8* %40, i32 %41, i32 420)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 (...) @ksft_exit_fail()
br label %48
48: ; preds = %45, %38
%49 = load i32, i32* %7
%50 = load i32, i32* %12
%51 = load i32, i32* %7
%52 = load i32, i32* %12
%53 = load i64, i64* @KCMP_FILE
%54 = load i32, i32* %9
%55 = load i32, i32* %10
%56 = call i32 @sys_kcmp(i32 %51, i32 %52, i64 %53, i32 %54, i32 %55)
%57 = load i32, i32* %7
%58 = load i32, i32* %12
%59 = load i64, i64* @KCMP_FILES
%60 = call i32 @sys_kcmp(i32 %57, i32 %58, i64 %59, i32 0, i32 0)
%61 = load i32, i32* %7
%62 = load i32, i32* %12
%63 = load i64, i64* @KCMP_VM
%64 = call i32 @sys_kcmp(i32 %61, i32 %62, i64 %63, i32 0, i32 0)
%65 = load i32, i32* %7
%66 = load i32, i32* %12
%67 = load i64, i64* @KCMP_FS
%68 = call i32 @sys_kcmp(i32 %65, i32 %66, i64 %67, i32 0, i32 0)
%69 = load i32, i32* %7
%70 = load i32, i32* %12
%71 = load i64, i64* @KCMP_SIGHAND
%72 = call i32 @sys_kcmp(i32 %69, i32 %70, i64 %71, i32 0, i32 0)
%73 = load i32, i32* %7
%74 = load i32, i32* %12
%75 = load i64, i64* @KCMP_IO
%76 = call i32 @sys_kcmp(i32 %73, i32 %74, i64 %75, i32 0, i32 0)
%77 = load i32, i32* %7
%78 = load i32, i32* %12
%79 = load i64, i64* @KCMP_SYSVSEM
%80 = call i32 @sys_kcmp(i32 %77, i32 %78, i64 %79, i32 0, i32 0)
%81 = load i32, i32* %7
%82 = load i32, i32* %12
%83 = load i64, i64* @KCMP_TYPES
%84 = add nsw i64 %83, 1
%85 = call i32 @sys_kcmp(i32 %81, i32 %82, i64 %84, i32 0, i32 0)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %50, i32 %56, i32 %60, i32 %64, i32 %68, i32 %72, i32 %76, i32 %80, i32 %85)
%87 = load i32, i32* %7
%88 = load i32, i32* %12
%89 = load i64, i64* @KCMP_FILE
%90 = load i32, i32* %9
%91 = load i32, i32* %9
%92 = call i32 @sys_kcmp(i32 %87, i32 %88, i64 %89, i32 %90, i32 %91)
store i32 %92, i32* %13
%93 = load i32, i32* %13
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %101
95: ; preds = %48
%96 = load i32, i32* %13
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %96, i8* %98)
%100 = call i32 (...) @ksft_inc_fail_cnt()
store i32 -1, i32* %13
br label %104
101: ; preds = %48
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%103 = call i32 (...) @ksft_inc_pass_cnt()
br label %104
104: ; preds = %101, %95
%105 = load i32, i32* %7
%106 = load i32, i32* %7
%107 = load i64, i64* @KCMP_VM
%108 = call i32 @sys_kcmp(i32 %105, i32 %106, i64 %107, i32 0, i32 0)
store i32 %108, i32* %13
%109 = load i32, i32* %13
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %117
111: ; preds = %104
%112 = load i32, i32* %13
%113 = load i32, i32* @errno
%114 = call i8* @strerror(i32 %113)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %112, i8* %114)
%116 = call i32 (...) @ksft_inc_fail_cnt()
store i32 -1, i32* %13
br label %120
117: ; preds = %104
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%119 = call i32 (...) @ksft_inc_pass_cnt()
br label %120
120: ; preds = %117, %111
%121 = call i32 (...) @ksft_print_cnts()
%122 = load i32, i32* %13
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %126
124: ; preds = %120
%125 = call i32 (...) @ksft_exit_fail()
br label %128
126: ; preds = %120
%127 = call i32 (...) @ksft_exit_pass()
br label %128
128: ; preds = %126, %124
br label %129
129: ; preds = %128, %35
%130 = load i32, i32* %8
%131 = load i32, i32* @P_ALL
%132 = call i32 @waitpid(i32 %130, i32* %11, i32 %131)
%133 = call i32 (...) @ksft_exit_pass()
ret i32 %133
}

LLVM IR (-O2):
@__const.main.kpath = [15 x i8] c"kcmp-test-file\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str = [18 x i8] c"Can't create file\00"
@.str.1 = [12 x i8] c"fork failed\00"
@.str.2 = [16 x i8] c"Can't open file\00"
@.str.3 = [107 x i8] c"pid1: %6d pid2: %6d FD: %2ld FILES: %2ld VM: %2ld FS: %2ld SIGHAND: %2ld IO: %2ld SYSVSEM: %2ld INV: %2ld\0A\00"
@KCMP_FILE = global i64 0
@KCMP_FILES = global i64 0
@KCMP_VM = global i64 0
@KCMP_FS = global i64 0
@KCMP_SIGHAND = global i64 0
@KCMP_IO = global i64 0
@KCMP_SYSVSEM = global i64 0
@KCMP_TYPES = global i64 0
@.str.4 = [39 x i8] c"FAIL: 0 expected but %d returned (%s)\0A\00"
@errno = global i32 0
@P_ALL = global i32 0
@str.6 = [29 x i8] c"PASS: 0 returned as expected\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [15 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @O_RDWR
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = load i32, i32* @O_TRUNC
%11 = or i32 %9, %10
%12 = call i32 @open(i8* %5, i32 %11, i32 420)
%13 = tail call i32 (...) @getpid()
%14 = icmp slt i32 %12, 0
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 (...) @ksft_exit_fail()
br label %18
18: ; preds = %15, %2
%19 = tail call i32 (...) @fork()
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 (...) @ksft_exit_fail()
br label %80
24: ; preds = %18
%25 = icmp eq i32 %19, 0
br i1 %25, label %26, label %80
26: ; preds = %24
%27 = tail call i32 (...) @getpid()
%28 = load i32, i32* @O_RDWR
%29 = call i32 @open(i8* %5, i32 %28, i32 420)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%33 = tail call i32 (...) @ksft_exit_fail()
br label %34
34: ; preds = %31, %26
%35 = load i64, i64* @KCMP_FILE
%36 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %35, i32 %12, i32 %29)
%37 = load i64, i64* @KCMP_FILES
%38 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %37, i32 0, i32 0)
%39 = load i64, i64* @KCMP_VM
%40 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %39, i32 0, i32 0)
%41 = load i64, i64* @KCMP_FS
%42 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %41, i32 0, i32 0)
%43 = load i64, i64* @KCMP_SIGHAND
%44 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %43, i32 0, i32 0)
%45 = load i64, i64* @KCMP_IO
%46 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %45, i32 0, i32 0)
%47 = load i64, i64* @KCMP_SYSVSEM
%48 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %47, i32 0, i32 0)
%49 = load i64, i64* @KCMP_TYPES
%50 = add nsw i64 %49, 1
%51 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %50, i32 0, i32 0)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([107 x i8], [107 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %27, i32 %36, i32 %38, i32 %40, i32 %42, i32 %44, i32 %46, i32 %48, i32 %51)
%53 = load i64, i64* @KCMP_FILE
%54 = tail call i32 @sys_kcmp(i32 %13, i32 %27, i64 %53, i32 %12, i32 %12)
%55 = icmp eq i32 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %34
%57 = load i32, i32* @errno
%58 = tail call i8* @strerror(i32 %57)
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %54, i8* %58)
%60 = tail call i32 (...) @ksft_inc_fail_cnt()
br label %64
61: ; preds = %34
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%63 = tail call i32 (...) @ksft_inc_pass_cnt()
br label %64
64: ; preds = %61, %56
%65 = load i64, i64* @KCMP_VM
%66 = tail call i32 @sys_kcmp(i32 %13, i32 %13, i64 %65, i32 0, i32 0)
%67 = icmp eq i32 %66, 0
br i1 %67, label %75, label %68
68: ; preds = %64
%69 = load i32, i32* @errno
%70 = tail call i8* @strerror(i32 %69)
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %66, i8* %70)
%72 = tail call i32 (...) @ksft_inc_fail_cnt()
%73 = tail call i32 (...) @ksft_print_cnts()
%74 = tail call i32 (...) @ksft_exit_fail()
br label %80
75: ; preds = %64
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%77 = tail call i32 (...) @ksft_inc_pass_cnt()
%78 = tail call i32 (...) @ksft_print_cnts()
%79 = tail call i32 (...) @ksft_exit_pass()
br label %80
80: ; preds = %21, %68, %75, %24
%81 = load i32, i32* @P_ALL
%82 = call i32 @waitpid(i32 %19, i32* %4, i32 %81)
%83 = call i32 (...) @ksft_exit_pass()
ret i32 %83
}