// File: /workspace/github_cpp_makefile_star2_O1/trapexit[P]bbf/src/sg.cpp
// Function: sg::exec(int, int, int, sg::ata_tf const*, void*, unsigned int, unsigned int)
int
  exec(const int            fd,
       const int            rw,
       const int            dma,
       const struct ata_tf *tf,
       void                *data,
       const unsigned int   data_bytes,
       const unsigned int   timeout)
  {
    int rv;
    uint8_t cdb[SG_ATA_16_LEN] = {0};
    uint8_t sb[32]             = {0};
    sg_io_hdr_t io_hdr         = {0};

    if(data && data_bytes && !rw)
      memset(data,0,data_bytes);

    cdb[1]         = calculate_cdb1(dma,rw,data);
    cdb[2]         = calculate_cdb2(rw,data);
    io_hdr.cmd_len = populate_cdb_from_tf(cdb,tf);
    populate_io_hdr(&io_hdr,cdb,sb,tf,data,data_bytes,rw,timeout);

    return sg::exec_core(fd,io_hdr);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, %ebp
movq %r8, %r15
movq %rcx, %r14
movl %edx, %r13d
movl %esi, %r12d
movl %edi, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x60(%rsp)
testl %esi, %esi
jne 0x14885
testq %r15, %r15
je 0x14885
testl %ebp, %ebp
je 0x14885
movl %ebp, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x4280
testl %r13d, %r13d
setne %al
testq %r15, %r15
setne %dl
movb $0xc, %cl
testb %dl, %al
jne 0x148d3
testq %r15, %r15
sete %al
testl %r13d, %r13d
setne %dl
movb $0x6, %cl
testb %al, %dl
jne 0x148d3
testq %r15, %r15
setne %al
testl %r12d, %r12d
setne %dl
movb $0xa, %cl
testb %al, %dl
jne 0x148d3
testq %r15, %r15
setne %al
addb %al, %al
addb $0x6, %al
testl %r12d, %r12d
movzbl %al, %eax
movl $0x6, %ecx
cmovel %eax, %ecx
testq %r15, %r15
movl $0x20, %eax
movl $0xe, %edx
cmovel %eax, %edx
testl %r12d, %r12d
cmovnel %eax, %edx
testq %r15, %r15
movl $0x6, %eax
cmovel %edx, %eax
testl %r12d, %r12d
cmovel %edx, %eax
movb %cl, 0x1(%rsp)
movb %al, 0x2(%rsp)
movb 0x4(%r14), %al
testb %al, %al
je 0x14978
movb $-0x7b, (%rsp)
orb $0x1, %cl
movb %cl, 0x1(%rsp)
movb 0xa(%r14), %cl
movb %cl, 0x3(%rsp)
movb 0x5(%r14), %cl
movb %cl, 0x4(%rsp)
movb 0xb(%r14), %cl
movb %cl, 0x5(%rsp)
movb 0x6(%r14), %cl
movb %cl, 0x6(%rsp)
movb 0xc(%r14), %cl
movb %cl, 0x7(%rsp)
movb 0x7(%r14), %cl
movb %cl, 0x8(%rsp)
movb 0xd(%r14), %cl
movb %cl, 0x9(%rsp)
movb 0x8(%r14), %cl
movb %cl, 0xa(%rsp)
movb 0xe(%r14), %cl
movb %cl, 0xb(%rsp)
movb 0x9(%r14), %cl
movb %cl, 0xc(%rsp)
movb (%r14), %cl
movb %cl, 0xd(%rsp)
movb 0x1(%r14), %cl
movb %cl, 0xe(%rsp)
movb $0x10, %dl
jmp 0x149b5
movb $-0x5f, (%rsp)
movb 0x5(%r14), %cl
movb %cl, 0x3(%rsp)
movb 0x6(%r14), %cl
movb %cl, 0x4(%rsp)
movb 0x7(%r14), %cl
movb %cl, 0x5(%rsp)
movb 0x8(%r14), %cl
movb %cl, 0x6(%rsp)
movb 0x9(%r14), %cl
movb %cl, 0x7(%rsp)
movb (%r14), %cl
movb %cl, 0x8(%rsp)
movb 0x1(%r14), %cl
movb %cl, 0x9(%rsp)
movb $0xc, %dl
cmpl $0x1, %r12d
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
sbbl $0x0, %esi
movl 0xd0(%rsp), %ecx
xorl %edi, %edi
cmpq $0x1, %r15
movl $0x0, %r8d
sbbl %r8d, %r8d
orl %esi, %r8d
testq %r15, %r15
cmovel %edi, %ebp
movb %dl, 0x18(%rsp)
movl $0x53, 0x10(%rsp)
movl %r8d, 0x14(%rsp)
movq %r15, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
movq %rsp, %rdx
movq %rdx, 0x28(%rsp)
leaq 0x70(%rsp), %rdx
movq %rdx, 0x30(%rsp)
movb $0x20, 0x19(%rsp)
movzbl 0x9(%r14), %edi
movzbl 0x8(%r14), %edx
movzbl 0x7(%r14), %esi
testb %al, %al
je 0x14a2a
movb 0xc(%r14), %al
jmp 0x14a2f
movb (%r14), %al
andb $0xf, %al
movzbl %al, %eax
shll $0x10, %edi
shll $0x8, %edx
orl %edi, %edx
orl %esi, %edx
shll $0x18, %eax
orl %edx, %eax
leaq 0x10(%rsp), %rdx
movl %eax, 0x30(%rdx)
testl %ecx, %ecx
movl $0x3e8, %eax            # imm = 0x3E8
cmovnel %ecx, %eax
movl %eax, 0x28(%rdx)
xorl %ebp, %ebp
movl $0x2285, %esi           # imm = 0x2285
movl %ebx, %edi
xorl %eax, %eax
callq 0x45b0
cmpl $-0x1, %eax
je 0x14a87
movzbl 0x50(%rsp), %eax
testb $-0x3, %al
jne 0x14a90
movzwl 0x54(%rsp), %ebp
testl %ebp, %ebp
je 0x14aa9
orl $0x100, %ebp            # imm = 0x100
negl %ebp
jmp 0x14a95
callq 0x4060
subl (%rax), %ebp
jmp 0x14a95
movl $0xffffffcc, %ebp       # imm = 0xFFFFFFCC
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x56(%rsp), %ebp
testl %ebp, %ebp
je 0x14ac0
orl $0x200, %ebp            # imm = 0x200
cmpl $0x208, %ebp            # imm = 0x208
jne 0x14a83
movq 0x30(%rsp), %rdi
callq 0xff71
xorl %ebp, %ebp
testb %al, %al
je 0x14a95
movq 0x30(%rsp), %rdi
callq 0xff71
cmpb $0x1, %al
je 0x14a95
movq 0x30(%rsp), %rdi
callq 0x146e5
movl %eax, %ebp
jmp 0x14a83