// File: /workspace/github_c_makefile_star2_O2/Aethlas[P]fflz4/fflz4.c
// Function: print_tabs
void print_tabs(const cJSON *json, const unsigned int flag)
{
    const cJSON *active_title = NULL, *active_url = NULL;
    const cJSON *child = NULL;
    long lastAccessed = 0;

    cJSON_ArrayForEach(child, json) {
        const cJSON *tabs = cJSON_GetObjectItemCaseSensitive(child, "tabs");
        if (!cJSON_IsArray(tabs)) break;

        const cJSON *tab = NULL;
        cJSON_ArrayForEach(tab, tabs) {
            const cJSON *accessed = cJSON_GetObjectItemCaseSensitive(tab, "lastAccessed");
            const cJSON *index = cJSON_GetObjectItemCaseSensitive(tab, "index");
            const cJSON *entries = cJSON_GetObjectItemCaseSensitive(tab, "entries");
            if (!cJSON_IsArray(entries) || cJSON_IsNull(index)) break;

            const cJSON *entry = cJSON_GetArrayItem(entries, index->valueint-1);
            if (!cJSON_IsObject(entry)) break;

            const cJSON *title = cJSON_GetObjectItemCaseSensitive(entry, "title");
            const cJSON *url = cJSON_GetObjectItemCaseSensitive(entry, "url");

            if (!cJSON_IsNull(accessed)) {
                char *ac = cJSON_Print(accessed);
                long tmp = strtol(ac, NULL, 10);
                if (lastAccessed < tmp) {
                    lastAccessed = tmp;
                    active_title = cJSON_GetObjectItemCaseSensitive(entry, "title");
                    active_url = cJSON_GetObjectItemCaseSensitive(entry, "url");
                }
                free(ac);
            }

            if ((flag & (FLAG_T | FLAG_U)) == (FLAG_T | FLAG_U)) {
                if (cJSON_IsString(title) && cJSON_IsString(url))
                    fprintf(stdout, "%s\n%s\n\n", title->valuestring, url->valuestring);
            } else {
                if ((flag & FLAG_T) && !(flag & FLAG_C) && cJSON_IsString(title))
                    fprintf(stdout, "%s\n", title->valuestring);

                if ((flag & FLAG_U) && !(flag & FLAG_C) && cJSON_IsString(url))
                    fprintf(stdout, "%s\n", url->valuestring);
            }
        }
    }

    if (!cJSON_IsString(active_title) && !cJSON_IsString(active_url))
        return;

    if ((flag & (FLAG_C | FLAG_T)) == (FLAG_C | FLAG_T))
        fprintf(stdout, "%s\n", active_title->valuestring);
    else if ((flag & (FLAG_C | FLAG_U)) == (FLAG_C | FLAG_U))
        fprintf(stdout, "%s\n", active_url->valuestring);
    else if (flag & FLAG_C)
        fprintf(stdout, "%s\n%s\n", active_title->valuestring, active_url->valuestring);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %r13d
testq %rdi, %rdi
je 0x1be0
movq 0x10(%rdi), %r14
jmp 0x1be3
xorl %r14d, %r14d
movl %r13d, %eax
andl $0x6, %eax
movl %eax, 0x1c(%rsp)
movl %r13d, %eax
andl $0xc, %eax
movl %eax, 0xc(%rsp)
movl %r13d, %eax
andl $0xa, %eax
movl %eax, 0x8(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x28(%rsp)
testq %r14, %r14
je 0x1e21
movq %r14, %rdi
leaq 0xd54a(%rip), %rsi      # 0xf179
callq 0xda12
movq %rax, %rbx
movq %rax, %rdi
callq 0xe6f9
testl %eax, %eax
je 0x1e21
testq %rbx, %rbx
je 0x1c55
addq $0x10, %rbx
movq (%rbx), %rbx
jmp 0x1c57
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x1caa
movq %rbx, %rdi
leaq 0xd518(%rip), %rsi      # 0xf17e
callq 0xda12
movq %rax, %r15
movq %rbx, %rdi
leaq 0xd513(%rip), %rsi      # 0xf18b
callq 0xda12
movq %rax, %r12
movq %rbx, %rdi
leaq 0xd507(%rip), %rsi      # 0xf191
callq 0xda12
movq %rax, %rbp
movq %rax, %rdi
callq 0xe6f9
testl %eax, %eax
je 0x1caa
movq %r12, %rdi
callq 0xe6db
testl %eax, %eax
je 0x1cb2
movq (%r14), %r14
jmp 0x1c1c
movl 0x28(%r12), %esi
decl %esi
movq %rbp, %rdi
callq 0xd945
movq %rax, %rbp
movq %rax, %rdi
callq 0xe708
testl %eax, %eax
je 0x1caa
movq %rbp, %rdi
leaq 0xd4bf(%rip), %rsi      # 0xf199
callq 0xda12
movq %rax, 0x30(%rsp)
movq %rbp, %rdi
leaq 0xd4b1(%rip), %rsi      # 0xf19f
callq 0xda12
movq %rax, %r12
movq %r15, %rdi
callq 0xe6db
testl %eax, %eax
jne 0x1d63
movl %r13d, 0x18(%rsp)
movq %r15, %rdi
callq 0xd2f9
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x1130
cmpq %rax, 0x20(%rsp)
jge 0x1d56
movq %rax, %r13
movq %rbp, %rdi
leaq 0xd466(%rip), %rsi      # 0xf199
callq 0xda12
movq %rax, 0x28(%rsp)
movq %rbp, %rdi
leaq 0xd458(%rip), %rsi      # 0xf19f
callq 0xda12
movq %rax, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movq %r15, %rdi
callq 0x1230
movl 0x18(%rsp), %r13d
cmpl $0x6, 0x1c(%rsp)
movq 0x30(%rsp), %r15
jne 0x1db5
movq %r15, %rdi
callq 0xcb8e
testl %eax, %eax
je 0x1c50
movq %r12, %rdi
callq 0xcb8e
testl %eax, %eax
je 0x1c50
movq 0x11222(%rip), %rax     # 0x12fb8
movq (%rax), %rdi
movq 0x20(%r15), %rdx
movq 0x20(%r12), %rcx
leaq 0xd3fa(%rip), %rsi      # 0xf1a3
xorl %eax, %eax
callq 0x1100
jmp 0x1c50
cmpl $0x4, 0xc(%rsp)
jne 0x1de4
movq %r15, %rdi
callq 0xcb8e
testl %eax, %eax
je 0x1de4
movq 0x111e9(%rip), %rax     # 0x12fb8
movq (%rax), %rdi
movq 0x20(%r15), %rdx
leaq 0xd3d1(%rip), %rsi      # 0xf1ae
xorl %eax, %eax
callq 0x1100
cmpl $0x2, 0x8(%rsp)
jne 0x1c50
movq %r12, %rdi
callq 0xcb8e
testl %eax, %eax
je 0x1c50
movq 0x111b2(%rip), %rax     # 0x12fb8
movq (%rax), %rdi
movq 0x20(%r12), %rdx
leaq 0xd399(%rip), %rsi      # 0xf1ae
xorl %eax, %eax
callq 0x1100
jmp 0x1c50
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0xcb8e
testl %eax, %eax
jne 0x1e40
movq 0x10(%rsp), %rdi
callq 0xcb8e
testl %eax, %eax
je 0x1e93
cmpl $0xc, 0xc(%rsp)
jne 0x1e57
movq 0x1116a(%rip), %rax     # 0x12fb8
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
jmp 0x1e71
cmpl $0xa, 0x8(%rsp)
jne 0x1e8d
movq 0x11153(%rip), %rax     # 0x12fb8
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdx
leaq 0xd336(%rip), %rsi      # 0xf1ae
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100
testb $0x8, %r13b
jne 0x1ea2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1110f(%rip), %rax     # 0x12fb8
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rcx
leaq 0xd2eb(%rip), %rsi      # 0xf1ab
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100