// File: /workspace/github_c_makefile_star2_O1/albinoloverats[P]hide/common/src/error.c
// Function: on_error
extern void on_error(int s)
{
	if (fatal_error_in_progress)
		raise(s);
	fatal_error_in_progress = 1;

	write(STDERR_FILENO, ERROR_CURSOR, ERROR_CURSOR_LEN);
	write(STDERR_FILENO, ERROR_DIVIDE, ERROR_DIVIDE_LEN);

	char m[32] = { 0x0 };
	strcat(m, "Received fatal signal [");
	strcat(m, int_to_ascii(s));
	strcat(m, "]");
	psignal(s, m);

#ifdef BUILD_GUI
	error_gui_alert(m);
#endif

#if !defined _WIN32 && !defined __CYGWIN__ && !defined __FreeBSD__
	void *bt[BACKTRACE_BUFFER_LIMIT];
	int c = backtrace(bt, BACKTRACE_BUFFER_LIMIT);
	char **sym = backtrace_symbols(bt, c);
	if (sym)
		for (int i = 0; i < c; i++)
		{
			write(STDERR_FILENO, sym[i], strlen(sym[i]));
			write(STDERR_FILENO, "\n", 1);
		}
#endif

	write(STDERR_FILENO, ERROR_DIVIDE, ERROR_DIVIDE_LEN);

#ifndef __APPLE__
	signal(s, SIG_DFL);
	raise(s);
	__builtin_unreachable();
#else
	exit(errno);
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
movl %edi, %ebx
cmpl $0x0, 0x4c16(%rip)      # 0x8230
je 0x3623
movl %ebx, %edi
callq 0x2040
movl $0x1, 0x4c03(%rip)      # 0x8230
leaq 0x1c3c(%rip), %rsi      # 0x5270
movl $0x7, %edx
movl $0x2, %edi
callq 0x20e0
leaq 0x1c2e(%rip), %rsi      # 0x5278
movl $0x2e, %edx
movl $0x2, %edi
callq 0x20e0
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x2100
movabsq $0x5b206c616e6769, %rcx # imm = 0x5B206C616E6769
movq %rcx, 0x10(%rsp,%rax)
movups 0x1c26(%rip), %xmm0     # 0x52a7
movups %xmm0, (%rsp,%rax)
testl %ebx, %ebx
js 0x36c1
leaq 0x4bc4(%rip), %rsi      # 0x8254
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
movl %ebx, %ecx
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x23, %rdx
leal (%rdx,%rdx), %edi
leal (%rdi,%rdi,4), %edi
movl %ecx, %r8d
subl %edi, %r8d
orb $0x30, %r8b
movb %r8b, -0x1(%rsi)
decq %rsi
cmpl $0xa, %ecx
movl %edx, %ecx
jae 0x3697
jmp 0x3700
leaq 0x4b8b(%rip), %rsi      # 0x8253
movl %ebx, %eax
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rax # imm = 0x66666667
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rax
addl %edx, %eax
leal (%rax,%rax), %edx
leal (%rdx,%rdx,4), %edx
movl %ecx, %edi
subl %edx, %edi
movb $0x30, %dl
subb %dil, %dl
movb %dl, (%rsi)
addl $0x9, %ecx
decq %rsi
cmpl $0x12, %ecx
ja 0x36ca
movb $0x2d, (%rsi)
movq %rsp, %r14
movq %r14, %rdi
callq 0x2330
movq %r14, %rdi
callq 0x2100
movw $0x5d, (%rsp,%rax)
movl %ebx, %edi
movq %r14, %rsi
callq 0x23a0
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x2110
movl %eax, %ebp
movq %r14, %rdi
movl %eax, %esi
callq 0x20d0
testq %rax, %rax
je 0x378f
testl %ebp, %ebp
jle 0x378f
movq %rax, %r14
movl %ebp, %r13d
xorl %ebp, %ebp
leaq 0x1b4c(%rip), %r15      # 0x52a5
movq (%r14,%rbp,8), %r12
movq %r12, %rdi
callq 0x2100
movl $0x2, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x20e0
movl $0x1, %edx
movl $0x2, %edi
movq %r15, %rsi
callq 0x20e0
incq %rbp
cmpq %rbp, %r13
jne 0x3759
leaq 0x1ae2(%rip), %rsi      # 0x5278
movl $0x2e, %edx
movl $0x2, %edi
callq 0x20e0
movl %ebx, %edi
xorl %esi, %esi
callq 0x2200
movl %ebx, %edi
callq 0x2040