// File: /workspace/github_c_makefile_star2_O0/panux[P]linit/src/linitctl.c
// Function: cmd_stop
void cmd_stop(int argc, char **argv, FILE *stream) {
    if(argc != 1) {
        fprintf(stderr, "[FATAL] Missing arguments\n");
        exit(1);
    }
    char pre[] = "stop ";
    size_t n = strlen(pre) + strlen(argv[0]) + 1;
    char buf[n];
    char *b = buf;
    strcpy(b, pre);
    b += strlen(pre);
    strcpy(b, argv[0]);
    if(fwrite(buf, n, 1, stream) != 1) {
        fprintf(stderr, "[FATAL] Failed to write command\n");
        exit(65);
    }
    //wait for completion
    while(true) {
        char *resp = rcvResp(stream);
        char *stat = NULL;
        int nspace = 0;
        for(size_t i = 0; (resp[i] != '\0') && (nspace < 2); i++) {
            if(resp[i] == ' ') {
                stat = resp + i;
                nspace++;
            }
        }
        stat++;
        if(nspace < 2) {
            fprintf(stderr, "[FATAL] Bad response: \"%s\"\n", resp);
            exit(65);
        }
        if(strcmp(stat, "stopped") == 0) {
            free(resp);
            return;
        }
        free(resp);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x1, -0x4(%rbp)
je 0x18fe
movq 0x2715(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x7ed(%rip), %rsi       # 0x20da
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x10e0
movw $0x20, -0x1c(%rbp)
movl $0x706f7473, -0x20(%rbp) # imm = 0x706F7473
leaq -0x20(%rbp), %rdi
callq 0x1080
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1080
movq %rax, %rcx
movq -0x70(%rbp), %rax
leaq 0x1(%rax,%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq %rsp, %rax
movq %rax, -0x30(%rbp)
movq %rcx, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, -0x68(%rbp)
movq %rax, %rsp
movq %rcx, -0x38(%rbp)
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1060
leaq -0x20(%rbp), %rdi
callq 0x1080
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x1060
movq -0x68(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rcx
movl $0x1, %edx
callq 0x1100
cmpq $0x1, %rax
je 0x19cb
movq 0x2648(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x741(%rip), %rsi       # 0x20fb
movb $0x0, %al
callq 0x10b0
movl $0x41, %edi
callq 0x10e0
jmp 0x19cd
jmp 0x19cf
movq -0x18(%rbp), %rdi
callq 0x13f0
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq -0x60(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x71(%rbp)
je 0x1a13
cmpl $0x2, -0x54(%rbp)
setl %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x1a1c
jmp 0x1a52
movq -0x48(%rbp), %rax
movq -0x60(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x1a42
movq -0x48(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x1a44
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x19f3
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpl $0x2, -0x54(%rbp)
jge 0x1a8a
movq 0x258d(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
leaq 0x6c7(%rip), %rsi       # 0x2140
movb $0x0, %al
callq 0x10b0
movl $0x41, %edi
callq 0x10e0
movq -0x50(%rbp), %rdi
leaq 0x6dc(%rip), %rsi       # 0x2171
callq 0x10a0
cmpl $0x0, %eax
jne 0x1ab4
movq -0x48(%rbp), %rdi
callq 0x1040
movq -0x30(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x1040
jmp 0x19cd
nopw %cs:(%rax,%rax)