#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int si_code;
  int /*<<< orphan*/ si_addr;
};
typedef TYPE_1__ siginfo_t;
typedef int /*<<< orphan*/ pointers;

/* Variables and functions */
#define ILL_BADSTK 135
#define ILL_COPROC 134
#define ILL_ILLADR 133
#define ILL_ILLOPC 132
#define ILL_ILLOPN 131
#define ILL_ILLTRP 130
#define ILL_PRVOPC 129
#define ILL_PRVREG 128
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ abort();
int backtrace(void **, int);
char **backtrace_symbols(void **, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int, ...);
void ill(int sig, siginfo_t *info, void *data) {
  int i;
  int frame_count = 0;
  void *pointers[256];
  switch (info->si_code) {
  case ILL_ILLOPC:
    syslog(LOG_ERR, "ILL: illegal opcode (%p)", info->si_addr);
    break;
  case ILL_ILLOPN:
    syslog(LOG_ERR, "ILL: illegal operand (%p)", info->si_addr);
    break;
  case ILL_ILLADR:
    syslog(LOG_ERR, "ILL: illegal addressing mode (%p)", info->si_addr);
    break;
  case ILL_ILLTRP:
    syslog(LOG_ERR, "ILL: illegal trap (%p)", info->si_addr);
    break;
  case ILL_PRVOPC:
    syslog(LOG_ERR, "ILL: privileged opcode (%p)", info->si_addr);
    break;
  case ILL_PRVREG:
    syslog(LOG_ERR, "ILL: privilieged register (%p)", info->si_addr);
    break;
  case ILL_COPROC:
    syslog(LOG_ERR, "ILL: coprocessor error (%p)", info->si_addr);
    break;
  case ILL_BADSTK:
    syslog(LOG_ERR, "ILL: internal stack error (%p)", info->si_addr);
    break;
  default:
    syslog(LOG_ERR, "illegal instruction at address %p\n", info->si_addr);
  }
  frame_count = backtrace(pointers, sizeof(pointers));
  char **frames = backtrace_symbols(pointers, frame_count);
  for (i = 0; i < frame_count; ++i) {
    syslog(LOG_ERR, "frame(%03d): %s", i, frames[i]);
  }
  abort();
}


