// File: /workspace/github_cpp_makefile_star2_O3/SoftwearDevelopment[P]xattr_syscall_wrapper/setxattr.cc
// Function: main
int main(int argc, char** argv) {
  if (argc != 3) {
    std::cerr << "USAGE: setxattr [FILE] [XATTR] < data" << std::endl;
    return 1;
  }

  auto &file = argv[1], &attr = argv[2];
  std::vector<char> payload;

  // load the data

  size_t have = 0, alloc = 1024*4; // One page
  while (true) {
    payload.resize(alloc);
    std::cin.read(payload.data()+have, payload.size() - have);

    alloc *=2;
    have += std::cin.gcount();

    if (std::cin.eof()) { // success
      payload.resize(have);
      break;

    } else if (alloc > max_buf_size) { // to large
      std::cerr << "read error: data larger than " << max_buf_size << " bytes. "
                << "Refusing to allocate more.";
      return 1;
    }
  }

  // return the data
  int r = setxattr(file, attr, payload.data(), payload.size(), 0);
  if (r == -1)
    fatal_errno(file, "setxattr");

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
cmpl $0x3, %edi
jne 0x13c0
movq %rsi, %rbx
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
movq $0x0, 0x10(%r15)
movl $0x1000, %r12d          # imm = 0x1000
xorl %r14d, %r14d
movq 0x2cbe(%rip), %r13      # 0x3fd8
movq %r15, %rdi
movq %r12, %rsi
callq 0x157a
movq 0x10(%rsp), %rsi
addq %r14, %rsi
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
movq %r13, %rdi
callq 0x1150
movq (%r13), %rax
movq -0x18(%rax), %rax
addq 0x8(%r13), %r14
testb $0x2, 0x20(%r13,%rax)
jne 0x1409
leaq (%r12,%r12), %rax
cmpq $0x3200001, %r12        # imm = 0x3200001
movq %rax, %r12
jb 0x131a
movq 0x2c84(%rip), %rdi      # 0x3ff0
leaq 0xcb7(%rip), %rsi       # 0x202a
movl $0x1d, %edx
callq 0x1130
movq 0x2c6c(%rip), %rdi      # 0x3ff0
movl $0x6400000, %esi        # imm = 0x6400000
callq 0x10a0
movq %rax, %rbx
leaq 0xcb0(%rip), %rsi       # 0x2048
movl $0x8, %edx
movq %rax, %rdi
callq 0x1130
movl $0x1, %ebp
leaq 0xca0(%rip), %rsi       # 0x2051
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x1130
jmp 0x143a
movq 0x2c29(%rip), %rbx      # 0x3ff0
leaq 0xc36(%rip), %rsi       # 0x2004
movl $0x25, %edx
movq %rbx, %rdi
callq 0x1130
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
movl $0x1, %ebp
jmp 0x1451
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x157a
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
subq %rdx, %rcx
xorl %ebp, %ebp
xorl %r8d, %r8d
callq 0x1160
cmpl $-0x1, %eax
je 0x1462
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1451
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1120
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %rsi
leaq 0x48(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x15a6
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xbe7(%rip), %rsi       # 0x206c
leaq 0xbe8(%rip), %rdx       # 0x2074
leaq 0x28(%rsp), %rdi
callq 0x16e8
callq 0x1040
movl (%rax), %ebx
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x2b42(%rip), %rdi      # 0x3ff0
callq 0x1130
movq %rax, %r14
leaq 0xb92(%rip), %rsi       # 0x204f
movl $0x1, %edx
movq %rax, %rdi
callq 0x1130
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
leaq 0xb8f(%rip), %rsi       # 0x2075
movl $0x2, %edx
movq %rax, %rdi
callq 0x1130
movl %ebx, %edi
callq 0x1050
movq %r14, %rdi
movq %rax, %rsi
callq 0x1100
movq %rax, %rdi
callq 0x1070
movl $0x1, %edi
callq 0x1140
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1536
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x1120
jmp 0x1536
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x155a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x1120
jmp 0x155a
jmp 0x1557
jmp 0x1557
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1571
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1120
movq %rbx, %rdi
callq 0x1190
nop