// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x72b8(%rip), %rsi      # 0x1e147
callq 0x2230
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x16ec8
callq 0x17550
movq %rax, %rdi
callq 0x176d0
movq 0xf12e(%rip), %rax      # 0x25fe0
movq (%rax), %rdi
leaq 0xa79c(%rip), %rsi      # 0x21658
movb $0x0, %al
callq 0x2310
jmp 0x17272
cmpq $0x0, 0x11bb0(%rip)     # 0x28a80
jne 0x16edd
cmpl $0x0, 0x11b9f(%rip)     # 0x28a78
jne 0x16edd
jmp 0x16efc
leaq 0xa79e(%rip), %rdi      # 0x21682
leaq 0xa530(%rip), %rsi      # 0x2141b
movl $0x17f, %edx            # imm = 0x17F
leaq 0xa7ab(%rip), %rcx      # 0x216a2
callq 0x2100
callq 0x17550
movq %rax, %rdi
callq 0x176d0
movq 0x11b70(%rip), %rax     # 0x28a80
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
je 0x16f30
movq -0x10(%rbp), %rdi
callq 0x21f0
jmp 0x17272
movq -0x10(%rbp), %rcx
leaq -0x28(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2320
shlq $0x3, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
jne 0x16f6f
movq -0x10(%rbp), %rdi
callq 0x2420
cmpl $0x0, %eax
je 0x16f89
leaq 0xa74b(%rip), %rdi      # 0x216c1
callq 0x2190
movq -0x10(%rbp), %rdi
callq 0x21f0
jmp 0x17272
movq -0x10(%rbp), %rcx
leaq -0x2c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2320
shlq $0x2, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
jne 0x16fc8
movq -0x10(%rbp), %rdi
callq 0x2420
cmpl $0x0, %eax
je 0x16fe2
leaq 0xa71d(%rip), %rdi      # 0x216ec
callq 0x2190
movq -0x10(%rbp), %rdi
callq 0x21f0
jmp 0x17272
movq -0x10(%rbp), %rcx
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2320
shlq $0x2, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2420
cmpl $0x0, %eax
je 0x1702d
leaq 0xa6fd(%rip), %rdi      # 0x21717
callq 0x2190
movq -0x10(%rbp), %rdi
callq 0x21f0
jmp 0x17272
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
jne 0x17256
movq $0x0, -0x38(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2110
movq -0x20(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x1708d
leaq 0xa6c4(%rip), %rdi      # 0x21742
callq 0x2190
movl $0x1, %edi
callq 0x2260
jmp 0x1708f
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x170a9
jmp 0x17254
movl $0x8, %edi
callq 0x22b0
movq -0x38(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x170d7
leaq 0xa6d7(%rip), %rdi      # 0x2179f
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x2c(%rbp), %ecx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl %ecx, (%rax)
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rcx
leaq -0x28(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2320
shlq $0x3, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
je 0x17134
jmp 0x17254
movq -0x10(%rbp), %rdi
callq 0x2420
cmpl $0x0, %eax
je 0x17158
leaq 0xa6a4(%rip), %rdi      # 0x217ed
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x10(%rbp), %rcx
leaq -0x2c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2320
shlq $0x2, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
jne 0x17197
movq -0x10(%rbp), %rdi
callq 0x2420
cmpl $0x0, %eax
je 0x171ad
leaq 0xa681(%rip), %rdi      # 0x2181f
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x10(%rbp), %rcx
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2320
shlq $0x2, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2340
cmpl $0x0, %eax
jne 0x171ec
movq -0x10(%rbp), %rdi
callq 0x2420
cmpl $0x0, %eax
je 0x17202
leaq 0xa66c(%rip), %rdi      # 0x2185f
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2110
movq -0x38(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x17244
leaq 0xa66a(%rip), %rdi      # 0x2189f
callq 0x2190
movl $0x1, %edi
callq 0x2260
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x1708f
jmp 0x17256
movq -0x10(%rbp), %rdi
callq 0x21f0
callq 0x17650
leaq 0xa67f(%rip), %rdi      # 0x218ea
movb $0x0, %al
callq 0x2040
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)