#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 flock {
  int l_type;
};

/* Variables and functions */
int /*<<< orphan*/ F_DUPFD;
int F_GETFD;
int F_GETFL;
int /*<<< orphan*/ F_GETLK;
int F_GETOWN;
int F_SETFD;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ F_SETOWN;
int F_UNLCK;
int O_APPEND;
int O_RDWR;
int errno;
int fcntl(int, int, ...);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int f = open("/test", O_RDWR, 0777);
  printf("F_DUPFD: %d\n", fcntl(f, F_DUPFD, 100) >= 100);
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_DUPFD/error1: %d\n", fcntl(50, F_DUPFD, 200));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_DUPFD/error2: %d\n", fcntl(f, F_DUPFD, -1));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_GETFD: %d\n", fcntl(f, F_GETFD));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_SETFD: %d\n", fcntl(f, F_SETFD));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_GETFL: %d\n", fcntl(f, F_GETFL) == O_RDWR);
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_SETFL: %d\n", fcntl(f, F_SETFL, O_APPEND));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_GETFL/2: %d\n", fcntl(f, F_GETFL) == (O_RDWR | O_APPEND));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  struct flock lk;
  lk.l_type = 42;
  printf("F_GETLK: %d\n", fcntl(f, F_GETLK, &lk));
  printf("errno: %d\n", errno);
  printf("lk.l_type == F_UNLCK: %d\n", lk.l_type == F_UNLCK);
  printf("\n");
  errno = 0;
  printf("F_SETLK: %d\n", fcntl(f, F_SETLK, &lk));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_SETLKW: %d\n", fcntl(f, F_SETLK, &lk));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_SETOWN: %d\n", fcntl(f, F_SETOWN, 123));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("F_GETOWN: %d\n", fcntl(f, F_GETOWN));
  printf("errno: %d\n", errno);
  printf("\n");
  errno = 0;
  printf("INVALID: %d\n", fcntl(f, 123));
  printf("errno: %d\n", errno);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
