// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, -0x40(%rbp)
movq 0x8(%rsi), %rcx
movq %rsi, -0x30(%rbp)
subq (%rsi), %rcx
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
shrq $0x5, %rcx
movq %rcx, -0x38(%rbp)
testl %ecx, %ecx
jle 0x3954
movq -0x38(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0x48(%rbp)
xorl %r15d, %r15d
movq 0x376a(%rip), %r14      # 0x6fd0
xorl %ebx, %ebx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax,%r15), %r12
movl $0xd, %edx
movq %r14, %rdi
leaq 0x1813(%rip), %rsi      # 0x5096
callq 0x2240
movq %r14, %rdi
movl %r12d, %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(%r12), %eax
movslq %eax, %r13
movl $0x1, %esi
movq %r13, %rdi
callq 0x2140
movq %r12, %rcx
movq %rax, %r12
movl 0x38f6(%rip), %eax      # 0x71d4
movl %eax, (%r12)
movq -0x38(%rbp), %rax
movl %eax, 0x4(%r12)
movl %ebx, 0x8(%r12)
leaq 0xc(%r12), %rdi
movq %rbx, -0x50(%rbp)
movq -0x30(%rbp), %rbx
movq (%rbx), %r14
movq (%r14,%r15), %rsi
movslq %ecx, %rdx
callq 0x2190
movq 0x8(%rbx), %rdx
movq -0x50(%rbp), %rbx
subq %r14, %rdx
sarq $0x5, %rdx
cmpq %rbx, %rdx
jbe 0x39ab
movq 0x8(%r14,%r15), %rdx
addq %r15, %r14
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
movq %r13, %r8
callq 0x22f0
incq %rbx
addq $0x20, %r15
cmpq %rbx, -0x48(%rbp)
movq 0x3682(%rip), %r14      # 0x6fd0
jne 0x3868
movq -0x30(%rbp), %rcx
movq (%rcx), %rax
movq -0x40(%rbp), %rbx
movq %rax, (%rbx)
movq 0x8(%rcx), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3999
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18fd(%rip), %rdi      # 0x52af
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22b0
jmp 0x39c0
jmp 0x39c0
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x39dc
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2340