// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linit-sup-stop.c
// Function: main
int main(int argc, char **argv) {
    if(argc != 3) {
        perror("Missing args\n");
        return 1;
    }
    //connect
    int fd = socket(AF_UNIX, SOCK_STREAM, 0);
    if(fd == -1) {
        fprintf(stderr, "Failed to create socket: %s\n", strerror(errno));
        return 65;
    }
    struct sockaddr_un addr = { .sun_family = AF_UNIX };
    strcpy(addr.sun_path, "/tmp/linit-supd.sock");
    if(connect(fd, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)) == -1) {
        fprintf(stderr, "Failed to connect: %s\n", strerror(errno));
        return 65;
    }
    FILE *supconn = fdopen(fd, "r+");
    if(supconn == NULL) {
        fprintf(stderr, "Failed to convert fd to stream: %s\n", strerror(errno));
        return 65;
    }
    //write command
    if(fprintf(supconn, "^%d%s\n", atoi(argv[1]), argv[2]) == -1) {
        fprintf(stderr, "Failed to write to linit-supd connection: %s\n", strerror(errno));
        return 65;
    }
    if(fflush(supconn) != 0) {
        fprintf(stderr, "Failed to flush linit-supd connection: %s\n", strerror(errno));
        return 65;
    }
    //get response
    char resp[80];
    if(fgets(resp, 80, supconn) == NULL) {
        fprintf(stderr, "Failed to get response from linit-supd connection: %s\n", strerror(errno));
        return 65;
    }
    fclose(supconn);
    if(!streq(resp, "ok\n")) {
        return 65;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xc0, %rsp
cmpl $0x3, %edi
jne 0x12e2
movq %rsi, %rbx
pushq $0x1
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x10d0
cmpl $-0x1, %eax
je 0x12f5
movl %eax, %ebp
xorps %xmm0, %xmm0
leaq 0x52(%rsp), %rsi
movups %xmm0, 0x16(%rsi)
movups %xmm0, 0x56(%rsi)
movups %xmm0, 0x46(%rsi)
movups %xmm0, 0x36(%rsi)
movups %xmm0, 0x26(%rsi)
andq $0x0, 0x66(%rsi)
movw $0x1, (%rsi)
movups 0xdf8(%rip), %xmm0      # 0x202f
movups %xmm0, 0x2(%rsi)
movabsq $0x6b636f732e6470, %rax # imm = 0x6B636F732E6470
movq %rax, 0xf(%rsi)
pushq $0x6e
popq %rdx
movl %ebp, %edi
callq 0x10b0
cmpl $-0x1, %eax
je 0x1317
leaq 0xdf8(%rip), %rsi       # 0x205b
movl %ebp, %edi
callq 0x1080
testq %rax, %rax
je 0x1336
movq %rax, %r14
movq 0x8(%rbx), %rdi
callq 0x10a0
movq 0x10(%rbx), %rcx
leaq 0xdf8(%rip), %rsi       # 0x2082
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x1060
cmpl $-0x1, %eax
je 0x1355
movq %r14, %rdi
callq 0x1070
testl %eax, %eax
jne 0x1374
movq %rsp, %rdi
pushq $0x50
popq %rsi
movq %r14, %rdx
callq 0x1050
testq %rax, %rax
je 0x1393
movq %r14, %rdi
callq 0x1040
xorl %ecx, %ecx
cmpl $0xa6b6f, (%rsp)        # imm = 0xA6B6F
pushq $0x41
popq %rax
cmovel %ecx, %eax
jmp 0x13c0
leaq 0xd1b(%rip), %rdi       # 0x2004
callq 0x1090
pushq $0x1
jmp 0x13bf
movq 0x2cfc(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xd00(%rip), %rsi       # 0x2012
jmp 0x13b0
movq 0x2cda(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xd10(%rip), %rsi       # 0x2044
jmp 0x13b0
movq 0x2cbb(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xd0b(%rip), %rsi       # 0x205e
jmp 0x13b0
movq 0x2c9c(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xd17(%rip), %rsi       # 0x2089
jmp 0x13b0
movq 0x2c7d(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xd26(%rip), %rsi       # 0x20b7
jmp 0x13b0
movq 0x2c5e(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xd32(%rip), %rsi       # 0x20e2
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1060
pushq $0x41
popq %rax
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %rbp
retq