// File: /workspace/github_c_makefile_star2_O1/Cotix[P]cReddit/libreddit/token.c
// Function: performIdentAction
int performIdentAction(TokenParser *p, TokenIdent *identifiers, int i, va_list args)
{
    char *tmp = NULL;
    int performedAction = 0, len;

    time_t created_time_t;
    struct tm *localtime_internal_data;
    struct tm *created_struct_tm;
    char *formatted_time_string;

    READ_TOKEN_TO_TMP(p->block->memory, tmp, p->tokens[p->currentToken]);

    if (TOKEN_EQUALS(tmp, identifiers[i].name)) {
        switch(identifiers[i].action) {
        case TOKEN_CHECK_CALL:
            (p->currentToken)++;
            CALL_TOKEN_FUNC(identifiers[i].funcCallback, p, identifiers, args);
            performedAction = 1;
            break;

        case TOKEN_SET_PARSE:
            (p->currentToken)++;
            if (identifiers[i].freeFlag) {
                free(*((char**)identifiers[i].value));
                free(*(identifiers[i].parseStrWide));
                free(*(identifiers[i].parseStr));
            }

            *((char**)identifiers[i].value) = getCopyOfToken(p->block->memory, p->tokens[p->currentToken]);

            len = p->tokens[p->currentToken].end - p->tokens[p->currentToken].start;

            *(identifiers[i].parseStr)     = redditParseEscCodes    (*((char**)identifiers[i].value), len);
            *(identifiers[i].parseStrWide) = redditParseEscCodesWide(*((char**)identifiers[i].value), len);

            break;

        case TOKEN_SET:
            (p->currentToken)++;
            READ_TOKEN_TO_TMP(p->block->memory, tmp, p->tokens[p->currentToken]);
            switch(identifiers[i].type) {
            case TOKEN_BOOL:
                if (TOKEN_IS_TRUE(p->block->memory, p->tokens[p->currentToken]))
                    *((unsigned int *)identifiers[i].value) |= identifiers[i].bitMask;
                else
                    *((unsigned int *)identifiers[i].value) &= ~identifiers[i].bitMask;

                break;
            case TOKEN_INT:
                *((int*)(identifiers[i].value)) = atoi(tmp);
                break;
            case TOKEN_STRING:
            case TOKEN_OBJECT:
                if (identifiers[i].freeFlag)
                    free(*((char**)identifiers[i].value));

                *((char**)identifiers[i].value) = getCopyOfToken(p->block->memory, p->tokens[p->currentToken]);
                break;
            case TOKEN_DATE:
                // Process the tmp char* string as a date
                created_time_t = atol(tmp);
                created_struct_tm = (struct tm *)(rmalloc(sizeof(struct tm)));
                formatted_time_string = (char *)(rmalloc(CREATE_DATE_FORMAT_BYTE_COUNT));
                
                // Convert created_time_t (seconds since epoch) to 
                // the struct tm object of localtime_internal_data. After we get
                // the value, copy the internal data (static data)to a newly created
                // struct tm object.
                localtime_internal_data = localtime(&created_time_t);
                if (localtime_internal_data != NULL)
                {
                    memcpy(created_struct_tm, localtime_internal_data, sizeof(struct tm));

                    // Use strftime to convert the struct tm to a formatted string. The
                    // format for the string is specified by CREATE_DATE_FORMAT
                    if (0 != strftime(formatted_time_string, CREATE_DATE_FORMAT_BYTE_COUNT, 
                                CREATE_DATE_FORMAT, created_struct_tm))
                    {
                        *((char**)identifiers[i].value) = formatted_time_string;
                    }
                }

                // Free only created_struct_tm, don't free formatted_time_string
                // because that data is now pointed to by identifiers[i].value
                free(created_struct_tm);
                break;
            }
            performedAction = 1;

            break;
        }
    }

    free(tmp);
    return performedAction;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r13
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r15
movq 0x8(%rdi), %rax
movslq 0x14(%rdi), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x8(%rax,%rdx), %ecx
subl 0x4(%rax,%rdx), %ecx
incl %ecx
movslq %ecx, %rsi
xorl %edi, %edi
callq 0x354f
movq %rax, %rbx
movq (%r15), %rax
movq 0x8(%r15), %rcx
movslq 0x14(%r15), %rdx
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rdi
addq %rdx, %rdi
movslq 0x4(%rcx,%rdi), %r8
movq (%rax), %rsi
addq %r8, %rsi
movslq 0x8(%rcx,%rdi), %rdx
subq %r8, %rdx
movq %rbx, %rdi
callq 0x2140
movq 0x8(%r15), %rax
movslq 0x14(%r15), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movslq 0x8(%rax,%rdx), %rcx
movslq 0x4(%rax,%rdx), %rax
subq %rax, %rcx
movb $0x0, (%rbx,%rcx)
movslq %ebp, %rax
imulq $0x38, %rax, %r14
movq (%r12,%r14), %rsi
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0x4658
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x2040
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r12, %r14
movl 0xc(%r14), %eax
testl %eax, %eax
je 0x4719
cmpl $0x1, %eax
je 0x4699
cmpl $0x2, %eax
jne 0x463d
incl 0x14(%r15)
movq 0x10(%r13), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
movups (%r13), %xmm0
movaps %xmm0, (%rdx)
movq %r15, %rdi
movq %r12, %rsi
callq *0x30(%r14)
movl $0x1, %ebp
jmp 0x463f
incl 0x14(%r15)
cmpb $0x1, 0x2c(%r14)
jne 0x46c8
movq 0x10(%r14), %rax
movq (%rax), %rdi
callq 0x2040
movq 0x20(%r14), %rax
movq (%rax), %rdi
callq 0x2040
movq 0x18(%r14), %rax
movq (%rax), %rdi
callq 0x2040
movq 0x8(%r15), %rax
movslq 0x14(%r15), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movslq 0x4(%rax,%rdx), %r12
movl 0x8(%rax,%rdx), %ebp
subl %r12d, %ebp
js 0x482d
movq (%r15), %rax
leal 0x1(%rbp), %edi
addq (%rax), %r12
callq 0x3538
movq %rax, %r13
movl %ebp, %ebp
movq %rax, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x2140
movb $0x0, (%r13,%rbp)
jmp 0x4830
movslq 0x14(%r15), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x14(%r15)
movq 0x8(%r15), %rdx
leaq (%rcx,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rcx, %rax
incq %rax
movl 0x8(%rdx,%rax), %ecx
subl 0x4(%rdx,%rax), %ecx
incl %ecx
movslq %ecx, %rsi
movq %rbx, %rdi
callq 0x354f
movq %rax, %rbx
movq (%r15), %rax
movq 0x8(%r15), %rcx
movslq 0x14(%r15), %rdx
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rdi
addq %rdx, %rdi
movslq 0x4(%rcx,%rdi), %r8
movq (%rax), %rsi
addq %r8, %rsi
movslq 0x8(%rcx,%rdi), %rdx
subq %r8, %rdx
movq %rbx, %rdi
callq 0x2140
movq 0x8(%r15), %rax
movslq 0x14(%r15), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movslq 0x8(%rax,%rdx), %rcx
movslq 0x4(%rax,%rdx), %rax
subq %rax, %rcx
movb $0x0, (%rbx,%rcx)
movl 0x8(%r14), %eax
movl $0x1, %ebp
cmpq $0x4, %rax
ja 0x463f
leaq 0x18be(%rip), %rcx      # 0x607c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x2c(%r14)
jne 0x47da
movq 0x10(%r14), %rax
movq (%rax), %rdi
callq 0x2040
movq 0x8(%r15), %rax
movslq 0x14(%r15), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movslq 0x4(%rax,%rdx), %r12
movl 0x8(%rax,%rdx), %r13d
subl %r12d, %r13d
js 0x4962
movq (%r15), %rax
leal 0x1(%r13), %edi
addq (%rax), %r12
callq 0x3538
movq %rax, %r15
movl %r13d, %r13d
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2140
movb $0x0, (%r15,%r13)
jmp 0x4965
xorl %r13d, %r13d
movq 0x10(%r14), %rax
movq %r13, (%rax)
movq 0x8(%r15), %rax
movslq 0x14(%r15), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x8(%rax,%rdx), %ebp
subl 0x4(%rax,%rdx), %ebp
movq 0x10(%r14), %rax
movq (%rax), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x4dfa
movq 0x18(%r14), %rcx
movq %rax, (%rcx)
movq 0x10(%r14), %rax
movq (%rax), %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x4dfa
movq 0x20(%r14), %rcx
movq %rax, (%rcx)
jmp 0x463d
movq %rbx, %rdi
callq 0x21e0
movq %rsp, %r13
movq %rax, (%r13)
movl $0x38, %edi
callq 0x3538
movq %rax, %r15
movl $0x20, %edi
callq 0x3538
movq %rax, %r12
movq %r13, %rdi
callq 0x2050
testq %rax, %rax
je 0x4902
movq 0x30(%rax), %rcx
movq %rcx, 0x30(%r15)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%r15)
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
leaq 0x1940(%rip), %rdx      # 0x6226
movl $0x20, %esi
movq %r12, %rdi
movq %r15, %rcx
callq 0x21c0
testq %rax, %rax
je 0x4902
movq 0x10(%r14), %rax
movq %r12, (%rax)
movq %r15, %rdi
callq 0x2040
jmp 0x463f
callq 0x2030
movq (%rax), %rax
movq (%r15), %rcx
movq 0x8(%r15), %rdx
movq (%rcx), %rcx
movslq 0x14(%r15), %rsi
leaq (%rsi,%rsi,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rsi, %rdi
movslq 0x4(%rdx,%rdi), %rdx
movsbq (%rcx,%rdx), %rcx
cmpl $0x54, (%rax,%rcx,4)
movl 0x28(%r14), %eax
jne 0x4971
movq 0x10(%r14), %rcx
orl %eax, (%rcx)
jmp 0x463f
movq %rbx, %rdi
callq 0x2210
movq 0x10(%r14), %rcx
movl %eax, (%rcx)
jmp 0x463f
xorl %r15d, %r15d
movq 0x10(%r14), %rax
movq %r15, (%rax)
jmp 0x463f
notl %eax
movq 0x10(%r14), %rcx
andl %eax, (%rcx)
jmp 0x463f