// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rsi, %rbp
movq %rdi, %r15
movq 0x8(%rsi), %rsi
movq (%rbp), %rdi
movq %rsi, %r12
subq %rdi, %r12
sarq $0x2, %r12
movq (%rdx), %rcx
movq 0x8(%rdx), %rax
subq %rcx, %rax
pushq $0x18
popq %r13
cqto
idivq %r13
cmpq %rdi, %rsi
je 0x1b9b3
cmpq %rax, %r12
jne 0x1b9b3
movq 0x8(%rcx), %rax
movq (%rcx), %rcx
movq %rax, %r13
subq %rcx, %r13
sarq $0x2, %r13
subq %rcx, %rax
je 0x1ba1b
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
cmpq %rcx, %rax
jne 0x1ba1b
leaq 0x4(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x3(%rsp), %rcx
movq %r15, %rdi
movq %r13, %rsi
callq 0x1ca80
xorl %eax, %eax
cmpq %r12, %rax
je 0x1b980
imulq $0x18, %rax, %rcx
addq (%r14), %rcx
movq (%rbp), %rdx
movq (%r15), %rsi
xorl %edi, %edi
cmpq %rdi, %r13
je 0x1b97b
movq (%rcx), %r8
movss (%r8,%rdi,4), %xmm0
mulss (%rdx,%rax,4), %xmm0
addss (%rsi,%rdi,4), %xmm0
movss %xmm0, (%rsi,%rdi,4)
incq %rdi
jmp 0x1b959
incq %rax
jmp 0x1b944
movq (%rbx), %rax
movq (%r15), %rcx
xorl %edx, %edx
cmpq %rdx, %r13
je 0x1b9a1
movss (%rax,%rdx,4), %xmm0
addss (%rcx,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rdx,4)
incq %rdx
jmp 0x1b988
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9662e(%rip), %rdi     # 0xb1fe8
leaq 0x372b(%rip), %rsi      # 0x1f0ec
callq 0x21c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x2130
leaq 0x3696(%rip), %rsi      # 0x1f06e
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movq 0x8(%r14), %rax
subq (%r14), %rax
cqto
idivq %r13
movq %rax, %rsi
callq 0x2130
movq %rax, %rdi
callq 0x20d0
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x36ed(%rip), %rsi      # 0x1f0fe
movq %rax, %rdi
callq 0x2090
jmp 0x1ba7d
movq 0x965c6(%rip), %rdi     # 0xb1fe8
leaq 0x36f2(%rip), %rsi      # 0x1f11b
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x2130
leaq 0x362e(%rip), %rsi      # 0x1f06e
movq %rax, %rdi
callq 0x21c0
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
callq 0x20d0
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x36b9(%rip), %rsi      # 0x1f12e
movq %rax, %rdi
callq 0x2090
movq 0x9656c(%rip), %rsi     # 0xb1ff0
movq 0x96525(%rip), %rdx     # 0xb1fb0
movq %rbx, %rdi
callq 0x22c0
jmp 0x1ba95
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x22d0