// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movq %rcx, %rbx
movq %rdx, %r13
movq 0x8(%rsi), %rax
movq (%rsi), %rcx
movq %rax, %r15
subq %rcx, %r15
sarq $0x2, %r15
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rcx, %rax
je 0x1ca7d
movq (%r13), %rcx
movq 0x8(%r13), %rax
subq %rcx, %rax
sarq $0x3, %rax
imulq %r12, %rax
cmpq %rax, %r15
jne 0x1ca7d
movq 0x8(%rcx), %rax
movq (%rcx), %rcx
movq %rax, %r12
subq %rcx, %r12
sarq $0x2, %r12
subq %rcx, %rax
je 0x1caf8
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
cmpq %rcx, %rax
jne 0x1caf8
movq %rsi, %rbp
movq %rdi, %r14
leaq 0x4(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x3(%rsp), %rcx
movq %r12, %rsi
callq 0x1e4b6
movq (%r13), %rax
movq (%rbp), %rcx
movq (%r14), %rdx
cmpq $0x1, %r12
movq %r12, %rsi
adcq $0x0, %rsi
cmpq $0x1, %r15
adcq $0x0, %r15
xorl %edi, %edi
leaq (%rdi,%rdi,2), %r8
movq (%rax,%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 0x1ca1d
incq %rdi
cmpq %r15, %rdi
jne 0x1ca12
movq (%rbx), %rax
movq (%r14), %rcx
cmpq $0x1, %r12
adcq $0x0, %r12
xorl %edx, %edx
movss (%rax,%rdx,4), %xmm0
addss (%rcx,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %r12
jne 0x1ca54
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x94564(%rip), %rbx     # 0xb0fe8
leaq 0x3689(%rip), %rsi      # 0x20114
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2200
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rbx
leaq 0x35e9(%rip), %rsi      # 0x20096
movl $0x11, %edx
movq %rax, %rdi
callq 0x2200
movq 0x8(%r13), %rsi
subq (%r13), %rsi
sarq $0x3, %rsi
imulq %r12, %rsi
movq %rbx, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x20e0
movl $0x10, %edi
callq 0x20f0
movq %rax, %rbx
leaq 0x3638(%rip), %rsi      # 0x20126
movq %rax, %rdi
callq 0x20b0
jmp 0x1cb6c
movq 0x944e9(%rip), %r14     # 0xb0fe8
leaq 0x363d(%rip), %rsi      # 0x20143
movl $0x12, %edx
movq %r14, %rdi
callq 0x2200
movq %r14, %rdi
movq %r12, %rsi
callq 0x2140
movq %rax, %r14
leaq 0x356e(%rip), %rsi      # 0x20096
movl $0x11, %edx
movq %rax, %rdi
callq 0x2200
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x2, %rsi
movq %r14, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x20e0
movl $0x10, %edi
callq 0x20f0
movq %rax, %rbx
leaq 0x35f2(%rip), %rsi      # 0x20156
movq %rax, %rdi
callq 0x20b0
movq 0x9447d(%rip), %rsi     # 0xb0ff0
movq 0x94436(%rip), %rdx     # 0xb0fb0
movq %rbx, %rdi
callq 0x22c0
jmp 0x1cb84
movq %rax, %r14
movq %rbx, %rdi
callq 0x2180
movq %r14, %rdi
callq 0x22d0