// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: run_patches
int run_patches(){
    struct patch_attr attr;
    struct ppl_list_node * cur;
    unsigned int queue_type;
    int found_queue = 0;
    int cur_run;
    unsigned int value_size;
    void* value;
    int ret;
    struct executor_queue* eq;
    if(!total_ppl){
        return -1;
    }
    read(0, &attr, sizeof(struct patch_attr));
    if(attr.queue_type > BRAINFUCK_EXECUTOR){
        return -1; 
    }
    queue_type = attr.queue_type;
    // iterate over the linked list
    cur = &head;
    for(cur=cur->fd; cur!=&head; cur=cur->fd)
    {
        eq = (struct executor_queue *)((unsigned long)cur - (unsigned long)&((struct executor_queue*)0)->list);
#ifdef DEBUG
        printf("%p\n", eq);
#endif
        if(eq->queue_type == queue_type && attr.number_of_patch <= eq->head - eq->tail){
            found_queue=1;
            break;
        }
    }
    if(!found_queue){
        puts("not found");
        return -1; 
    }
    value_size = eq->value_size;
    value = malloc(eq->value_size);
    memset(value, 0, value_size);
    for(cur_run=0; cur_run<attr.number_of_patch; cur_run++){
        // get_the element 
        eq->ops->get_elem(eq, value);
        ret=eq->ops->check_patch(eq, value);
        if(ret < 0){
            printf("%s... is not a valid patch\n", (char*)value);
            return 0;
        }
        eq->ops->run_patch(eq, value);
    }
    free(value);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x30(%rbp)
cmpl $0x0, 0x7a0a(%rip)      # 0xa210
jne 0x2814
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2980
xorl %edi, %edi
leaq -0x1c(%rbp), %rsi
movl $0x18, %edx
callq 0x1120
cmpl $0x2, -0x1c(%rbp)
jbe 0x2836
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2980
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq 0x7a85(%rip), %rax      # 0xa2c8
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
leaq 0x7a6f(%rip), %rax      # 0xa2c8
cmpq %rax, -0x28(%rbp)
je 0x28a9
movq -0x28(%rbp), %rax
xorl %ecx, %ecx
addq $0x28, %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x2c(%rbp), %eax
jne 0x289a
movl -0xc(%rbp), %eax
movq -0x50(%rbp), %rcx
movl 0x18(%rcx), %ecx
movq -0x50(%rbp), %rdx
subl 0x1c(%rdx), %ecx
cmpl %ecx, %eax
ja 0x289a
movl $0x1, -0x30(%rbp)
jmp 0x28a9
jmp 0x289c
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2852
cmpl $0x0, -0x30(%rbp)
jne 0x28c7
leaq 0x4100(%rip), %rdi      # 0x69b6
callq 0x1070
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2980
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, %edi
callq 0x1170
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl -0x38(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x1100
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x2970
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq *%rax
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq *%rax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x2950
movq -0x40(%rbp), %rsi
leaq 0x4080(%rip), %rdi      # 0x69c0
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x4(%rbp)
jmp 0x2980
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq *%rax
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x28fa
movq -0x40(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)