// File: /workspace/github_c_makefile_star2_O1/Ziddykins[P]Dawn/src/status.c
// Function: load_events
void load_events(char const * fn) {
    FILE * file;
    size_t len = 0;
    if(!(file = fopen(fn, "rb"))) {
        select_list(init_event_list());
        fprintf(stderr, WARN "Could not load events\n");
    } else {
        assert(elist == 0 && !eventQ_singleton);
        select_list(init_event_list());
        struct event_list * celist = elist;

        time_t tmpT;
        enum Events tmpE;
        int tmpD;
        if(feof(file)) {
            fclose(file);
            return;
        }

        len += sizeof tmpT * fread(&tmpT, sizeof tmpT, 1, file);
        if(feof(file) || ferror(file)) {
            PRINTERR("fread")
            fclose(file);
            return;
        }

        len += sizeof tmpE * fread(&tmpE, sizeof tmpE, 1, file);
        if(feof(file) || ferror(file)) {
            PRINTERR("fread")
            fclose(file);
            return;
        }

        len += sizeof tmpD * fread(&tmpD, sizeof tmpD, 1, file);
        if(ferror(file)) {
            PRINTERR("fread")
            fclose(file);
            return;
        }
        celist->len++;

        if(!feof(file)) {
            struct event_node * tmp = 0;
            CALLEXIT(!(tmp = celist->head = calloc(1, sizeof *celist->head)))
            while(!feof(file)) {
                CALLEXIT(!(tmp->elem = malloc(sizeof *tmp->elem)))
                tmp->event_time = tmpT;
                tmp->elem->event = tmpE;
                tmp->elem->data = tmpD;

                len += sizeof tmpT * fread(&tmpT, sizeof tmpT, 1, file);
                if(feof(file)) {
                    break;
                }
                CALLEXIT(ferror(file))

                len += sizeof tmpE * fread(&tmpE, sizeof tmpE, 1, file);
                CALLEXIT(feof(file) || ferror(file))

                len += sizeof tmpD * fread(&tmpD, sizeof tmpD, 1, file);
                CALLEXIT(feof(file) || ferror(file))

                celist->len++;

                CALLEXIT(!(tmp->next = calloc(1, sizeof *tmp)))
                tmp = tmp->next;
            }
        }
        fclose(file);
        update_alarm();
        printf(INFO "Loaded events\n");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x5d89(%rip), %rsi      # 0x1509f
callq 0x2230
testq %rax, %rax
je 0xf561
cmpq $0x0, 0x12764(%rip)     # 0x21a90
jne 0xf593
cmpl $0x0, 0x1274f(%rip)     # 0x21a88
jne 0xf593
movq %rax, %rbx
callq 0xf774
movq %rax, %r14
movq %rax, 0x1273f(%rip)     # 0x21a90
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
je 0xf36a
movq %rbx, %rdi
callq 0x21f0
jmp 0xf436
leaq 0x10(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
leaq 0x92f6(%rip), %r15      # 0x18686
testl %eax, %eax
jne 0xf572
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf572
leaq 0xc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
leaq 0x92e3(%rip), %r15      # 0x186b1
testl %eax, %eax
jne 0xf572
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf572
leaq 0x8(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf56b
incq 0x8(%r14)
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
je 0xf445
movq %rbx, %rdi
callq 0x21f0
callq 0xf800
leaq 0x94a0(%rip), %rdi      # 0x188d1
callq 0x2330
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
movl $0x18, %esi
callq 0x2110
movq %rax, (%r14)
testq %rax, %rax
je 0xf5b2
movq %rax, %r15
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf41d
movl $0x8, %edi
callq 0x22b0
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0xf589
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%r15)
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x4(%rax)
movl $0x8, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf41d
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf58e
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf57f
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf57f
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf584
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf584
incq 0x8(%r14)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2110
movq %rax, (%r15)
movq %rax, %r15
testq %rax, %rax
jne 0xf472
callq 0x2f2b
callq 0x2f6a
jmp 0xf436
leaq 0x916a(%rip), %r15      # 0x186dc
movq %r15, %rdi
callq 0x2190
jmp 0xf35d
callq 0x2f01
callq 0x2f16
callq 0x2f40
callq 0x2eec
leaq 0x90ad(%rip), %rdi      # 0x18647
leaq 0x8e3f(%rip), %rsi      # 0x183e0
leaq 0x90bf(%rip), %rcx      # 0x18667
movl $0x17f, %edx            # imm = 0x17F
callq 0x2100
callq 0x2f55