// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/state.c
// Function: rs_read_daemons
int rs_read_daemons(int inf, struct delayed_action *d_list, int count)
{
    int i = 0;
    int func = 0;
    int value = 0;
    int id = 0;
    
    if (d_list == NULL)
        printf("HELP THERE ARE NO DAEMONS\n");
    
    if (rs_read_int(inf, &id) != 0)
    {
        if (id != RSID_DAEMONS)
        {
            printf("Invalid id. %x != %x(RSID_DAEMONS)\n", id, RSID_DAEMONS);
            printf("Sorry, invalid save game format");
            format_error = TRUE;
        }
        else if (rs_read_int(inf, &value) != 0)
        {
            if (value > count)
            {
                printf("Incorrect number of daemons in block. %d > %d.",
                    value, count);
                printf("Sorry, invalid save game format");
                format_error = TRUE;
            }
            else
            {
                for(i=0; i < value; i++)
                {
                    func = 0;
                    rs_read_int(inf, &d_list[i].d_type);
                    rs_read_int(inf, &func);
                    rs_read_int(inf, &d_list[i].d_arg);
                    rs_read_int(inf, &d_list[i].d_time);
                    
                    switch(func)
                    {
                        case 1: d_list[i].d_func = rollwand;
                                break;
                        case 2: d_list[i].d_func = doctor;
                                break;
                        case 3: d_list[i].d_func = stomach;
                                break;
                        case 4: d_list[i].d_func = runners;
                                break;
                        case 5: d_list[i].d_func = swander;
                                break;
                        case 6: d_list[i].d_func = nohaste;
                                break;
                        case 7: d_list[i].d_func = unconfuse;
                                break;
                        case 8: d_list[i].d_func = unsee;
                                break;
                        case 9: d_list[i].d_func = sight;
                                break;
                        case 10: d_list[i].d_func = noteth;
                                break;
                        case 11: d_list[i].d_func = sapem;
                                break;
                        case 12: d_list[i].d_func = notslow;
                                break;
                        case 13: d_list[i].d_func = notregen;
                                break;
                        case 14: d_list[i].d_func = notinvinc;
                                break;
                        case 15: d_list[i].d_func = rchg_str;
                                break;
                        case 16: d_list[i].d_func = wghtchk;
                                break;
                        case 17: d_list[i].d_func = status;
                                break;
                        default: d_list[i].d_func = NULL;
                                break;
                    }   
                }
            }
        }
    }
    
    return(READSTAT);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r14d
movq %rsi, %rbx
movl %edi, %ebp
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x14(%rsp)
testq %rsi, %rsi
jne 0x1695c
leaq 0xc8ba(%rip), %rdi      # 0x23211
callq 0x60f0
leaq 0x14(%rsp), %rsi
movl %ebp, %edi
callq 0x15d65
testl %eax, %eax
je 0x169c8
movl 0x14(%rsp), %esi
cmpl $0xabcd000e, %esi       # imm = 0xABCD000E
jne 0x1699d
leaq 0xc(%rsp), %rsi
movl %ebp, %edi
callq 0x15d65
testl %eax, %eax
je 0x169c8
movl 0xc(%rsp), %esi
cmpl %r14d, %esi
jle 0x169e8
leaq 0xc454(%rip), %rdi      # 0x22dec
movl %r14d, %edx
jmp 0x169a9
leaq 0xc424(%rip), %rdi      # 0x22dc8
movl $0xabcd000e, %edx       # imm = 0xABCD000E
xorl %eax, %eax
callq 0x61c0
leaq 0xc874(%rip), %rdi      # 0x2322b
xorl %eax, %eax
callq 0x61c0
movl $0x1, 0x1cac0(%rip)     # 0x33488
movl 0x1cab2(%rip), %ecx     # 0x33480
xorl %eax, %eax
orl 0x1cab2(%rip), %ecx     # 0x33488
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0xc(%rsp)
jle 0x169c8
movslq 0xc(%rsp), %r15
addq $0x10, %rbx
xorl %r12d, %r12d
leaq 0x10(%rsp), %r14
leaq 0x13249(%rip), %r13     # 0x29c50
movl $0x0, 0x10(%rsp)
leaq -0x10(%rbx), %rsi
movl %ebp, %edi
callq 0x15d65
movl %ebp, %edi
movq %r14, %rsi
callq 0x15d65
movl %ebp, %edi
movq %rbx, %rsi
callq 0x15d65
leaq 0x4(%rbx), %rsi
movl %ebp, %edi
callq 0x15d65
movl 0x10(%rsp), %eax
decl %eax
cmpl $0x10, %eax
ja 0x16a4d
movl %eax, %eax
movq (%r13,%rax,8), %rax
jmp 0x16a4f
xorl %eax, %eax
movq %rax, -0x8(%rbx)
incq %r12
addq $0x18, %rbx
cmpq %r15, %r12
jl 0x16a07
jmp 0x169c8