#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ linebuf;

/* Variables and functions */
int /*<<< orphan*/ dump_stack_symbols_to_error_fds();
int /*<<< orphan*/ format_dec_number_sigsafe(int, char *, int);
int /*<<< orphan*/ get_tor_backtrace_version();
int /*<<< orphan*/ tor_log_err_sigsafe(char *, int /*<<< orphan*/, char *,
                                       char const *, char *, char *, char *,
                                       char const *, char *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ tor_log_err_sigsafe_write(char const *);
void tor_raw_assertion_failed_msg_(const char *file, int line, const char *expr,
                                   const char *msg) {
  char linebuf[16];
  format_dec_number_sigsafe(line, linebuf, sizeof(linebuf));
  tor_log_err_sigsafe("INTERNAL ERROR: Raw assertion failed in ",
                      get_tor_backtrace_version(), " at ", file, ":", linebuf,
                      ": ", expr, "\n", NULL);
  if (msg) {
    tor_log_err_sigsafe_write(msg);
    tor_log_err_sigsafe_write("\n");
  }
  dump_stack_symbols_to_error_fds();
  tor_log_err_sigsafe_write("\n");
}


x86 assembly (clang, -O0):
<tor_raw_assertion_failed_msg_>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1070 <format_dec_number_sigsafe@plt>
mov    $0x0,%al
call   1050 <get_tor_backtrace_version@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
lea    -0x40(%rbp),%r9
mov    -0x20(%rbp),%r10
lea    0xe6b(%rip),%rdi
lea    0xe8d(%rip),%rdx
lea    0xe8b(%rip),%r8
lea    0xe86(%rip),%r11
lea    0xe82(%rip),%rax
xor    %ebx,%ebx
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
call   1060 <tor_log_err_sigsafe@plt>
cmpq   $0x0,-0x28(%rbp)
je     11ef <tor_raw_assertion_failed_msg_+0x9f>
mov    -0x28(%rbp),%rdi
call   1030 <tor_log_err_sigsafe_write@plt>
lea    0xe49(%rip),%rdi
call   1030 <tor_log_err_sigsafe_write@plt>
mov    $0x0,%al
call   1040 <dump_stack_symbols_to_error_fds@plt>
lea    0xe36(%rip),%rdi
call   1030 <tor_log_err_sigsafe_write@plt>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<tor_raw_assertion_failed_msg_>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rsp,%r12
mov    %esi,%edi
mov    %r12,%rsi
mov    $0x10,%edx
call   1070 <format_dec_number_sigsafe@plt>
xor    %eax,%eax
call   1050 <get_tor_backtrace_version@plt>
lea    0xeaf(%rip),%r10
lea    0xea5(%rip),%r11
lea    0xe6e(%rip),%rdi
lea    0xe90(%rip),%rdx
lea    0xe8e(%rip),%r8
mov    %eax,%esi
mov    %rbx,%rcx
mov    %r12,%r9
push   $0x0
push   %r10
push   %r14
push   %r11
call   1060 <tor_log_err_sigsafe@plt>
add    $0x20,%rsp
test   %r15,%r15
je     11d2 <tor_raw_assertion_failed_msg_+0x82>
mov    %r15,%rdi
call   1030 <tor_log_err_sigsafe_write@plt>
lea    0xe66(%rip),%rdi
call   1030 <tor_log_err_sigsafe_write@plt>
xor    %eax,%eax
call   1040 <dump_stack_symbols_to_error_fds@plt>
lea    0xe53(%rip),%rdi
call   1030 <tor_log_err_sigsafe_write@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [41 x i8] c"INTERNAL ERROR: Raw assertion failed in \00"
@.str.1 = [5 x i8] c" at \00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [3 x i8] c": \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @tor_raw_assertion_failed_msg_(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [16 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i32, i32* %6
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%12 = call i32 @format_dec_number_sigsafe(i32 %10, i8* %11, i32 16)
%13 = call i32 (...) @get_tor_backtrace_version()
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%16 = load i8*, i8** %7
%17 = call i32 @tor_log_err_sigsafe(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* null)
%18 = load i8*, i8** %8
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %4
%21 = load i8*, i8** %8
%22 = call i32 @tor_log_err_sigsafe_write(i8* %21)
%23 = call i32 @tor_log_err_sigsafe_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %20, %4
%25 = call i32 (...) @dump_stack_symbols_to_error_fds()
%26 = call i32 @tor_log_err_sigsafe_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"INTERNAL ERROR: Raw assertion failed in \00"
@.str.1 = [5 x i8] c" at \00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [3 x i8] c": \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @tor_raw_assertion_failed_msg_(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = call i32 @format_dec_number_sigsafe(i32 %1, i8* %6, i32 16)
%8 = call i32 (...) @get_tor_backtrace_version()
%9 = call i32 @tor_log_err_sigsafe(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* null)
%10 = icmp eq i8* %3, null
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = call i32 @tor_log_err_sigsafe_write(i8* %3)
%13 = call i32 @tor_log_err_sigsafe_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %11, %4
%15 = call i32 (...) @dump_stack_symbols_to_error_fds()
%16 = call i32 @tor_log_err_sigsafe_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}