// File: /workspace/github_cpp_makefile_star2_O3/awbrenn[P]robot-controller/Middleware.cpp
// Function: addHeaderToResponseToClient(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>)
vector<string> addHeaderToResponseToClient(vector<string> fragmented_response) {
    uint32_t number_of_messages = fragmented_response.size();
    uint32_t sequence_number = 0;
    string body;
    int i;

    number_of_messages = fragmented_response.size();

    /* add header to each of the fragmented responses */
    for (i = 0; i < (int) number_of_messages; i++) {
        sequence_number = i;
        int body_length = fragmented_response[i].length();
        cout << "Body length: " << body_length << endl;
        char * body = (char *) calloc(body_length + 12, sizeof(char));
        memcpy(body, &REQUEST_ID, 4);
        memcpy(body + 4, &number_of_messages, 4);
        memcpy(body + 8, &sequence_number, 4);
        memcpy(body + 12, fragmented_response[i].data(), body_length);
        fragmented_response.at(i).assign(body, body_length + 12);
    }

    return fragmented_response;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
movq %rcx, %r8
subq %rax, %r8
leaq -0x40(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq $0x0, -0x8(%rdx)
movb $0x0, (%rdx)
shrq $0x5, %r8
movq %rdx, %rdi
testl %r8d, %r8d
jle 0x3978
movq %rbx, -0x58(%rbp)
movq %r8, -0x68(%rbp)
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r8, -0x60(%rbp)
xorl %r15d, %r15d
movq 0x376f(%rip), %r14      # 0x6fd0
movq $0x0, -0x30(%rbp)
movq %rsi, %rbx
movq %rsi, -0x70(%rbp)
movq (%rbx), %rax
movq %r15, -0x78(%rbp)
movq 0x8(%rax,%r15), %rbx
movl $0xd, %edx
movq %r14, %rdi
leaq 0x180b(%rip), %rsi      # 0x5096
callq 0x2240
movq %r14, %rdi
movl %ebx, %esi
callq 0x2320
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leal 0xc(%rbx), %eax
movslq %eax, %r13
movl $0x1, %esi
movq %r13, %rdi
callq 0x2140
movq %rax, %r12
movl 0x38f4(%rip), %eax      # 0x71d4
movl %eax, (%r12)
movq -0x68(%rbp), %rax
movl %eax, 0x4(%r12)
movq -0x30(%rbp), %rax
movl %eax, 0x8(%r12)
leaq 0xc(%r12), %rdi
movq -0x70(%rbp), %rax
movq (%rax), %r14
movq -0x78(%rbp), %r15
movq (%r14,%r15), %rsi
movslq %ebx, %rdx
movq %rax, %rbx
callq 0x2190
movq 0x8(%rbx), %rdx
subq %r14, %rdx
sarq $0x5, %rdx
cmpq -0x30(%rbp), %rdx
jbe 0x39b8
movq 0x8(%r14,%r15), %rdx
addq %r15, %r14
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
movq %r13, %r8
callq 0x22f0
movq -0x30(%rbp), %rcx
incq %rcx
addq $0x20, %r15
movq %rcx, -0x30(%rbp)
cmpq %rcx, -0x60(%rbp)
movq 0x3674(%rip), %r14      # 0x6fd0
jne 0x3870
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rdx
movq %rbx, %rsi
movq -0x58(%rbp), %rbx
movq %rax, (%rbx)
movq %rcx, 0x8(%rbx)
movq 0x10(%rsi), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
cmpq %rdx, %rdi
je 0x39a6
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18f0(%rip), %rdi      # 0x52af
movq -0x30(%rbp), %rsi
xorl %eax, %eax
callq 0x22b0
jmp 0x39ce
jmp 0x39ce
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x39ea
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2340