// File: /workspace/github_c_makefile_star2_O0/bobrippling[P]tim/external.c
// Function: shellout_write
bool shellout_write(const char *cmd, list_t *seeked, int nlines)
{
	ui_term();

	FILE *subp = popen(cmd, "w");

	if(!subp){
		fprintf(stderr, "fork/exec: %s", strerror(errno));
		return false;
	}

	int r = list_write_file(seeked, nlines, subp, /*eol*/true);
	int errno_write = errno;

	int waitret = pclose(subp);
	int errno_wait = errno;

	if(r){
		fprintf(stderr, "write subprocess: %s", strerror(errno_write));
		return false;
	}

	if(WIFEXITED(waitret)){
		int ec = WEXITSTATUS(waitret);

		if(ec)
			fprintf(stderr, "command returned %d\n", ec);

	}else if(WIFSIGNALED(waitret)){
		fprintf(stderr, "command signalled with %d\n", WTERMSIG(waitret));
	}else if(WIFSTOPPED(waitret)){
		fprintf(stderr, "command stopped with %d\n", WSTOPSIG(waitret));
	}else{
		fprintf(stderr, "unknown state from wait()/pclose(): %d: %s",
				waitret, strerror(errno_wait));
	}

	shellout_wait_ret();

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
callq 0x5890
movq -0x10(%rbp), %rdi
leaq 0x547b(%rip), %rsi      # 0x15a7e
callq 0x4430
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1064b
movq 0xb9d6(%rip), %rax      # 0x1bff0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x40a0
movl (%rax), %edi
callq 0x44d0
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x51c6(%rip), %rsi      # 0x15801
movb $0x0, %al
callq 0x4310
movb $0x0, -0x1(%rbp)
jmp 0x107a3
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movl $0x1, %ecx
callq 0xcb60
movl %eax, -0x2c(%rbp)
callq 0x40a0
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x41d0
movl %eax, -0x34(%rbp)
callq 0x40a0
movl (%rax), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x106bd
movq 0xb960(%rip), %rax      # 0x1bff0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x30(%rbp), %edi
callq 0x44d0
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x5162(%rip), %rsi      # 0x1580f
movb $0x0, %al
callq 0x4310
movb $0x0, -0x1(%rbp)
jmp 0x107a3
movl -0x34(%rbp), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
jne 0x106fc
movl -0x34(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x106f7
movq 0xb90d(%rip), %rax      # 0x1bff0
movq (%rax), %rdi
movl -0x3c(%rbp), %edx
leaq 0x5134(%rip), %rsi      # 0x15824
movb $0x0, %al
callq 0x4310
jmp 0x1079a
movl -0x34(%rbp), %eax
andl $0x7f, %eax
addl $0x1, %eax
movsbl %al, %eax
sarl %eax
cmpl $0x0, %eax
jle 0x1072f
movq 0xb8da(%rip), %rax      # 0x1bff0
movq (%rax), %rdi
movl -0x34(%rbp), %edx
andl $0x7f, %edx
leaq 0x5113(%rip), %rsi      # 0x15839
movb $0x0, %al
callq 0x4310
jmp 0x10798
movl -0x34(%rbp), %eax
andl $0xff, %eax
cmpl $0x7f, %eax
jne 0x10762
movq 0xb8ad(%rip), %rax      # 0x1bff0
movq (%rax), %rdi
movl -0x34(%rbp), %edx
andl $0xff00, %edx           # imm = 0xFF00
sarl $0x8, %edx
leaq 0x50fb(%rip), %rsi      # 0x15854
movb $0x0, %al
callq 0x4310
jmp 0x10796
movq 0xb887(%rip), %rax      # 0x1bff0
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x38(%rbp), %edi
callq 0x44d0
movq -0x60(%rbp), %rdi
movl -0x54(%rbp), %edx
movq %rax, %rcx
leaq 0x50de(%rip), %rsi      # 0x1586d
movb $0x0, %al
callq 0x4310
jmp 0x10798
jmp 0x1079a
callq 0x10530
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nop