// File: cannam[P]mini-cpp-convnet/flower.cpp
// Function: activation(std::vector<float, std::allocator<float>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<float>
activation(const vector<float> &in,
           string type)
{
    auto out(in);
    size_t sz = out.size();

    if (type == "relu") {
        for (size_t i = 0; i < sz; ++i) {
            if (out[i] < 0.f) {
                out[i] = 0.f;
            }
        }
    } else if (type == "softmax") {
        float sum = 0.f;
        for (size_t i = 0; i < sz; ++i) {
            out[i] = exp(out[i]);
            sum += out[i];
        }
        if (sum != 0.f) {
            for (size_t i = 0; i < sz; ++i) {
                out[i] /= sum;
            }
        }
    } else {
        throw runtime_error("Unknown activation function '" + type + "'");
    }

    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdx, -0xa8(%rbp)
movq %rdi, -0xb0(%rbp)
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x10(%rbp), %rsi
callq 0x4aea0
movq -0xb0(%rbp), %rdi
callq 0x4a7b0
movq -0xa8(%rbp), %rdi
movq %rax, -0x28(%rbp)
leaq 0xa5da(%rip), %rsi      # 0x53144
callq 0x4ad10
movb %al, -0x9a(%rbp)
jmp 0x48b77
movb -0x9a(%rbp), %al
testb $0x1, %al
jne 0x48b83
jmp 0x48bec
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x48be7
movq -0xb0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x4ab60
xorps %xmm0, %xmm0
ucomiss (%rax), %xmm0
jbe 0x48bd7
movq -0xb0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x4ab60
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
jmp 0x48bd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x48e07
jmp 0x48bd9
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x48b8b
jmp 0x48de1
movq -0xa8(%rbp), %rdi
leaq 0xa56d(%rip), %rsi      # 0x53167
callq 0x4ad10
movb %al, -0xb9(%rbp)
jmp 0x48c07
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x48c16
jmp 0x48d04
xorps %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x48c9b
movq -0xb0(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x4ab60
movss (%rax), %xmm0
callq 0x4af90
movss %xmm0, -0xc0(%rbp)
jmp 0x48c53
movq -0xb0(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x4ab60
movss -0xc0(%rbp), %xmm0
movq -0xb0(%rbp), %rdi
movss %xmm0, (%rax)
movq -0x50(%rbp), %rsi
callq 0x4ab60
movss (%rax), %xmm0
addss -0x44(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x48c26
movss -0x44(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x48cac
jp 0x48cac
jmp 0x48cff
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x48cfd
movq -0xb0(%rbp), %rdi
movss -0x44(%rbp), %xmm0
movss %xmm0, -0xc4(%rbp)
movq -0x58(%rbp), %rsi
callq 0x4ab60
movss -0xc4(%rbp), %xmm1
movss (%rax), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x48cb4
jmp 0x48cff
jmp 0x48ddf
movb $0x1, -0x99(%rbp)
movl $0x10, %edi
callq 0x3120
movq -0xa8(%rbp), %rdx
movq %rax, -0xd0(%rbp)
leaq 0xa41f(%rip), %rsi      # 0x53149
leaq -0x98(%rbp), %rdi
callq 0x4ad90
jmp 0x48d38
leaq 0xa426(%rip), %rdx      # 0x53165
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x4ad40
jmp 0x48d51
movq -0xd0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3350
jmp 0x48d63
movq -0xd0(%rbp), %rdi
movb $0x0, -0x99(%rbp)
movq 0xa0278(%rip), %rsi     # 0xe8ff0
movq 0xa0231(%rip), %rdx     # 0xe8fb0
callq 0x3390
jmp 0x48e1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x48dc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x48dba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3180
leaq -0x98(%rbp), %rdi
callq 0x3180
testb $0x1, -0x99(%rbp)
jne 0x48dd1
jmp 0x48ddd
movq -0xd0(%rbp), %rdi
callq 0x31d0
jmp 0x48e07
jmp 0x48de1
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x48df7
movq -0xb0(%rbp), %rdi
callq 0x4aa80
movq -0xb8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0xb0(%rbp), %rdi
callq 0x4aa80
movq -0x30(%rbp), %rdi
callq 0x33b0
nopl (%rax)