// File: /workspace/github_cpp_makefile_star2_O1/rellla[P]E3DC-Rscp/RscpMain.cpp
// Function: createAuthRequest(SRscpFrameBuffer*, e3dc_config_t*)
int createAuthRequest(SRscpFrameBuffer * frameBuffer, e3dc_config_t *e3dc_config)
{
    RscpProtocol protocol;
    SRscpValue rootValue;
    // The root container is create with the TAG ID 0 which is not used by any device.
    protocol.createContainerValue(&rootValue, 0);

    //---------------------------------------------------------------------------------------------------------
    // Create a auth request frame
    //---------------------------------------------------------------------------------------------------------
    printf("\nRequest authentication\n");
    // authentication request
    SRscpValue authenContainer;
    protocol.createContainerValue(&authenContainer,
				  TAG_RSCP_REQ_AUTHENTICATION);
    protocol.appendValue(&authenContainer, TAG_RSCP_AUTHENTICATION_USER,
			 e3dc_config->e3dc_user);
    protocol.appendValue(&authenContainer,
			 TAG_RSCP_AUTHENTICATION_PASSWORD, e3dc_config->e3dc_password);
    // append sub-container to root container
    protocol.appendValue(&rootValue, authenContainer);
    // free memory of sub-container as it is now copied to rootValue
    protocol.destroyValueData(authenContainer);

    // create buffer frame to send data to the S10
    protocol.createFrameAsBuffer(frameBuffer, rootValue.data, rootValue.length, true);	// true to calculate CRC on for transfer
    // the root value object should be destroyed after the data is copied into the frameBuffer and is not needed anymore
    protocol.destroyValueData(rootValue);

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x4bf8
leaq 0x18(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x6(%rsp), %r9
movb $0xe, (%r9)
leaq 0x14(%rsp), %r8
movw $0x0, (%r8)
leaq 0x29(%rsp), %rsi
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x5624
leaq 0xe1b8(%rip), %rdi      # 0x10637
callq 0x21c0
leaq 0x14(%rsp), %rdx
movl $0x1, (%rdx)
leaq 0x5(%rsp), %r9
movb $0xe, (%r9)
leaq 0x6(%rsp), %r8
movw $0x0, (%r8)
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %ecx, %ecx
callq 0x5624
leaq 0x14(%rsp), %r15
movl $0x2, (%r15)
leaq 0x18(%r14), %r12
movq %r12, %rdi
callq 0x2080
leaq 0x6(%rsp), %r8
movw %ax, (%r8)
leaq 0x5(%rsp), %r9
movb $0xd, (%r9)
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x57e6
leaq 0x14(%rsp), %r15
movl $0x3, (%r15)
addq $0x98, %r14
movq %r14, %rdi
callq 0x2080
leaq 0x6(%rsp), %r8
movw %ax, (%r8)
leaq 0x5(%rsp), %r9
movb $0xd, (%r9)
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x57e6
leaq 0x8(%rsp), %rdi
leaq 0x29(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x4894
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5b04
movq 0x30(%rsp), %rdx
movzwl 0x2e(%rsp), %ecx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %r8d
callq 0x4ce0
leaq 0x8(%rsp), %rdi
leaq 0x29(%rsp), %rsi
callq 0x5b04
leaq 0x8(%rsp), %rdi
callq 0x4c04
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x25a4
jmp 0x25a4
jmp 0x25a4
jmp 0x25a4
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4c04
movq %rbx, %rdi
callq 0x2240