// File: /workspace/github_c_makefile_star2_O3/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)      # 0x8220
je 0x3613
movl %ebx, %edi
callq 0x2040
movl $0x1, 0x4c03(%rip)      # 0x8220
leaq 0x1c1c(%rip), %rsi      # 0x5240
movl $0x7, %edx
movl $0x2, %edi
callq 0x20e0
leaq 0x1c0e(%rip), %rsi      # 0x5248
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 0x1c06(%rip), %xmm0     # 0x5277
movups %xmm0, (%rsp,%rax)
testl %ebx, %ebx
js 0x36b1
leaq 0x4bc4(%rip), %rsi      # 0x8244
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 0x3687
jmp 0x36f0
leaq 0x4b8b(%rip), %rsi      # 0x8243
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 0x36ba
movb $0x2d, (%rsi)
movq %rsp, %r14
movq %r14, %rdi
callq 0x2320
movq %r14, %rdi
callq 0x2100
movw $0x5d, (%rsp,%rax)
movl %ebx, %edi
movq %r14, %rsi
callq 0x2390
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 0x377f
testl %ebp, %ebp
jle 0x377f
movq %rax, %r14
movl %ebp, %r13d
xorl %ebp, %ebp
leaq 0x1b2c(%rip), %r15      # 0x5275
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 0x3749
leaq 0x1ac2(%rip), %rsi      # 0x5248
movl $0x2e, %edx
movl $0x2, %edi
callq 0x20e0
movl %ebx, %edi
xorl %esi, %esi
callq 0x21f0
movl %ebx, %edi
callq 0x2040