// File: /workspace/github_c_makefile_star2_O3/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 0x5b09(%rip), %rsi      # 0x150ef
callq 0x2230
testq %rax, %rax
je 0xf831
cmpq $0x0, 0x12494(%rip)     # 0x21a90
jne 0xf863
cmpl $0x0, 0x1247f(%rip)     # 0x21a88
jne 0xf863
movq %rax, %rbx
callq 0xfa2a
movq %rax, %r14
movq %rax, 0x1246f(%rip)     # 0x21a90
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
je 0xf63a
movq %rbx, %rdi
callq 0x21f0
jmp 0xf706
leaq 0x10(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
leaq 0x9086(%rip), %r15      # 0x186e6
testl %eax, %eax
jne 0xf842
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf842
leaq 0xc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
leaq 0x9073(%rip), %r15      # 0x18711
testl %eax, %eax
jne 0xf842
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf842
leaq 0x8(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf83b
incq 0x8(%r14)
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
je 0xf715
movq %rbx, %rdi
callq 0x21f0
callq 0xfab6
leaq 0x9230(%rip), %rdi      # 0x18931
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 0xf882
movq %rax, %r15
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf6ed
movl $0x8, %edi
callq 0x22b0
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0xf859
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 0xf6ed
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf85e
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf84f
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf84f
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %rbx, %rcx
callq 0x2320
movq %rbx, %rdi
callq 0x2340
testl %eax, %eax
jne 0xf854
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xf854
incq 0x8(%r14)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2110
movq %rax, (%r15)
movq %rax, %r15
testq %rax, %rax
jne 0xf742
callq 0x2f2b
callq 0x2f6a
jmp 0xf706
leaq 0x8efa(%rip), %r15      # 0x1873c
movq %r15, %rdi
callq 0x2190
jmp 0xf62d
callq 0x2f01
callq 0x2f16
callq 0x2f40
callq 0x2eec
leaq 0x8e3d(%rip), %rdi      # 0x186a7
leaq 0x8bcf(%rip), %rsi      # 0x18440
leaq 0x8e4f(%rip), %rcx      # 0x186c7
movl $0x17f, %edx            # imm = 0x17F
callq 0x2100
callq 0x2f55