x86 assembly (clang, -O0):
<ill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x830(%rbp)
sub    $0x7,%eax
ja     12a7 <ill+0x167>
mov    -0x830(%rbp),%rax
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    12c5 <ill+0x185>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
lea    -0x820(%rbp),%rdi
mov    $0x800,%esi
call   1050 <backtrace@plt>
mov    %eax,-0x20(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <backtrace_symbols@plt>
mov    %rax,-0x828(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1339 <ill+0x1f9>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
mov    -0x828(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f6 <ill+0x1b6>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<ill>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    (%rsi),%eax
add    $0xffffff80,%eax
cmp    $0x7,%eax
ja     116c <ill+0x2c>
cltq
lea    0xfb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    1173 <ill+0x33>
lea    0xf6f(%rip),%rax
mov    0x2e5e(%rip),%r12
mov    (%r12),%edi
mov    0x4(%rsi),%edx
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <syslog@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x800,%esi
call   1050 <backtrace@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <backtrace_symbols@plt>
test   %ebx,%ebx
jle    11dd <ill+0x9d>
mov    %rax,%r15
mov    %ebx,%r13d
lea    0xf4d(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    (%r15,%rbx,8),%rcx
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <syslog@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11c0 <ill+0x80>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@LOG_ERR = global i32 0
@.str = [25 x i8] c"ILL: illegal opcode (%p)\00"
@.str.1 = [26 x i8] c"ILL: illegal operand (%p)\00"
@.str.2 = [34 x i8] c"ILL: illegal addressing mode (%p)\00"
@.str.3 = [23 x i8] c"ILL: illegal trap (%p)\00"
@.str.4 = [28 x i8] c"ILL: privileged opcode (%p)\00"
@.str.5 = [31 x i8] c"ILL: privilieged register (%p)\00"
@.str.6 = [28 x i8] c"ILL: coprocessor error (%p)\00"
@.str.7 = [31 x i8] c"ILL: internal stack error (%p)\00"
@.str.8 = [35 x i8] c"illegal instruction at address %p\0A\00"
@.str.9 = [16 x i8] c"frame(%03d): %s\00"
define void @ill(i32 %0, %struct.TYPE_3__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8*]
%10 = alloca i8**
store i32 %0, i32* %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
store i8* %2, i8** %6
store i32 0, i32* %8
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i32, i32* %12
switch i32 %13, label %62 [
i32 132, label %14
i32 131, label %20
i32 133, label %26
i32 130, label %32
i32 129, label %38
i32 128, label %44
i32 134, label %50
i32 135, label %56
]
14: ; preds = %3
%15 = load i32, i32* @LOG_ERR
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = call i32 (i32, i8*, i32, ...) @syslog(i32 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %68
20: ; preds = %3
%21 = load i32, i32* @LOG_ERR
%22 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32 (i32, i8*, i32, ...) @syslog(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %68
26: ; preds = %3
%27 = load i32, i32* @LOG_ERR
%28 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = call i32 (i32, i8*, i32, ...) @syslog(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %68
32: ; preds = %3
%33 = load i32, i32* @LOG_ERR
%34 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = call i32 (i32, i8*, i32, ...) @syslog(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %68
38: ; preds = %3
%39 = load i32, i32* @LOG_ERR
%40 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 1
%42 = load i32, i32* %41
%43 = call i32 (i32, i8*, i32, ...) @syslog(i32 %39, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %68
44: ; preds = %3
%45 = load i32, i32* @LOG_ERR
%46 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%47 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %46, i32 0, i32 1
%48 = load i32, i32* %47
%49 = call i32 (i32, i8*, i32, ...) @syslog(i32 %45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %48)
br label %68
50: ; preds = %3
%51 = load i32, i32* @LOG_ERR
%52 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%53 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %52, i32 0, i32 1
%54 = load i32, i32* %53
%55 = call i32 (i32, i8*, i32, ...) @syslog(i32 %51, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %54)
br label %68
56: ; preds = %3
%57 = load i32, i32* @LOG_ERR
%58 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%59 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %58, i32 0, i32 1
%60 = load i32, i32* %59
%61 = call i32 (i32, i8*, i32, ...) @syslog(i32 %57, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %60)
br label %68
62: ; preds = %3
%63 = load i32, i32* @LOG_ERR
%64 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%65 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %64, i32 0, i32 1
%66 = load i32, i32* %65
%67 = call i32 (i32, i8*, i32, ...) @syslog(i32 %63, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %62, %56, %50, %44, %38, %32, %26, %20, %14
%69 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%70 = call i32 @backtrace(i8** %69, i32 2048)
store i32 %70, i32* %8
%71 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%72 = load i32, i32* %8
%73 = call i8** @backtrace_symbols(i8** %71, i32 %72)
store i8** %73, i8*** %10
store i32 0, i32* %7
br label %74
74: ; preds = %87, %68
%75 = load i32, i32* %7
%76 = load i32, i32* %8
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %90
78: ; preds = %74
%79 = load i32, i32* @LOG_ERR
%80 = load i32, i32* %7
%81 = load i8**, i8*** %10
%82 = load i32, i32* %7
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 (i32, i8*, i32, ...) @syslog(i32 %79, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %80, i8* %85)
br label %87
87: ; preds = %78
%88 = load i32, i32* %7
%89 = add nsw i32 %88, 1
store i32 %89, i32* %7
br label %74
90: ; preds = %74
%91 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@LOG_ERR = global i32 0
@.str = [25 x i8] c"ILL: illegal opcode (%p)\00"
@.str.1 = [26 x i8] c"ILL: illegal operand (%p)\00"
@.str.2 = [34 x i8] c"ILL: illegal addressing mode (%p)\00"
@.str.3 = [23 x i8] c"ILL: illegal trap (%p)\00"
@.str.4 = [28 x i8] c"ILL: privileged opcode (%p)\00"
@.str.5 = [31 x i8] c"ILL: privilieged register (%p)\00"
@.str.6 = [28 x i8] c"ILL: coprocessor error (%p)\00"
@.str.7 = [31 x i8] c"ILL: internal stack error (%p)\00"
@.str.8 = [35 x i8] c"illegal instruction at address %p\0A\00"
@.str.9 = [16 x i8] c"frame(%03d): %s\00"
@reltable.ill = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.ill to i64)) to i32)]
define void @ill(i32 %0, %struct.TYPE_3__* nocapture %1, i8* nocapture readnone %2) {
%4 = alloca [256 x i8*]
%5 = bitcast [256 x i8*]* %4 to i8*
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add i32 %7, -128
%9 = icmp ult i32 %8, 8
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = sext i32 %8 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.ill to i8*), i64 %12)
br label %14
14: ; preds = %3, %10
%15 = phi i8* [ %13, %10 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), %3 ]
%16 = load i32, i32* @LOG_ERR
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%18 = load i32, i32* %17
%19 = tail call i32 (i32, i8*, i32, ...) @syslog(i32 %16, i8* %15, i32 %18)
%20 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
%21 = call i32 @backtrace(i8** %20, i32 2048)
%22 = call i8** @backtrace_symbols(i8** %20, i32 %21)
%23 = icmp sgt i32 %21, 0
br i1 %23, label %24, label %35
24: ; preds = %14
%25 = zext i32 %21 to i64
br label %26
26: ; preds = %24, %26
%27 = phi i64 [ 0, %24 ], [ %33, %26 ]
%28 = load i32, i32* @LOG_ERR
%29 = getelementptr inbounds i8*, i8** %22, i64 %27
%30 = load i8*, i8** %29
%31 = trunc i64 %27 to i32
%32 = call i32 (i32, i8*, i32, ...) @syslog(i32 %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %31, i8* %30)
%33 = add nuw nsw i64 %27, 1
%34 = icmp eq i64 %33, %25
br i1 %34, label %35, label %26
35: ; preds = %26, %14
%36 = call i32 (...) @abort()
unreachable
}