// File: /workspace/github_cpp_makefile_star2_O2/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 $0xc8, %rsp
movl %r9d, %ebp
movq %r8, %r15
movq %rcx, %r14
movl %edx, %r13d
movl %esi, %r12d
movl %edi, 0x2c(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movups %xmm0, 0x90(%rsp)
movups %xmm0, 0x80(%rsp)
movups %xmm0, 0x70(%rsp)
movups %xmm0, 0x60(%rsp)
movups %xmm0, 0x50(%rsp)
testl %esi, %esi
jne 0x10cd3
testq %r15, %r15
je 0x10cd3
testl %ebp, %ebp
je 0x10cd3
movl %ebp, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x4290
testl %r13d, %r13d
setne %al
testq %r15, %r15
setne %dl
pushq $0x6
popq %rcx
movb $0xc, %bl
testb %dl, %al
jne 0x10d1f
testq %r15, %r15
sete %al
testl %r13d, %r13d
setne %dl
movb $0x6, %bl
testb %al, %dl
jne 0x10d1f
testq %r15, %r15
setne %al
testl %r12d, %r12d
setne %dl
movb $0xa, %bl
testb %al, %dl
jne 0x10d1f
testq %r15, %r15
setne %al
addb %al, %al
addb $0x6, %al
testl %r12d, %r12d
movzbl %al, %ebx
cmovnel %ecx, %ebx
testq %r15, %r15
pushq $0x20
popq %rax
pushq $0xe
popq %rdx
cmovel %eax, %edx
testl %r12d, %r12d
cmovnel %eax, %edx
leaq 0x18(%rsp), %r8
testq %r15, %r15
cmovel %edx, %ecx
leaq 0x19(%rsp), %r9
testl %r12d, %r12d
cmovel %edx, %ecx
movb %bl, -0x8(%r9)
movb %cl, -0x7(%r9)
movb 0x4(%r14), %al
movb %al, 0xf(%rsp)
testb %al, %al
je 0x10dcc
leaq 0x1a(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x1b(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x1c(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r8, %r10
leaq 0x1d(%rsp), %r8
movq %r9, %r11
leaq 0x1e(%rsp), %r9
orb $0x1, %bl
movb %bl, -0xd(%r9)
movb 0xa(%r14), %al
movb %al, -0xb(%r9)
movb 0x5(%r14), %al
movb %al, -0xa(%r9)
movb 0xb(%r14), %al
movb %al, -0x9(%r9)
movb 0x6(%r14), %al
movb %al, -0x8(%r9)
movb 0xc(%r14), %al
movb %al, -0x7(%r9)
movb $0x10, %cl
pushq $0xe
popq %rbx
pushq $0x8
popq %r13
pushq $0xd
popq %rax
pushq $0x7
popq %rdx
movb $-0x7b, %sil
jmp 0x10e06
leaq 0x13(%rsp), %r10
leaq 0x14(%rsp), %r11
leaq 0x15(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x16(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x17(%rsp), %rax
movq %rax, 0x30(%rsp)
pushq $0x8
popq %rbx
pushq $0x7
popq %r13
pushq $0x6
popq %rax
pushq $0x5
popq %rdx
movb $0xc, %cl
movb $-0x5f, %sil
leaq 0x10(%rsp), %rdi
movb %sil, (%rdi)
movb (%r14,%rdx), %dl
movb %dl, (%r10)
movb (%r14,%rax), %al
movb %al, (%r11)
movb (%r14,%r13), %al
movq 0x40(%rsp), %rdx
movb %al, (%rdx)
movb (%r14,%rbx), %al
movq 0x38(%rsp), %rdx
movb %al, (%rdx)
movb 0x9(%r14), %al
movq 0x30(%rsp), %rdx
movb %al, (%rdx)
movb (%r14), %al
movb %al, (%r8)
movb 0x1(%r14), %dl
movb %dl, (%r9)
cmpl $0x1, %r12d
pushq $-0x2
popq %rdx
sbbl $0x0, %edx
xorl %esi, %esi
cmpq $0x1, %r15
movl $0x0, %r8d
sbbl %r8d, %r8d
orl %edx, %r8d
testq %r15, %r15
cmovel %esi, %ebp
movb %cl, 0x50(%rsp)
movl $0x53, 0x48(%rsp)
movl %r8d, 0x4c(%rsp)
movq %r15, 0x58(%rsp)
movl 0x100(%rsp), %esi
movl %ebp, 0x54(%rsp)
movq %rdi, 0x60(%rsp)
leaq 0xa0(%rsp), %rdx
movq %rdx, 0x68(%rsp)
movb $0x20, 0x51(%rsp)
movzwl 0x8(%r14), %edx
movzbl 0x7(%r14), %edi
cmpb $0x0, 0xf(%rsp)
je 0x10ebb
movb 0xc(%r14), %al
jmp 0x10ebd
andb $0xf, %al
movzbl %al, %eax
shll $0x8, %edx
orl %edi, %edx
shll $0x18, %eax
orl %edx, %eax
leaq 0x48(%rsp), %rdx
movl %eax, 0x30(%rdx)
testl %esi, %esi
movl $0x3e8, %eax            # imm = 0x3E8
cmovnel %esi, %eax
movl %eax, 0x28(%rdx)
xorl %ebp, %ebp
movl $0x2285, %esi           # imm = 0x2285
movl 0x2c(%rsp), %edi
xorl %eax, %eax
callq 0x45e0
cmpl $-0x1, %eax
je 0x10f18
movzbl 0x88(%rsp), %eax
testb $-0x3, %al
jne 0x10f21
movzwl 0x8c(%rsp), %ebp
testl %ebp, %ebp
je 0x10f38
orl $0x100, %ebp            # imm = 0x100
negl %ebp
jmp 0x10f24
callq 0x4050
subl (%rax), %ebp
jmp 0x10f24
pushq $-0x34
popq %rbp
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x8e(%rsp), %ebp
testl %ebp, %ebp
je 0x10f52
orl $0x200, %ebp            # imm = 0x200
cmpl $0x208, %ebp            # imm = 0x208
jne 0x10f14
movq 0x68(%rsp), %rdi
callq 0xcfbd
xorl %ebp, %ebp
testb %al, %al
je 0x10f24
movq 0x68(%rsp), %rdi
callq 0xcfbd
cmpb $0x1, %al
je 0x10f24
movq 0x68(%rsp), %rdi
callq 0x10b3d
movl %eax, %ebp
jmp 0x10f14