#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*/ FILE;

/* Variables and functions */
int LOG_ERR;
int LOG_USER;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *, int,
                           char const *);
int /*<<< orphan*/ syslog(int, char *, char const *, int, char const *);
void cm_list_assert_i(char const *expr, char const *file, int line) {
  FILE *fp;
  if ((fp = fopen("/dev/tty", "a")) != NULL) {
    fprintf(fp, "%s, line %d: assertion fails: \"%s\"\n", file, line, expr);
    fclose(fp);
  }
  syslog(LOG_ERR | LOG_USER, "ERROR: %s, line %d: assertion fails: \"%s\"",
         file, line, expr);
  abort();
  exit(1);
}


x86 assembly (clang, -O0):
<cm_list_assert_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xe96(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11a8 <cm_list_assert_i+0x58>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%r8
lea    0xe71(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    0x2e30(%rip),%rax
or     (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%r8
lea    0xe63(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<cm_list_assert_i>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xe99(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     119b <cm_list_assert_i+0x4b>
mov    %rax,%rbx
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %r15,%r8
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2e2e(%rip),%rax
mov    0x2e3f(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %r15,%r8
call   1060 <syslog@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/tty\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [36 x i8] c"%s, line %d: assertion fails: \22%s\22\0A\00"
@LOG_ERR = global i32 0
@LOG_USER = global i32 0
@.str.3 = [42 x i8] c"ERROR: %s, line %d: assertion fails: \22%s\22\00"
define void @cm_list_assert_i(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = load i32*, i32** %7
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = load i8*, i8** %4
%15 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %12, i32 %13, i8* %14)
%16 = load i32*, i32** %7
%17 = call i32 @fclose(i32* %16)
br label %18
18: ; preds = %10, %3
%19 = load i32, i32* @LOG_ERR
%20 = load i32, i32* @LOG_USER
%21 = or i32 %19, %20
%22 = load i8*, i8** %5
%23 = load i32, i32* %6
%24 = load i8*, i8** %4
%25 = call i32 @syslog(i32 %21, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %22, i32 %23, i8* %24)
%26 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/tty\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [36 x i8] c"%s, line %d: assertion fails: \22%s\22\0A\00"
@LOG_ERR = global i32 0
@LOG_USER = global i32 0
@.str.3 = [42 x i8] c"ERROR: %s, line %d: assertion fails: \22%s\22\00"
define void @cm_list_assert_i(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %2, i8* %0)
%8 = tail call i32 @fclose(i32* %4)
br label %9
9: ; preds = %6, %3
%10 = load i32, i32* @LOG_ERR
%11 = load i32, i32* @LOG_USER
%12 = or i32 %11, %10
%13 = tail call i32 @syslog(i32 %12, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %2, i8* %0)
%14 = tail call i32 (...) @abort()
unreachable
}