// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/multiboot.c
// Function: add_action
static int add_action(struct multiboot *mboot, int mode, const char *arg)
{
    struct mboot_action *action = malloc(sizeof(struct mboot_action));
    if (action == NULL)
    {
        perror("malloc()");
        return -1;
    }

    char *argcopy = strdup(arg);
    if (argcopy == NULL)
    {
        perror("strdup()");
        free(action);
        return -1;
    }

    char *tok = strtok(argcopy, ":");
    if (tok == NULL)
    {
        fprintf(stderr, "invalid argument: '%s'\n", arg);
        free(argcopy);
        free(action);
        return -1;
    }

    action->memtype = mboot->ops->get_memtype(mboot, tok);
    if (action->memtype == -1)
    {
        fprintf(stderr, "invalid memtype: '%s'\n", tok);
        free(argcopy);
        free(action);
        return -1;
    }

    tok = strtok(NULL, ":");
    if (tok == NULL)
    {
        fprintf(stderr, "invalid argument: '%s'\n", arg);
        free(argcopy);
        free(action);
        return -1;
    }

    action->filename = strdup(tok);
    if (action->filename == NULL)
    {
        perror("strdup()");
        free(argcopy);
        free(action);
        return -1;
    }

    action->mode = mode;

    list_add_tail(&action->list, &action_list);
    free(argcopy);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x20, %edi
callq 0x21b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9370
leaq 0x278b(%rip), %rdi      # 0xbaea
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x951e
movq -0x20(%rbp), %rdi
callq 0x2250
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x93a5
leaq 0x1da3(%rip), %rdi      # 0xb12e
callq 0x2210
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x951e
movq -0x30(%rbp), %rdi
leaq 0x31fd(%rip), %rsi      # 0xc5ad
callq 0x2220
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x93fa
movq 0x6c31(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x31da(%rip), %rsi      # 0xc5af
movb $0x0, %al
callq 0x2160
movq -0x30(%rbp), %rdi
callq 0x2030
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x951e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq *%rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
jne 0x945c
movq 0x6bcf(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x3190(%rip), %rsi      # 0xc5c7
movb $0x0, %al
callq 0x2160
movq -0x30(%rbp), %rdi
callq 0x2030
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x951e
xorl %eax, %eax
movl %eax, %edi
leaq 0x3146(%rip), %rsi      # 0xc5ad
callq 0x2220
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x94ae
movq 0x6b7a(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x3123(%rip), %rsi      # 0xc5af
movb $0x0, %al
callq 0x2160
movq -0x30(%rbp), %rdi
callq 0x2030
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x951e
movq -0x38(%rbp), %rdi
callq 0x2250
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x94f4
leaq 0x1c5a(%rip), %rdi      # 0xb12e
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2030
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x951e
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x28(%rbp), %rdi
leaq 0x70e7(%rip), %rsi      # 0x105f0
callq 0x9600
movq -0x30(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)