// File: /workspace/github_cpp_makefile_star2_O1/cannam[P]mini-cpp-convnet/flower.cpp
// Function: dense(std::vector<float, std::allocator<float>> const&, std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>> const&, std::vector<float, std::allocator<float>> const&)
vector<float>
dense(const vector<float> &in,
      const vector<vector<float>> &weights,
      const vector<float> &biases)
{
    size_t in_size = in.size();
    if (in_size != weights.size() || in_size == 0) {
        cerr << "dense: in_size = " << in_size
             << " but we expected " << weights.size() << endl;
        throw runtime_error("Input size mismatch in dense");
    }

    size_t out_size = weights[0].size();
    if (out_size != biases.size() || out_size == 0) {
        cerr << "dense: out_size = " << out_size
             << " but we expected " << biases.size() << endl;
        throw runtime_error("Output size mismatch in dense");
    }
    
#ifdef VERBOSE
    cerr << "dense: input length " << in_size << ", output length "
         << out_size << endl;
#endif

    vector<float> out(out_size, 0.f);

    for (size_t i = 0; i < in_size; ++i) {
        for (size_t j = 0; j < out_size; ++j) {
            out[j] += weights[i][j] * in[i];
        }
    }

    for (size_t j = 0; j < out_size; ++j) {
        out[j] += biases[j];
    }

    return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq (%rsi), %r8
movq 0x8(%rsi), %rbp
movq %rbp, %r12
subq %r8, %r12
sarq $0x2, %r12
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %r8, %rbp
je 0x1d114
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rdx, %r12
jne 0x1d114
movq %r8, 0x28(%rsp)
movq %rsi, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq (%rax), %rbx
movq 0x8(%rax), %r15
movq %r15, %r14
subq %rbx, %r14
sarq $0x2, %r14
movq %r15, %rax
subq %rbx, %rax
je 0x1d18e
movq 0x8(%rcx), %rdx
subq (%rcx), %rdx
cmpq %rdx, %rax
jne 0x1d18e
movq %rcx, 0x20(%rsp)
leaq 0x34(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0xf(%rsp), %rcx
movq %r14, %rsi
movq %rdi, %r13
callq 0x1ead4
cmpq 0x28(%rsp), %rbp
je 0x1d0d0
movq 0x18(%rsp), %rcx
movq (%rcx), %r10
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq (%r13), %rdx
cmpq $0x1, %r14
movq %r14, %rsi
adcq $0x0, %rsi
cmpq $0x1, %r12
adcq $0x0, %r12
xorl %edi, %edi
cmpq %rbx, %r15
je 0x1d0c8
leaq (%rdi,%rdi,2), %r8
movq (%r10,%r8,8), %r8
xorl %r9d, %r9d
movss (%r8,%r9,4), %xmm0
mulss (%rcx,%rdi,4), %xmm0
addss (%rdx,%r9,4), %xmm0
movss %xmm0, (%rdx,%r9,4)
incq %r9
cmpq %r9, %rsi
jne 0x1d0a9
incq %rdi
cmpq %r12, %rdi
jne 0x1d099
cmpq %rbx, %r15
movq 0x20(%rsp), %rcx
je 0x1d102
movq (%rcx), %rsi
movq (%r13), %rcx
cmpq $0x1, %r14
adcq $0x0, %r14
xorl %edx, %edx
movss (%rsi,%rdx,4), %xmm0
addss (%rcx,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %r14
jne 0x1d0eb
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x94ecd(%rip), %rbx     # 0xb1fe8
leaq 0x3fca(%rip), %rsi      # 0x210ec
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2200
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2140
movq %rax, %rbx
leaq 0x3f2a(%rip), %rsi      # 0x2106e
movl $0x11, %edx
movq %rax, %rdi
callq 0x2200
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
movq %rbx, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x20e0
movl $0x10, %edi
callq 0x20f0
movq %rax, %rbx
leaq 0x3f7a(%rip), %rsi      # 0x210fe
movq %rax, %rdi
callq 0x20b0
jmp 0x1d205
movq 0x94e53(%rip), %rbx     # 0xb1fe8
leaq 0x3f7f(%rip), %rsi      # 0x2111b
movl $0x12, %edx
movq %rbx, %rdi
movq %rcx, %r15
callq 0x2200
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2140
movq %rax, %r14
leaq 0x3ead(%rip), %rsi      # 0x2106e
movl $0x11, %edx
movq %rax, %rdi
callq 0x2200
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x2, %rsi
movq %r14, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x20e0
movl $0x10, %edi
callq 0x20f0
movq %rax, %rbx
leaq 0x3f31(%rip), %rsi      # 0x2112e
movq %rax, %rdi
callq 0x20b0
movq 0x94de4(%rip), %rsi     # 0xb1ff0
movq 0x94d9d(%rip), %rdx     # 0xb1fb0
movq %rbx, %rdi
callq 0x22c0
jmp 0x1d21d
movq %rax, %r14
movq %rbx, %rdi
callq 0x2180
movq %r14, %rdi
callq 0x22d0