// File: /workspace/github_c_makefile_star2_O2/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 0x5dac(%rip), %rsi      # 0x14097
callq 0x2240
testq %rax, %rax
je 0xe526
cmpq $0x0, 0x1178f(%rip)     # 0x1fa90
jne 0xe59f
cmpl $0x0, 0x1177a(%rip)     # 0x1fa88
jne 0xe59f
movq %rax, %rbx
callq 0xe781
movq %rax, %r14
movq %rax, 0x1176a(%rip)     # 0x1fa90
movq %rbx, %rdi
callq 0x2350
testl %eax, %eax
je 0xe33f
movq %rbx, %rdi
callq 0x21f0
jmp 0xe3ff
leaq 0x10(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2330
movq %rbx, %rdi
callq 0x2350
leaq 0x9355(%rip), %r15      # 0x176b6
testl %eax, %eax
jne 0xe563
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xe563
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2330
movq %rbx, %rdi
callq 0x2350
leaq 0x9346(%rip), %r15      # 0x176e1
testl %eax, %eax
jne 0xe563
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xe563
leaq 0x8(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2330
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xe55c
incq 0x8(%r14)
movq %rbx, %rdi
callq 0x2350
testl %eax, %eax
je 0xe40e
movq %rbx, %rdi
callq 0x21f0
callq 0xe812
leaq 0x9507(%rip), %rdi      # 0x17901
callq 0x2340
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x2110
movq %rax, (%r14)
testq %rax, %rax
je 0xe5be
movq %rax, %r15
pushq $0x8
popq %r12
pushq $0x1
popq %rbp
pushq $0x4
popq %r13
movq %rbx, %rdi
callq 0x2350
testl %eax, %eax
jne 0xe3e6
movq %r12, %rdi
callq 0x22c0
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0xe582
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%r15)
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x4(%rax)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x2330
movq %rbx, %rdi
callq 0x2350
testl %eax, %eax
jne 0xe3e6
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xe58b
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x2330
movq %rbx, %rdi
callq 0x2350
testl %eax, %eax
jne 0xe570
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xe570
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x2330
movq %rbx, %rdi
callq 0x2350
testl %eax, %eax
jne 0xe579
movq %rbx, %rdi
callq 0x2430
testl %eax, %eax
jne 0xe579
incq 0x8(%r14)
movq %rbp, %rdi
pushq $0x18
popq %rsi
callq 0x2110
movq %rax, (%r15)
movq %rax, %r15
testq %rax, %rax
jne 0xe433
leaq 0x9370(%rip), %rdi      # 0x17894
jmp 0xe592
callq 0xe781
movq %rax, 0x1155e(%rip)     # 0x1fa90
movq 0xea9f(%rip), %rax      # 0x1cfd8
movq (%rax), %rcx
leaq 0x910a(%rip), %rdi      # 0x1764d
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2480
leaq 0x91a9(%rip), %r15      # 0x1770c
movq %r15, %rdi
callq 0x2190
jmp 0xe332
leaq 0x929d(%rip), %rdi      # 0x17814
jmp 0xe592
leaq 0x92d4(%rip), %rdi      # 0x17854
jmp 0xe592
leaq 0x920b(%rip), %rdi      # 0x17794
jmp 0xe592
leaq 0x9250(%rip), %rdi      # 0x177e2
callq 0x2190
pushq $0x1
popq %rdi
callq 0x2270
leaq 0x90d1(%rip), %rdi      # 0x17677
leaq 0x8e63(%rip), %rsi      # 0x17410
leaq 0x90e3(%rip), %rcx      # 0x17697
movl $0x17f, %edx            # imm = 0x17F
callq 0x2100
leaq 0x9172(%rip), %rdi      # 0x17737
jmp 0xe592