#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 stat {
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int fchmod(int, int);
int fchown(int, int, int);
int fdatasync(int);
int fgetxattr(int, char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int flistxattr(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fremovexattr(int, char *);
int fsetxattr(int, char *, char *, int, int /*<<< orphan*/);
int fstat(int, struct stat *);
int fsync(int);
int ftruncate(int, int /*<<< orphan*/);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int memcmp(char *, char *, int /*<<< orphan*/);
int open(char *, int, int);
int read(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int /*<<< orphan*/);
int fd_based_fops_2(char *filename) {
  int fd = 0;
  int ret = -1;
  int result = 0;
  struct stat stbuf = {
      0,
  };
  char wstr[50] = {
      0,
  };
  char rstr[50] = {
      0,
  };
  fd = open(filename, O_RDWR | O_CREAT, 0666);
  if (fd < 0) {
    fprintf(stderr, "open failed : %s\n", strerror(errno));
    return ret;
  }
  ret = ftruncate(fd, 0);
  if (ret < 0) {
    fprintf(stderr, "ftruncate failed : %s\n", strerror(errno));
    result |= ret;
  }
  strcpy(wstr, "This is my second string\n");
  ret = write(fd, wstr, strlen(wstr));
  if (ret < 0) {
    fprintf(stderr, "write failed: %s\n", strerror(errno));
    result |= ret;
  }
  lseek(fd, 0, SEEK_SET);
  if (ret < 0) {
    fprintf(stderr, "lseek failed: %s\n", strerror(errno));
    result |= ret;
  }
  ret = read(fd, rstr, strlen(wstr));
  if (ret <= 0) {
    fprintf(stderr, "read failed: %s\n", strerror(errno));
    result |= ret;
  }
  ret = memcmp(rstr, wstr, strlen(wstr));
  if (ret != 0) {
    fprintf(stderr, "read returning junk\n");
    result |= ret;
  }
  ret = fstat(fd, &stbuf);
  if (ret < 0) {
    fprintf(stderr, "fstat failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fchmod(fd, 0640);
  if (ret < 0) {
    fprintf(stderr, "fchmod failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fchown(fd, 10001, 10001);
  if (ret < 0) {
    fprintf(stderr, "fchown failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fsync(fd);
  if (ret < 0) {
    fprintf(stderr, "fsync failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fsetxattr(fd, "trusted.xattr-test", "working", 8, 0);
  if (ret < 0) {
    fprintf(stderr, "fsetxattr failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fdatasync(fd);
  if (ret < 0) {
    fprintf(stderr, "fdatasync failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = flistxattr(fd, NULL, 0);
  if (ret <= 0) {
    fprintf(stderr, "flistxattr failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fgetxattr(fd, "trusted.xattr-test", NULL, 0);
  if (ret <= 0) {
    fprintf(stderr, "fgetxattr failed : %s\n", strerror(errno));
    result |= ret;
  }
  ret = fremovexattr(fd, "trusted.xattr-test");
  if (ret < 0) {
    fprintf(stderr, "fremovexattr failed : %s\n", strerror(errno));
    result |= ret;
  }
  if (fd)
    close(fd);
  unlink(filename);
  return result;
}


x86 assembly (clang, -O0):
<fd_based_fops_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   10d0 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   10d0 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   10d0 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
mov    0x2d2d(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1150 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1323 <fd_based_fops_2+0xc3>
mov    0x2ce5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xa4(%rbp),%edi
mov    %rax,%rdx
lea    0xcef(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1881 <fd_based_fops_2+0x621>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   10b0 <ftruncate@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1377 <fd_based_fops_2+0x117>
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xa8(%rbp),%edi
mov    %rax,%rdx
lea    0xcab(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xca7(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xb4(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x60(%rbp),%rdi
call   10a0 <strlen@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
call   1080 <write@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1402 <fd_based_fops_2+0x1a2>
mov    0x2c04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb8(%rbp)
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xb8(%rbp),%edi
mov    %rax,%rdx
lea    0xc51(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2bb4(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <lseek@plt>
cmpl   $0x0,-0x18(%rbp)
jge    145c <fd_based_fops_2+0x1fc>
mov    0x2baa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xbc(%rbp),%edi
mov    %rax,%rdx
lea    0xc09(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xcc(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xc8(%rbp)
lea    -0x60(%rbp),%rdi
call   10a0 <strlen@plt>
mov    -0xcc(%rbp),%edi
mov    -0xc8(%rbp),%rsi
mov    %eax,%edx
call   10f0 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     14da <fd_based_fops_2+0x27a>
mov    0x2b2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd0(%rbp)
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xd0(%rbp),%edi
mov    %rax,%rdx
lea    0xb9d(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0x60(%rbp),%rdi
call   10a0 <strlen@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
mov    %eax,%edx
call   1100 <memcmp@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     153e <fd_based_fops_2+0x2de>
mov    0x2aab(%rip),%rax
mov    (%rax),%edi
lea    0xb4a(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1180 <fstat@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1594 <fd_based_fops_2+0x334>
mov    0x2a72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe4(%rbp)
mov    0x2a5b(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xe4(%rbp),%edi
mov    %rax,%rdx
lea    0xb09(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1a0,%esi
call   1130 <fchmod@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    15eb <fd_based_fops_2+0x38b>
mov    0x2a1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe8(%rbp)
mov    0x2a04(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xe8(%rbp),%edi
mov    %rax,%rdx
lea    0xac5(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x2711,%edx
mov    %edx,%esi
call   1160 <fchown@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1644 <fd_based_fops_2+0x3e4>
mov    0x29c2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
mov    0x29ab(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xec(%rbp),%edi
mov    %rax,%rdx
lea    0xa80(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1140 <fsync@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1696 <fd_based_fops_2+0x436>
mov    0x2970(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf0(%rbp)
mov    0x2959(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xf0(%rbp),%edi
mov    %rax,%rdx
lea    0xa42(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    0xa3b(%rip),%rsi
lea    0xa47(%rip),%rdx
mov    $0x8,%ecx
xor    %r8d,%r8d
call   1070 <fsetxattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    16fe <fd_based_fops_2+0x49e>
mov    0x2908(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf4(%rbp)
mov    0x28f1(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xf4(%rbp),%edi
mov    %rax,%rdx
lea    0xa08(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <fdatasync@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1750 <fd_based_fops_2+0x4f0>
mov    0x28b6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf8(%rbp)
mov    0x289f(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xf8(%rbp),%edi
mov    %rax,%rdx
lea    0x9cd(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <flistxattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     17a8 <fd_based_fops_2+0x548>
mov    0x285e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xfc(%rbp)
mov    0x2847(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0xfc(%rbp),%edi
mov    %rax,%rdx
lea    0x98c(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    0x929(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1120 <fgetxattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     1807 <fd_based_fops_2+0x5a7>
mov    0x27ff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x100(%rbp)
mov    0x27e8(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0x100(%rbp),%edi
mov    %rax,%rdx
lea    0x945(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    0x8ca(%rip),%rsi
call   1090 <fremovexattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1860 <fd_based_fops_2+0x600>
mov    0x27a6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104(%rbp)
mov    0x278f(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0x104(%rbp),%edi
mov    %rax,%rdx
lea    0x903(%rip),%rsi
mov    $0x0,%al
call   1110 <fprintf@plt>
mov    -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1872 <fd_based_fops_2+0x612>
mov    -0x14(%rbp),%edi
call   10e0 <close@plt>
mov    -0x10(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fd_based_fops_2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%r14
movl   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x40(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movw   $0x0,0x80(%rsp)
mov    0x2d3b(%rip),%rax
mov    0x2d4c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1b6,%edx
call   1140 <open@plt>
test   %eax,%eax
js     1348 <fd_based_fops_2+0xf8>
mov    %eax,%ebp
xor    %r15d,%r15d
mov    %eax,%edi
xor    %esi,%esi
call   10b0 <ftruncate@plt>
test   %eax,%eax
jns    1305 <fd_based_fops_2+0xb5>
mov    %eax,%ebx
mov    0x2cf3(%rip),%rax
mov    (%rax),%r15d
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xd1d(%rip),%rsi
mov    %r15d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
mov    %ebx,%r15d
lea    0xd1d(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   10a0 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1080 <write@plt>
test   %eax,%eax
js     137d <fd_based_fops_2+0x12d>
mov    0x2c88(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   10c0 <lseek@plt>
jmp    13e7 <fd_based_fops_2+0x197>
mov    0x2c81(%rip),%rax
mov    (%rax),%ebx
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xc9a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
mov    $0xffffffff,%r15d
jmp    16ae <fd_based_fops_2+0x45e>
mov    %eax,%ebx
mov    0x2c4a(%rip),%rax
mov    (%rax),%r12d
mov    0x2c38(%rip),%r13
mov    0x0(%r13),%edi
call   1160 <strerror@plt>
lea    0xca3(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
mov    0x2c09(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   10c0 <lseek@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%ebx
mov    0x0(%r13),%edi
call   1160 <strerror@plt>
lea    0xc7a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
lea    0x10(%rsp),%rdi
call   10a0 <strlen@plt>
lea    0x50(%rsp),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   10e0 <read@plt>
test   %eax,%eax
jg     1434 <fd_based_fops_2+0x1e4>
mov    %eax,%ebx
mov    0x2bc4(%rip),%rax
mov    (%rax),%r12d
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xc43(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <strlen@plt>
lea    0x50(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   10f0 <memcmp@plt>
test   %eax,%eax
je     1470 <fd_based_fops_2+0x220>
mov    %eax,%ebx
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
lea    0xc12(%rip),%rsi
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
call   1170 <fstat@plt>
test   %eax,%eax
jns    14b1 <fd_based_fops_2+0x261>
mov    %eax,%ebx
mov    0x2b47(%rip),%rax
mov    (%rax),%r12d
mov    0x2b35(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xbec(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
mov    %ebp,%edi
mov    $0x1a0,%esi
call   1120 <fchmod@plt>
test   %eax,%eax
jns    14f2 <fd_based_fops_2+0x2a2>
mov    %eax,%ebx
mov    0x2b06(%rip),%rax
mov    (%rax),%r12d
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xbbe(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
mov    %ebp,%edi
mov    $0x2711,%esi
mov    $0x2711,%edx
call   1150 <fchown@plt>
test   %eax,%eax
jns    1538 <fd_based_fops_2+0x2e8>
mov    %eax,%ebx
mov    0x2ac0(%rip),%rax
mov    (%rax),%r12d
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xb8c(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
mov    %ebp,%edi
call   1130 <fsync@plt>
test   %eax,%eax
jns    1574 <fd_based_fops_2+0x324>
mov    %eax,%ebx
mov    0x2a84(%rip),%rax
mov    (%rax),%r12d
mov    0x2a72(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xb64(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
lea    0xb60(%rip),%rsi
lea    0xb6c(%rip),%rdx
mov    %ebp,%edi
mov    $0x8,%ecx
xor    %r8d,%r8d
call   1070 <fsetxattr@plt>
test   %eax,%eax
jns    15c6 <fd_based_fops_2+0x376>
mov    %eax,%ebx
mov    0x2a32(%rip),%rax
mov    (%rax),%r12d
mov    0x2a20(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xb40(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
mov    %ebp,%edi
call   1030 <fdatasync@plt>
test   %eax,%eax
jns    1602 <fd_based_fops_2+0x3b2>
mov    %eax,%ebx
mov    0x29f6(%rip),%rax
mov    (%rax),%r12d
mov    0x29e4(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xb1b(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <flistxattr@plt>
test   %eax,%eax
jg     1642 <fd_based_fops_2+0x3f2>
mov    %eax,%ebx
mov    0x29b6(%rip),%rax
mov    (%rax),%r12d
mov    0x29a4(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xaf2(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
lea    0xa92(%rip),%rsi
mov    %ebp,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1110 <fgetxattr@plt>
test   %eax,%eax
jg     1689 <fd_based_fops_2+0x439>
mov    %eax,%ebx
mov    0x296f(%rip),%rax
mov    (%rax),%r12d
mov    0x295d(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xac3(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
lea    0xa4b(%rip),%rsi
mov    %ebp,%edi
call   1090 <fremovexattr@plt>
test   %eax,%eax
js     16c3 <fd_based_fops_2+0x473>
test   %ebp,%ebp
je     16a6 <fd_based_fops_2+0x456>
mov    %ebp,%edi
call   10d0 <close@plt>
mov    %r14,%rdi
call   1040 <unlink@plt>
mov    %r15d,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    0x2904(%rip),%rax
mov    (%rax),%r12d
mov    0x28f2(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xa6f(%rip),%rsi
mov    %r12d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1100 <fprintf@plt>
or     %ebx,%r15d
test   %ebp,%ebp
jne    169f <fd_based_fops_2+0x44f>
jmp    16a6 <fd_based_fops_2+0x456>

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"open failed : %s\0A\00"
@errno = global i32 0
@.str.1 = [23 x i8] c"ftruncate failed : %s\0A\00"
@.str.2 = [26 x i8] c"This is my second string\0A\00"
@.str.3 = [18 x i8] c"write failed: %s\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [18 x i8] c"lseek failed: %s\0A\00"
@.str.5 = [17 x i8] c"read failed: %s\0A\00"
@.str.6 = [21 x i8] c"read returning junk\0A\00"
@.str.7 = [19 x i8] c"fstat failed : %s\0A\00"
@.str.8 = [20 x i8] c"fchmod failed : %s\0A\00"
@.str.9 = [20 x i8] c"fchown failed : %s\0A\00"
@.str.10 = [19 x i8] c"fsync failed : %s\0A\00"
@.str.11 = [19 x i8] c"trusted.xattr-test\00"
@.str.12 = [8 x i8] c"working\00"
@.str.13 = [23 x i8] c"fsetxattr failed : %s\0A\00"
@.str.14 = [23 x i8] c"fdatasync failed : %s\0A\00"
@.str.15 = [24 x i8] c"flistxattr failed : %s\0A\00"
@.str.16 = [23 x i8] c"fgetxattr failed : %s\0A\00"
@.str.17 = [26 x i8] c"fremovexattr failed : %s\0A\00"
define i32 @fd_based_fops_2(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.stat
%8 = alloca [50 x i8]
%9 = alloca [50 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 -1, i32* %5
store i32 0, i32* %6
%10 = bitcast %struct.stat* %7 to i8*
%11 = bitcast [50 x i8]* %8 to i8*
%12 = bitcast [50 x i8]* %9 to i8*
%13 = load i8*, i8** %3
%14 = load i32, i32* @O_RDWR
%15 = load i32, i32* @O_CREAT
%16 = or i32 %14, %15
%17 = call i32 @open(i8* %13, i32 %16, i32 438)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %1
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %5
store i32 %25, i32* %2
br label %228
26: ; preds = %1
%27 = load i32, i32* %4
%28 = call i32 @ftruncate(i32 %27, i32 0)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = or i32 %37, %36
store i32 %38, i32* %6
br label %39
39: ; preds = %31, %26
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%41 = call i32 @strcpy(i8* %40, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* %4
%43 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = call i32 @write(i32 %42, i8* %43, i32 %45)
store i32 %46, i32* %5
%47 = load i32, i32* %5
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %57
49: ; preds = %39
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = or i32 %55, %54
store i32 %56, i32* %6
br label %57
57: ; preds = %49, %39
%58 = load i32, i32* %4
%59 = load i32, i32* @SEEK_SET
%60 = call i32 @lseek(i32 %58, i32 0, i32 %59)
%61 = load i32, i32* %5
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %71
63: ; preds = %57
%64 = load i32, i32* @stderr
%65 = load i32, i32* @errno
%66 = call i8* @strerror(i32 %65)
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %66)
%68 = load i32, i32* %5
%69 = load i32, i32* %6
%70 = or i32 %69, %68
store i32 %70, i32* %6
br label %71
71: ; preds = %63, %57
%72 = load i32, i32* %4
%73 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%74 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%75 = call i32 @strlen(i8* %74)
%76 = call i32 @read(i32 %72, i8* %73, i32 %75)
store i32 %76, i32* %5
%77 = load i32, i32* %5
%78 = icmp sle i32 %77, 0
br i1 %78, label %79, label %87
79: ; preds = %71
%80 = load i32, i32* @stderr
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %82)
%84 = load i32, i32* %5
%85 = load i32, i32* %6
%86 = or i32 %85, %84
store i32 %86, i32* %6
br label %87
87: ; preds = %79, %71
%88 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%89 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%90 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%91 = call i32 @strlen(i8* %90)
%92 = call i32 @memcmp(i8* %88, i8* %89, i32 %91)
store i32 %92, i32* %5
%93 = load i32, i32* %5
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %101
95: ; preds = %87
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%98 = load i32, i32* %5
%99 = load i32, i32* %6
%100 = or i32 %99, %98
store i32 %100, i32* %6
br label %101
101: ; preds = %95, %87
%102 = load i32, i32* %4
%103 = call i32 @fstat(i32 %102, %struct.stat* %7)
store i32 %103, i32* %5
%104 = load i32, i32* %5
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %114
106: ; preds = %101
%107 = load i32, i32* @stderr
%108 = load i32, i32* @errno
%109 = call i8* @strerror(i32 %108)
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %109)
%111 = load i32, i32* %5
%112 = load i32, i32* %6
%113 = or i32 %112, %111
store i32 %113, i32* %6
br label %114
114: ; preds = %106, %101
%115 = load i32, i32* %4
%116 = call i32 @fchmod(i32 %115, i32 416)
store i32 %116, i32* %5
%117 = load i32, i32* %5
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %127
119: ; preds = %114
%120 = load i32, i32* @stderr
%121 = load i32, i32* @errno
%122 = call i8* @strerror(i32 %121)
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %122)
%124 = load i32, i32* %5
%125 = load i32, i32* %6
%126 = or i32 %125, %124
store i32 %126, i32* %6
br label %127
127: ; preds = %119, %114
%128 = load i32, i32* %4
%129 = call i32 @fchown(i32 %128, i32 10001, i32 10001)
store i32 %129, i32* %5
%130 = load i32, i32* %5
%131 = icmp slt i32 %130, 0
br i1 %131, label %132, label %140
132: ; preds = %127
%133 = load i32, i32* @stderr
%134 = load i32, i32* @errno
%135 = call i8* @strerror(i32 %134)
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %135)
%137 = load i32, i32* %5
%138 = load i32, i32* %6
%139 = or i32 %138, %137
store i32 %139, i32* %6
br label %140
140: ; preds = %132, %127
%141 = load i32, i32* %4
%142 = call i32 @fsync(i32 %141)
store i32 %142, i32* %5
%143 = load i32, i32* %5
%144 = icmp slt i32 %143, 0
br i1 %144, label %145, label %153
145: ; preds = %140
%146 = load i32, i32* @stderr
%147 = load i32, i32* @errno
%148 = call i8* @strerror(i32 %147)
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %148)
%150 = load i32, i32* %5
%151 = load i32, i32* %6
%152 = or i32 %151, %150
store i32 %152, i32* %6
br label %153
153: ; preds = %145, %140
%154 = load i32, i32* %4
%155 = call i32 @fsetxattr(i32 %154, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 8, i32 0)
store i32 %155, i32* %5
%156 = load i32, i32* %5
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %166
158: ; preds = %153
%159 = load i32, i32* @stderr
%160 = load i32, i32* @errno
%161 = call i8* @strerror(i32 %160)
%162 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %161)
%163 = load i32, i32* %5
%164 = load i32, i32* %6
%165 = or i32 %164, %163
store i32 %165, i32* %6
br label %166
166: ; preds = %158, %153
%167 = load i32, i32* %4
%168 = call i32 @fdatasync(i32 %167)
store i32 %168, i32* %5
%169 = load i32, i32* %5
%170 = icmp slt i32 %169, 0
br i1 %170, label %171, label %179
171: ; preds = %166
%172 = load i32, i32* @stderr
%173 = load i32, i32* @errno
%174 = call i8* @strerror(i32 %173)
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i8* %174)
%176 = load i32, i32* %5
%177 = load i32, i32* %6
%178 = or i32 %177, %176
store i32 %178, i32* %6
br label %179
179: ; preds = %171, %166
%180 = load i32, i32* %4
%181 = call i32 @flistxattr(i32 %180, i32* null, i32 0)
store i32 %181, i32* %5
%182 = load i32, i32* %5
%183 = icmp sle i32 %182, 0
br i1 %183, label %184, label %192
184: ; preds = %179
%185 = load i32, i32* @stderr
%186 = load i32, i32* @errno
%187 = call i8* @strerror(i32 %186)
%188 = call i32 (i32, i8*, ...) @fprintf(i32 %185, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i8* %187)
%189 = load i32, i32* %5
%190 = load i32, i32* %6
%191 = or i32 %190, %189
store i32 %191, i32* %6
br label %192
192: ; preds = %184, %179
%193 = load i32, i32* %4
%194 = call i32 @fgetxattr(i32 %193, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i32* null, i32 0)
store i32 %194, i32* %5
%195 = load i32, i32* %5
%196 = icmp sle i32 %195, 0
br i1 %196, label %197, label %205
197: ; preds = %192
%198 = load i32, i32* @stderr
%199 = load i32, i32* @errno
%200 = call i8* @strerror(i32 %199)
%201 = call i32 (i32, i8*, ...) @fprintf(i32 %198, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i8* %200)
%202 = load i32, i32* %5
%203 = load i32, i32* %6
%204 = or i32 %203, %202
store i32 %204, i32* %6
br label %205
205: ; preds = %197, %192
%206 = load i32, i32* %4
%207 = call i32 @fremovexattr(i32 %206, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
store i32 %207, i32* %5
%208 = load i32, i32* %5
%209 = icmp slt i32 %208, 0
br i1 %209, label %210, label %218
210: ; preds = %205
%211 = load i32, i32* @stderr
%212 = load i32, i32* @errno
%213 = call i8* @strerror(i32 %212)
%214 = call i32 (i32, i8*, ...) @fprintf(i32 %211, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8* %213)
%215 = load i32, i32* %5
%216 = load i32, i32* %6
%217 = or i32 %216, %215
store i32 %217, i32* %6
br label %218
218: ; preds = %210, %205
%219 = load i32, i32* %4
%220 = icmp ne i32 %219, 0
br i1 %220, label %221, label %224
221: ; preds = %218
%222 = load i32, i32* %4
%223 = call i32 @close(i32 %222)
br label %224
224: ; preds = %221, %218
%225 = load i8*, i8** %3
%226 = call i32 @unlink(i8* %225)
%227 = load i32, i32* %6
store i32 %227, i32* %2
br label %228
228: ; preds = %224, %20
%229 = load i32, i32* %2
ret i32 %229
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"open failed : %s\0A\00"
@errno = global i32 0
@.str.1 = [23 x i8] c"ftruncate failed : %s\0A\00"
@.str.2 = [26 x i8] c"This is my second string\0A\00"
@.str.3 = [18 x i8] c"write failed: %s\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [18 x i8] c"lseek failed: %s\0A\00"
@.str.5 = [17 x i8] c"read failed: %s\0A\00"
@.str.6 = [21 x i8] c"read returning junk\0A\00"
@.str.7 = [19 x i8] c"fstat failed : %s\0A\00"
@.str.8 = [20 x i8] c"fchmod failed : %s\0A\00"
@.str.9 = [20 x i8] c"fchown failed : %s\0A\00"
@.str.10 = [19 x i8] c"fsync failed : %s\0A\00"
@.str.11 = [19 x i8] c"trusted.xattr-test\00"
@.str.12 = [8 x i8] c"working\00"
@.str.13 = [23 x i8] c"fsetxattr failed : %s\0A\00"
@.str.14 = [23 x i8] c"fdatasync failed : %s\0A\00"
@.str.15 = [24 x i8] c"flistxattr failed : %s\0A\00"
@.str.16 = [23 x i8] c"fgetxattr failed : %s\0A\00"
@.str.17 = [26 x i8] c"fremovexattr failed : %s\0A\00"
define i32 @fd_based_fops_2(i8* nocapture %0) {
%2 = alloca %struct.stat
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = bitcast %struct.stat* %2 to i8*
%6 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
store i32 0, i32* %6
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @O_RDWR
%10 = load i32, i32* @O_CREAT
%11 = or i32 %10, %9
%12 = tail call i32 @open(i8* %0, i32 %11, i32 438)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %165
19: ; preds = %1
%20 = tail call i32 @ftruncate(i32 %12, i32 0)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = load i32, i32* @errno
%25 = tail call i8* @strerror(i32 %24)
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %22, %19
%28 = phi i32 [ %20, %22 ], [ 0, %19 ]
%29 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @strlen(i8* %7)
%31 = call i32 @write(i32 %12, i8* %7, i32 %30)
%32 = icmp slt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %27
%34 = load i32, i32* @SEEK_SET
%35 = call i32 @lseek(i32 %12, i32 0, i32 %34)
br label %48
36: ; preds = %27
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = or i32 %31, %28
%42 = load i32, i32* @SEEK_SET
%43 = call i32 @lseek(i32 %12, i32 0, i32 %42)
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %33, %36
%49 = phi i32 [ %41, %36 ], [ %28, %33 ]
%50 = call i32 @strlen(i8* %7)
%51 = call i32 @read(i32 %12, i8* %8, i32 %50)
%52 = icmp slt i32 %51, 1
br i1 %52, label %53, label %59
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %56)
%58 = or i32 %51, %49
br label %59
59: ; preds = %53, %48
%60 = phi i32 [ %58, %53 ], [ %49, %48 ]
%61 = call i32 @strlen(i8* %7)
%62 = call i32 @memcmp(i8* %8, i8* %7, i32 %61)
%63 = icmp eq i32 %62, 0
br i1 %63, label %68, label %64
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%67 = or i32 %62, %60
br label %68
68: ; preds = %64, %59
%69 = phi i32 [ %67, %64 ], [ %60, %59 ]
%70 = call i32 @fstat(i32 %12, %struct.stat* %2)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %78
72: ; preds = %68
%73 = load i32, i32* @stderr
%74 = load i32, i32* @errno
%75 = call i8* @strerror(i32 %74)
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %75)
%77 = or i32 %70, %69
br label %78
78: ; preds = %72, %68
%79 = phi i32 [ %77, %72 ], [ %69, %68 ]
%80 = call i32 @fchmod(i32 %12, i32 416)
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %78
%83 = load i32, i32* @stderr
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %85)
%87 = or i32 %80, %79
br label %88
88: ; preds = %82, %78
%89 = phi i32 [ %87, %82 ], [ %79, %78 ]
%90 = call i32 @fchown(i32 %12, i32 10001, i32 10001)
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %88
%93 = load i32, i32* @stderr
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %95)
%97 = or i32 %90, %89
br label %98
98: ; preds = %92, %88
%99 = phi i32 [ %97, %92 ], [ %89, %88 ]
%100 = call i32 @fsync(i32 %12)
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %108
102: ; preds = %98
%103 = load i32, i32* @stderr
%104 = load i32, i32* @errno
%105 = call i8* @strerror(i32 %104)
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %105)
%107 = or i32 %100, %99
br label %108
108: ; preds = %102, %98
%109 = phi i32 [ %107, %102 ], [ %99, %98 ]
%110 = call i32 @fsetxattr(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 8, i32 0)
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %118
112: ; preds = %108
%113 = load i32, i32* @stderr
%114 = load i32, i32* @errno
%115 = call i8* @strerror(i32 %114)
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %115)
%117 = or i32 %110, %109
br label %118
118: ; preds = %112, %108
%119 = phi i32 [ %117, %112 ], [ %109, %108 ]
%120 = call i32 @fdatasync(i32 %12)
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %128
122: ; preds = %118
%123 = load i32, i32* @stderr
%124 = load i32, i32* @errno
%125 = call i8* @strerror(i32 %124)
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i8* %125)
%127 = or i32 %120, %119
br label %128
128: ; preds = %122, %118
%129 = phi i32 [ %127, %122 ], [ %119, %118 ]
%130 = call i32 @flistxattr(i32 %12, i32* null, i32 0)
%131 = icmp slt i32 %130, 1
br i1 %131, label %132, label %138
132: ; preds = %128
%133 = load i32, i32* @stderr
%134 = load i32, i32* @errno
%135 = call i8* @strerror(i32 %134)
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i8* %135)
%137 = or i32 %130, %129
br label %138
138: ; preds = %132, %128
%139 = phi i32 [ %137, %132 ], [ %129, %128 ]
%140 = call i32 @fgetxattr(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i32* null, i32 0)
%141 = icmp slt i32 %140, 1
br i1 %141, label %142, label %148
142: ; preds = %138
%143 = load i32, i32* @stderr
%144 = load i32, i32* @errno
%145 = call i8* @strerror(i32 %144)
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i8* %145)
%147 = or i32 %140, %139
br label %148
148: ; preds = %142, %138
%149 = phi i32 [ %147, %142 ], [ %139, %138 ]
%150 = call i32 @fremovexattr(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%151 = icmp slt i32 %150, 0
br i1 %151, label %152, label %158
152: ; preds = %148
%153 = load i32, i32* @stderr
%154 = load i32, i32* @errno
%155 = call i8* @strerror(i32 %154)
%156 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8* %155)
%157 = or i32 %150, %149
br label %158
158: ; preds = %152, %148
%159 = phi i32 [ %157, %152 ], [ %149, %148 ]
%160 = icmp eq i32 %12, 0
br i1 %160, label %163, label %161
161: ; preds = %158
%162 = call i32 @close(i32 %12)
br label %163
163: ; preds = %161, %158
%164 = call i32 @unlink(i8* %0)
br label %165
165: ; preds = %163, %14
%166 = phi i32 [ -1, %14 ], [ %159, %163 ]
ret i32 %166
}