// File: /workspace/github_c_makefile_star2_O3/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, %r15d
movq %rsi, %rbx
movl %edi, %ebp
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
testq %rsi, %rsi
jne 0x16791
leaq 0xcafd(%rip), %rdi      # 0x23289
callq 0x60f0
leaq 0xc(%rsp), %rsi
movl %ebp, %edi
callq 0x15bb9
testl %eax, %eax
je 0x16801
movl 0xc(%rsp), %esi
cmpl $0xabcd000e, %esi       # imm = 0xABCD000E
jne 0x167d6
leaq 0x10(%rsp), %rsi
movl %ebp, %edi
callq 0x15bb9
testl %eax, %eax
je 0x16801
movl 0x10(%rsp), %r14d
cmpl %r15d, %r14d
jle 0x16821
leaq 0xc696(%rip), %rdi      # 0x22e64
movl %r14d, %esi
movl %r15d, %edx
jmp 0x167e2
leaq 0xc663(%rip), %rdi      # 0x22e40
movl $0xabcd000e, %edx       # imm = 0xABCD000E
xorl %eax, %eax
callq 0x61c0
leaq 0xcab3(%rip), %rdi      # 0x232a3
xorl %eax, %eax
callq 0x61c0
movl $0x1, 0x1cc87(%rip)     # 0x33488
movl 0x1cc79(%rip), %ecx     # 0x33480
xorl %eax, %eax
orl 0x1cc79(%rip), %ecx     # 0x33488
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
jle 0x16801
addq $0x10, %rbx
xorl %r12d, %r12d
leaq 0x14(%rsp), %r15
leaq 0x13417(%rip), %r13     # 0x29c50
movl $0x0, 0x14(%rsp)
leaq -0x10(%rbx), %rsi
movl %ebp, %edi
callq 0x15bb9
movl %ebp, %edi
movq %r15, %rsi
callq 0x15bb9
movl %ebp, %edi
movq %rbx, %rsi
callq 0x15bb9
leaq 0x4(%rbx), %rsi
movl %ebp, %edi
callq 0x15bb9
movl 0x14(%rsp), %eax
decl %eax
cmpl $0x10, %eax
ja 0x1687f
movl %eax, %eax
movq (%r13,%rax,8), %rax
jmp 0x16881
xorl %eax, %eax
movq %rax, -0x8(%rbx)
incq %r12
addq $0x18, %rbx
cmpq %r14, %r12
jb 0x16839
jmp 0x16801