// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x10(%rsp)
andl $0x0, 0xc(%rsp)
testq %rsi, %rsi
jne 0x157a1
leaq 0xbaed(%rip), %rdi      # 0x21289
callq 0x60f0
leaq 0xc(%rsp), %rsi
movl %ebp, %edi
callq 0x14cb7
testl %eax, %eax
je 0x15811
movl 0xc(%rsp), %esi
cmpl $0xabcd000e, %esi       # imm = 0xABCD000E
jne 0x157e6
leaq 0x10(%rsp), %rsi
movl %ebp, %edi
callq 0x14cb7
testl %eax, %eax
je 0x15811
movslq 0x10(%rsp), %r14
cmpl %r15d, %r14d
jle 0x15831
leaq 0xb686(%rip), %rdi      # 0x20e64
movl %r14d, %esi
movl %r15d, %edx
jmp 0x157f2
leaq 0xb653(%rip), %rdi      # 0x20e40
movl $0xabcd000e, %edx       # imm = 0xABCD000E
xorl %eax, %eax
callq 0x61c0
leaq 0xbaa3(%rip), %rdi      # 0x212a3
xorl %eax, %eax
callq 0x61c0
movl $0x1, 0x1dc67(%rip)     # 0x33478
movl 0x1dc59(%rip), %ecx     # 0x33470
xorl %eax, %eax
orl 0x1dc59(%rip), %ecx     # 0x33478
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x10, %rbx
xorl %r12d, %r12d
leaq 0x14(%rsp), %r15
leaq 0x1440c(%rip), %r13     # 0x29c50
cmpq %r14, %r12
jge 0x15811
andl $0x0, 0x14(%rsp)
leaq -0x10(%rbx), %rsi
movl %ebp, %edi
callq 0x14cb7
movl %ebp, %edi
movq %r15, %rsi
callq 0x14cb7
movl %ebp, %edi
movq %rbx, %rsi
callq 0x14cb7
leaq 0x4(%rbx), %rsi
movl %ebp, %edi
callq 0x14cb7
movl 0x14(%rsp), %eax
decl %eax
cmpl $0x10, %eax
ja 0x1588c
movl %eax, %eax
movq (%r13,%rax,8), %rax
jmp 0x1588e
xorl %eax, %eax
movq %rax, -0x8(%rbx)
incq %r12
addq $0x18, %rbx
jmp 0x15844