// File: /workspace/github_c_makefile_star2_O1/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_encode_request_header
int
kmip_encode_request_header(KMIP *ctx, const RequestHeader *value)
{
    int result = 0;
    result = kmip_encode_int32_be(ctx, TAG_TYPE(KMIP_TAG_REQUEST_HEADER, KMIP_TYPE_STRUCTURE));
    CHECK_RESULT(ctx, result);
    
    uint8 *length_index = ctx->index;
    uint8 *value_index = ctx->index += 4;
    
    result = kmip_encode_protocol_version(ctx, value->protocol_version);
    CHECK_RESULT(ctx, result);
    
    /* HERE (ph) Stopped working here after bug with 0 vs KMIP_UNSET */
    if(value->maximum_response_size != KMIP_UNSET)
    {
        result = kmip_encode_integer(ctx, KMIP_TAG_MAXIMUM_RESPONSE_SIZE, value->maximum_response_size);
        CHECK_RESULT(ctx, result);
    }
    
    if(ctx->version >= KMIP_1_4)
    {
        if(value->client_correlation_value != NULL)
        {
            result = kmip_encode_text_string(ctx, KMIP_TAG_CLIENT_CORRELATION_VALUE, value->client_correlation_value);
            CHECK_RESULT(ctx, result);
        }
        
        if(value->server_correlation_value != NULL)
        {
            result = kmip_encode_text_string(ctx, KMIP_TAG_SERVER_CORRELATION_VALUE, value->server_correlation_value);
            CHECK_RESULT(ctx, result);
        }
    }
    
    if(value->asynchronous_indicator != KMIP_UNSET)
    {
        result = kmip_encode_bool(ctx, KMIP_TAG_ASYNCHRONOUS_INDICATOR, value->asynchronous_indicator);
        CHECK_RESULT(ctx, result);
    }
    
    if(ctx->version >= KMIP_1_2)
    {
        if(value->attestation_capable_indicator != KMIP_UNSET)
        {
            result = kmip_encode_bool(ctx, KMIP_TAG_ATTESTATION_CAPABLE_INDICATOR, value->attestation_capable_indicator);
            CHECK_RESULT(ctx, result);
        }
        
        for(size_t i = 0; i < value->attestation_type_count; i++)
        {
            result = kmip_encode_enum(ctx, KMIP_TAG_ATTESTATION_TYPE, value->attestation_types[i]);
            CHECK_RESULT(ctx, result);
        }
    }
    
    if(value->authentication != NULL)
    {
        result = kmip_encode_authentication(ctx, value->authentication);
        CHECK_RESULT(ctx, result);
    }
    
    if(value->batch_error_continuation_option != 0)
    {
        result = kmip_encode_enum(ctx, KMIP_TAG_BATCH_ERROR_CONTINUATION_OPTION, value->batch_error_continuation_option);
        CHECK_RESULT(ctx, result);
    }
    
    if(value->batch_order_option != KMIP_UNSET)
    {
        result = kmip_encode_bool(ctx, KMIP_TAG_BATCH_ORDER_OPTION, value->batch_order_option);
        CHECK_RESULT(ctx, result);
    }
    
    if(value->time_stamp != 0)
    {
        result = kmip_encode_date_time(ctx, KMIP_TAG_TIME_STAMP, value->time_stamp);
        CHECK_RESULT(ctx, result);
    }
    
    result = kmip_encode_integer(ctx, KMIP_TAG_BATCH_COUNT, value->batch_count);
    CHECK_RESULT(ctx, result);
    
    uint8 *curr_index = ctx->index;
    ctx->index = length_index;

    result = kmip_encode_length(ctx, curr_index - value_index);
    CHECK_RESULT(ctx, result);

    ctx->index = curr_index;
    
    return(KMIP_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl $0x42007701, %esi       # imm = 0x42007701
callq 0x60a0
testl %eax, %eax
je 0xf4ce
movl %eax, %ebp
leaq 0x11fde(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f60, %edx           # imm = 0x1F60
jmp 0xf4fb
movq 0x8(%rbx), %r12
leaq 0x4(%r12), %r15
movq %r15, 0x8(%rbx)
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x6ac0
testl %eax, %eax
je 0xf511
movl %eax, %ebp
leaq 0x11faf(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f66, %edx           # imm = 0x1F66
callq 0x6de0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%r14), %edx
cmpl $-0x1, %edx
je 0xf53e
movq %rbx, %rdi
movl $0x420050, %esi         # imm = 0x420050
callq 0x63d0
testl %eax, %eax
je 0xf53e
movl %eax, %ebp
leaq 0x11f6e(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f6c, %edx           # imm = 0x1F6C
jmp 0xf4fb
cmpl $0x4, 0x18(%rbx)
jb 0xf5a1
movq 0x40(%r14), %rdx
testq %rdx, %rdx
je 0xf571
movq %rbx, %rdi
movl $0x420105, %esi         # imm = 0x420105
callq 0x6670
testl %eax, %eax
je 0xf571
movl %eax, %ebp
leaq 0x11f3b(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f74, %edx           # imm = 0x1F74
jmp 0xf4fb
movq 0x48(%r14), %rdx
testq %rdx, %rdx
je 0xf5a1
movq %rbx, %rdi
movl $0x420106, %esi         # imm = 0x420106
callq 0x6670
testl %eax, %eax
je 0xf5a1
movl %eax, %ebp
leaq 0x11f0e(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f7a, %edx           # imm = 0x1F7A
jmp 0xf4fb
movl 0xc(%r14), %edx
cmpl $-0x1, %edx
je 0xf5d1
movq %rbx, %rdi
movl $0x420007, %esi         # imm = 0x420007
callq 0x6570
testl %eax, %eax
je 0xf5d1
movl %eax, %ebp
leaq 0x11ede(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f81, %edx           # imm = 0x1F81
jmp 0xf4fb
cmpl $0x2, 0x18(%rbx)
jb 0xf688
movl 0x2c(%r14), %edx
cmpl $-0x1, %edx
je 0xf60b
movq %rbx, %rdi
movl $0x4200d3, %esi         # imm = 0x4200D3
callq 0x6570
testl %eax, %eax
je 0xf60b
movl %eax, %ebp
leaq 0x11ea4(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f89, %edx           # imm = 0x1F89
jmp 0xf4fb
cmpq $0x0, 0x38(%r14)
setne %r13b
je 0xf631
movq 0x30(%r14), %rax
movl (%rax), %edx
movq %rbx, %rdi
movl $0x4200c7, %esi         # imm = 0x4200C7
callq 0x66d0
testl %eax, %eax
je 0xf633
movl %eax, %ebp
jmp 0xf66b
jmp 0xf67f
movl $0x1, %r13d
cmpq 0x38(%r14), %r13
setb 0x7(%rsp)
jae 0xf76d
movq 0x30(%r14), %rax
movl (%rax,%r13,4), %edx
movq %rbx, %rdi
movl $0x4200c7, %esi         # imm = 0x4200C7
callq 0x66d0
incq %r13
testl %eax, %eax
je 0xf639
movl %eax, %ebp
movb 0x7(%rsp), %r13b
leaq 0x11e30(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f8f, %edx           # imm = 0x1F8F
callq 0x6de0
testb %r13b, %r13b
jne 0xf500
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0xf6b3
movq %rbx, %rdi
callq 0x6580
testl %eax, %eax
je 0xf6b3
movl %eax, %ebp
leaq 0x11dfc(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f96, %edx           # imm = 0x1F96
jmp 0xf4fb
movl 0x18(%r14), %edx
testl %edx, %edx
je 0xf6e2
movq %rbx, %rdi
movl $0x42000e, %esi         # imm = 0x42000E
callq 0x66d0
testl %eax, %eax
je 0xf6e2
movl %eax, %ebp
leaq 0x11dcd(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1f9c, %edx           # imm = 0x1F9C
jmp 0xf4fb
movl 0x1c(%r14), %edx
cmpl $-0x1, %edx
je 0xf712
movq %rbx, %rdi
movl $0x420010, %esi         # imm = 0x420010
callq 0x6570
testl %eax, %eax
je 0xf712
movl %eax, %ebp
leaq 0x11d9d(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1fa2, %edx           # imm = 0x1FA2
jmp 0xf4fb
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0xf742
movq %rbx, %rdi
movl $0x420092, %esi         # imm = 0x420092
callq 0x6210
testl %eax, %eax
je 0xf742
movl %eax, %ebp
leaq 0x11d6d(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1fa8, %edx           # imm = 0x1FA8
jmp 0xf4fb
movl 0x28(%r14), %edx
movq %rbx, %rdi
movl $0x42000d, %esi         # imm = 0x42000D
callq 0x63d0
testl %eax, %eax
je 0xf777
movl %eax, %ebp
leaq 0x11d42(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1fac, %edx           # imm = 0x1FAC
jmp 0xf4fb
movb 0x7(%rsp), %r13b
jmp 0xf67f
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6a80
testl %eax, %eax
je 0xf7a7
movl %eax, %ebp
leaq 0x11d08(%rip), %rsi     # 0x214a2
movq %rbx, %rdi
movl $0x1fb2, %edx           # imm = 0x1FB2
jmp 0xf4fb
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xf500