// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/region_layer.c
// Function: delta_region_box
float delta_region_box(box truth, float *x, float *biases, int n, int index, int i, int j, int w, int h, float *delta, float scale, int stride)
{
    box pred = get_region_box(x, biases, n, index, i, j, w, h, stride);
    float iou = box_iou(pred, truth);

    float tx = (truth.x*w - i);
    float ty = (truth.y*h - j);
    float tw = log(truth.w*w / biases[2*n]);
    float th = log(truth.h*h / biases[2*n + 1]);

    delta[index + 0*stride] = scale * (tx - x[index + 0*stride]);
    delta[index + 1*stride] = scale * (ty - x[index + 1*stride]);
    delta[index + 2*stride] = scale * (tw - x[index + 2*stride]);
    delta[index + 3*stride] = scale * (th - x[index + 3*stride]);
    return iou;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movlpd %xmm0, -0x18(%rbp)
movlpd %xmm1, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movl %edx, -0x2c(%rbp)
movl %ecx, -0x30(%rbp)
movl %r8d, -0x34(%rbp)
movl %r9d, -0x38(%rbp)
movss %xmm2, -0x3c(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
movl -0x34(%rbp), %r8d
movl -0x38(%rbp), %r9d
movl 0x10(%rbp), %r10d
movl 0x18(%rbp), %r11d
movl 0x28(%rbp), %ebx
movq %rsp, %rax
movl %ebx, 0x10(%rax)
movl %r11d, 0x8(%rax)
movl %r10d, (%rax)
callq 0x4d440
movlpd %xmm0, -0x4c(%rbp)
movlpd %xmm1, -0x44(%rbp)
movsd -0x4c(%rbp), %xmm0
movsd -0x44(%rbp), %xmm1
movsd -0x18(%rbp), %xmm2
movsd -0x10(%rbp), %xmm3
callq 0x44cd0
movss %xmm0, -0x50(%rbp)
movss -0x18(%rbp), %xmm0
cvtsi2ssl 0x10(%rbp), %xmm2
cvtsi2ssl -0x34(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x14(%rbp), %xmm0
cvtsi2ssl 0x18(%rbp), %xmm2
cvtsi2ssl -0x38(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x10(%rbp), %xmm0
cvtsi2ssl 0x10(%rbp), %xmm1
mulss %xmm1, %xmm0
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
divss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x31a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x5c(%rbp)
movss -0xc(%rbp), %xmm0
cvtsi2ssl 0x18(%rbp), %xmm1
mulss %xmm1, %xmm0
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
divss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x31a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x3c(%rbp), %xmm0
movss -0x54(%rbp), %xmm1
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
imull $0x0, 0x28(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
imull $0x0, 0x28(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movss -0x3c(%rbp), %xmm0
movss -0x58(%rbp), %xmm1
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movl 0x28(%rbp), %edx
shll $0x0, %edx
addl %edx, %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movl 0x28(%rbp), %edx
shll $0x0, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movss -0x3c(%rbp), %xmm0
movss -0x5c(%rbp), %xmm1
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movl 0x28(%rbp), %edx
shll %edx
addl %edx, %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movl 0x28(%rbp), %edx
shll %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movss -0x3c(%rbp), %xmm0
movss -0x60(%rbp), %xmm1
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
imull $0x3, 0x28(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
imull $0x3, 0x28(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movss -0x50(%rbp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nop