lea    0xeb1(%rip),%rdi
mov    $0x1ff,%edx
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    $0x64,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmp    $0x64,%eax
setge  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ddf(%rip),%rax
movl   $0x0,(%rax)
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
mov    $0x32,%edi
mov    $0xc8,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d83(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d29(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2d11(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%esi
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2cd4(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2cd4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ca4(%rip),%rax
mov    (%rax),%esi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c7f(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2c5f(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    0x2ca7(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c1b(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2c13(%rip),%rax
mov    (%rax),%esi
mov    0x2be2(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2be2(%rip),%rax
mov    (%rax),%esi
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2bbd(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2b9d(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    0x2be5(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2b74(%rip),%rdx
or     (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xc63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b73(%rip),%rax
mov    (%rax),%esi
lea    0xbe5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b4e(%rip),%rax
movl   $0x0,(%rax)
movl   $0x2a,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2b5f(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b13(%rip),%rax
mov    (%rax),%esi
lea    0xb85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    0x2b19(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xbe6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2acc(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2af4(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xbbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2a98(%rip),%rax
mov    (%rax),%esi
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2a73(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2a9b(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2a3f(%rip),%rax
mov    (%rax),%esi
lea    0xab1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xac0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2a1a(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2a62(%rip),%rax
mov    (%rax),%esi
mov    $0x7b,%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xb26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x29e5(%rip),%rax
mov    (%rax),%esi
lea    0xa57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x29c0(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x29e0(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xadf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2990(%rip),%rax
mov    (%rax),%esi
lea    0xa02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x296b(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    $0x7b,%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,%esi
lea    0xa9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x293f(%rip),%rax
mov    (%rax),%esi
lea    0x9b1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e8e(%rip),%r15
mov    (%r15),%esi
lea    0xea4(%rip),%rdi
mov    $0x1ff,%edx
call   1060 <open@plt>
mov    %eax,%ebp
mov    0x2e69(%rip),%r12
mov    (%r12),%esi
mov    %eax,%edi
mov    $0x64,%edx
xor    %eax,%eax
call   1040 <fcntl@plt>
xor    %esi,%esi
cmp    $0x64,%eax
setge  %sil
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2df9(%rip),%rbx
mov    (%rbx),%esi
lea    0xe6b(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    (%r12),%esi
mov    $0x32,%edi
mov    $0xc8,%edx
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xe40(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    (%r12),%esi
mov    %ebp,%edi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xe16(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xdec(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xdbb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2cc4(%rip),%r12
mov    (%r12),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
xor    %esi,%esi
cmp    (%r15),%eax
sete   %sil
lea    0xd7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
mov    0x2c64(%rip),%r13
mov    0x0(%r13),%edx
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xd45(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    (%r12),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
mov    0x0(%r13),%ecx
or     (%r15),%ecx
xor    %esi,%esi
cmp    %ecx,%eax
sete   %sil
lea    0xd0a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
movl   $0x2a,(%rsp)
mov    0x2c1f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r15
mov    %ebp,%edi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xcd0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%eax
mov    0x2be0(%rip),%rcx
xor    %esi,%esi
cmp    (%rcx),%eax
sete   %sil
lea    0xcaf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2bcb(%rip),%r12
mov    (%r12),%esi
mov    %ebp,%edi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xc94(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    (%r12),%esi
mov    %ebp,%edi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xc65(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2b6c(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    $0x7b,%edx
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xc30(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    0x2b01(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xc00(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,(%rbx)
mov    %ebp,%edi
mov    $0x7b,%esi
xor    %eax,%eax
call   1040 <fcntl@plt>
lea    0xbd4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.flock = type { i32 }
@.str = [6 x i8] c"/test\00"
@O_RDWR = global i32 0
@.str.1 = [13 x i8] c"F_DUPFD: %d\0A\00"
@F_DUPFD = global i32 0
@.str.2 = [11 x i8] c"errno: %d\0A\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [20 x i8] c"F_DUPFD/error1: %d\0A\00"
@.str.5 = [20 x i8] c"F_DUPFD/error2: %d\0A\00"
@.str.6 = [13 x i8] c"F_GETFD: %d\0A\00"
@F_GETFD = global i32 0
@.str.7 = [13 x i8] c"F_SETFD: %d\0A\00"
@F_SETFD = global i32 0
@.str.8 = [13 x i8] c"F_GETFL: %d\0A\00"
@F_GETFL = global i32 0
@.str.9 = [13 x i8] c"F_SETFL: %d\0A\00"
@F_SETFL = global i32 0
@O_APPEND = global i32 0
@.str.10 = [15 x i8] c"F_GETFL/2: %d\0A\00"
@.str.11 = [13 x i8] c"F_GETLK: %d\0A\00"
@F_GETLK = global i32 0
@.str.12 = [26 x i8] c"lk.l_type == F_UNLCK: %d\0A\00"
@F_UNLCK = global i32 0
@.str.13 = [13 x i8] c"F_SETLK: %d\0A\00"
@F_SETLK = global i32 0
@.str.14 = [14 x i8] c"F_SETLKW: %d\0A\00"
@.str.15 = [14 x i8] c"F_SETOWN: %d\0A\00"
@F_SETOWN = global i32 0
@.str.16 = [14 x i8] c"F_GETOWN: %d\0A\00"
@F_GETOWN = global i32 0
@.str.17 = [13 x i8] c"INVALID: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.flock
store i32 0, i32* %1
%4 = load i32, i32* @O_RDWR
%5 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4, i32 511)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = load i32, i32* @F_DUPFD
%8 = call i32 (i32, i32, ...) @fcntl(i32 %6, i32 %7, i32 100)
%9 = icmp sge i32 %8, 100
%10 = zext i1 %9 to i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @errno
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%15 = load i32, i32* @F_DUPFD
%16 = call i32 (i32, i32, ...) @fcntl(i32 50, i32 %15, i32 200)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @errno
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%21 = load i32, i32* %2
%22 = load i32, i32* @F_DUPFD
%23 = call i32 (i32, i32, ...) @fcntl(i32 %21, i32 %22, i32 -1)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @errno
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%28 = load i32, i32* %2
%29 = load i32, i32* @F_GETFD
%30 = call i32 (i32, i32, ...) @fcntl(i32 %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @errno
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%35 = load i32, i32* %2
%36 = load i32, i32* @F_SETFD
%37 = call i32 (i32, i32, ...) @fcntl(i32 %35, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @errno
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%42 = load i32, i32* %2
%43 = load i32, i32* @F_GETFL
%44 = call i32 (i32, i32, ...) @fcntl(i32 %42, i32 %43)
%45 = load i32, i32* @O_RDWR
%46 = icmp eq i32 %44, %45
%47 = zext i1 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @errno
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%52 = load i32, i32* %2
%53 = load i32, i32* @F_SETFL
%54 = load i32, i32* @O_APPEND
%55 = call i32 (i32, i32, ...) @fcntl(i32 %52, i32 %53, i32 %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %55)
%57 = load i32, i32* @errno
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%60 = load i32, i32* %2
%61 = load i32, i32* @F_GETFL
%62 = call i32 (i32, i32, ...) @fcntl(i32 %60, i32 %61)
%63 = load i32, i32* @O_RDWR
%64 = load i32, i32* @O_APPEND
%65 = or i32 %63, %64
%66 = icmp eq i32 %62, %65
%67 = zext i1 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %67)
%69 = load i32, i32* @errno
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%72 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 0
store i32 42, i32* %72
%73 = load i32, i32* %2
%74 = load i32, i32* @F_GETLK
%75 = call i32 (i32, i32, ...) @fcntl(i32 %73, i32 %74, %struct.flock* %3)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %75)
%77 = load i32, i32* @errno
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %77)
%79 = getelementptr inbounds %struct.flock, %struct.flock* %3, i32 0, i32 0
%80 = load i32, i32* %79
%81 = load i32, i32* @F_UNLCK
%82 = icmp eq i32 %80, %81
%83 = zext i1 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i32 %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%86 = load i32, i32* %2
%87 = load i32, i32* @F_SETLK
%88 = call i32 (i32, i32, ...) @fcntl(i32 %86, i32 %87, %struct.flock* %3)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 %88)
%90 = load i32, i32* @errno
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%93 = load i32, i32* %2
%94 = load i32, i32* @F_SETLK
%95 = call i32 (i32, i32, ...) @fcntl(i32 %93, i32 %94, %struct.flock* %3)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0), i32 %95)
%97 = load i32, i32* @errno
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%100 = load i32, i32* %2
%101 = load i32, i32* @F_SETOWN
%102 = call i32 (i32, i32, ...) @fcntl(i32 %100, i32 %101, i32 123)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i32 %102)
%104 = load i32, i32* @errno
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%107 = load i32, i32* %2
%108 = load i32, i32* @F_GETOWN
%109 = call i32 (i32, i32, ...) @fcntl(i32 %107, i32 %108)
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i32 %109)
%111 = load i32, i32* @errno
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %111)
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* @errno
%114 = load i32, i32* %2
%115 = call i32 (i32, i32, ...) @fcntl(i32 %114, i32 123)
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %115)
%117 = load i32, i32* @errno
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %117)
ret i32 0
}

LLVM IR (-O2):
%struct.flock = type { i32 }
@.str = [6 x i8] c"/test\00"
@O_RDWR = global i32 0
@.str.1 = [13 x i8] c"F_DUPFD: %d\0A\00"
@F_DUPFD = global i32 0
@.str.2 = [11 x i8] c"errno: %d\0A\00"
@errno = global i32 0
@.str.4 = [20 x i8] c"F_DUPFD/error1: %d\0A\00"
@.str.5 = [20 x i8] c"F_DUPFD/error2: %d\0A\00"
@.str.6 = [13 x i8] c"F_GETFD: %d\0A\00"
@F_GETFD = global i32 0
@.str.7 = [13 x i8] c"F_SETFD: %d\0A\00"
@F_SETFD = global i32 0
@.str.8 = [13 x i8] c"F_GETFL: %d\0A\00"
@F_GETFL = global i32 0
@.str.9 = [13 x i8] c"F_SETFL: %d\0A\00"
@F_SETFL = global i32 0
@O_APPEND = global i32 0
@.str.10 = [15 x i8] c"F_GETFL/2: %d\0A\00"
@.str.11 = [13 x i8] c"F_GETLK: %d\0A\00"
@F_GETLK = global i32 0
@.str.12 = [26 x i8] c"lk.l_type == F_UNLCK: %d\0A\00"
@F_UNLCK = global i32 0
@.str.13 = [13 x i8] c"F_SETLK: %d\0A\00"
@F_SETLK = global i32 0
@.str.14 = [14 x i8] c"F_SETLKW: %d\0A\00"
@.str.15 = [14 x i8] c"F_SETOWN: %d\0A\00"
@F_SETOWN = global i32 0
@.str.16 = [14 x i8] c"F_GETOWN: %d\0A\00"
@F_GETOWN = global i32 0
@.str.17 = [13 x i8] c"INVALID: %d\0A\00"
define i32 @main() {
%1 = alloca %struct.flock
%2 = load i32, i32* @O_RDWR
%3 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %2, i32 511)
%4 = load i32, i32* @F_DUPFD
%5 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %4, i32 100)
%6 = icmp sgt i32 %5, 99
%7 = zext i1 %6 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @errno
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%12 = load i32, i32* @F_DUPFD
%13 = tail call i32 (i32, i32, ...) @fcntl(i32 50, i32 %12, i32 200)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @errno
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%18 = load i32, i32* @F_DUPFD
%19 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %18, i32 -1)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @errno
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%24 = load i32, i32* @F_GETFD
%25 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %24)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @errno
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%30 = load i32, i32* @F_SETFD
%31 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %30)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %31)
%33 = load i32, i32* @errno
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%36 = load i32, i32* @F_GETFL
%37 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %36)
%38 = load i32, i32* @O_RDWR
%39 = icmp eq i32 %37, %38
%40 = zext i1 %39 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @errno
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%45 = load i32, i32* @F_SETFL
%46 = load i32, i32* @O_APPEND
%47 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %45, i32 %46)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @errno
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%52 = load i32, i32* @F_GETFL
%53 = tail call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %52)
%54 = load i32, i32* @O_RDWR
%55 = load i32, i32* @O_APPEND
%56 = or i32 %55, %54
%57 = icmp eq i32 %53, %56
%58 = zext i1 %57 to i32
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %58)
%60 = load i32, i32* @errno
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = tail call i32 @putchar(i32 10)
store i32 0, i32* @errno
%63 = bitcast %struct.flock* %1 to i8*
%64 = getelementptr inbounds %struct.flock, %struct.flock* %1, i64 0, i32 0
store i32 42, i32* %64
%65 = load i32, i32* @F_GETLK
%66 = call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %65, %struct.flock* %1)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %66)
%68 = load i32, i32* @errno
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %64
%71 = load i32, i32* @F_UNLCK
%72 = icmp eq i32 %70, %71
%73 = zext i1 %72 to i32
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i32 %73)
%75 = call i32 @putchar(i32 10)
store i32 0, i32* @errno
%76 = load i32, i32* @F_SETLK
%77 = call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %76, %struct.flock* %1)
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 %77)
%79 = load i32, i32* @errno
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %79)
%81 = call i32 @putchar(i32 10)
store i32 0, i32* @errno
%82 = load i32, i32* @F_SETLK
%83 = call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %82, %struct.flock* %1)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0), i32 %83)
%85 = load i32, i32* @errno
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %85)
%87 = call i32 @putchar(i32 10)
store i32 0, i32* @errno
%88 = load i32, i32* @F_SETOWN
%89 = call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %88, i32 123)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i32 %89)
%91 = load i32, i32* @errno
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %91)
%93 = call i32 @putchar(i32 10)
store i32 0, i32* @errno
%94 = load i32, i32* @F_GETOWN
%95 = call i32 (i32, i32, ...) @fcntl(i32 %3, i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i32 %95)
%97 = load i32, i32* @errno
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %97)
%99 = call i32 @putchar(i32 10)
store i32 0, i32* @errno
%100 = call i32 (i32, i32, ...) @fcntl(i32 %3, i32 123)
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %100)
%102 = load i32, i32* @errno
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %102)
ret i32 0
}