#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*/ abort();
int backtrace(void **, int);
char **backtrace_symbols(void **, int);
int /*<<< orphan*/ log_err(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:
    log_err("ILL: illegal opcode (%p)", info->si_addr);
    break;
  case ILL_ILLOPN:
    log_err("ILL: illegal operand (%p)", info->si_addr);
    break;
  case ILL_ILLADR:
    log_err("ILL: illegal addressing mode (%p)", info->si_addr);
    break;
  case ILL_ILLTRP:
    log_err("ILL: illegal trap (%p)", info->si_addr);
    break;
  case ILL_PRVOPC:
    log_err("ILL: privileged opcode (%p)", info->si_addr);
    break;
  case ILL_PRVREG:
    log_err("ILL: privilieged register (%p)", info->si_addr);
    break;
  case ILL_COPROC:
    log_err("ILL: coprocessor error (%p)", info->si_addr);
    break;
  case ILL_BADSTK:
    log_err("ILL: internal stack error (%p)", info->si_addr);
    break;
  default:
    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) {
    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     125f <ill+0x11f>
mov    -0x830(%rbp),%rax
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
jmp    1274 <ill+0x134>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@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    12df <ill+0x19f>
mov    -0x1c(%rbp),%esi
mov    -0x828(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <log_err@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12a5 <ill+0x165>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<ill>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    (%rsi),%eax
add    $0xffffff80,%eax
cmp    $0x7,%eax
ja     116a <ill+0x2a>
cltq
lea    0xfb7(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1171 <ill+0x31>
lea    0xf71(%rip),%rdi
mov    0x4(%rsi),%esi
xor    %eax,%eax
call   1060 <log_err@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    11c9 <ill+0x89>
mov    %rax,%r15
mov    %ebx,%r12d
lea    0xf5d(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <log_err@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <ill+0x70>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@.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 %54 [
i32 132, label %14
i32 131, label %19
i32 133, label %24
i32 130, label %29
i32 129, label %34
i32 128, label %39
i32 134, label %44
i32 135, label %49
]
14: ; preds = %3
%15 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %59
19: ; preds = %3
%20 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %59
24: ; preds = %3
%25 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %59
29: ; preds = %3
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %59
34: ; preds = %3
%35 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %59
39: ; preds = %3
%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 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %42)
br label %59
44: ; preds = %3
%45 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%46 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %45, i32 0, i32 1
%47 = load i32, i32* %46
%48 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %59
49: ; preds = %3
%50 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%51 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %52)
br label %59
54: ; preds = %3
%55 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%56 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %55, i32 0, i32 1
%57 = load i32, i32* %56
%58 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %54, %49, %44, %39, %34, %29, %24, %19, %14
%60 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%61 = call i32 @backtrace(i8** %60, i32 2048)
store i32 %61, i32* %8
%62 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%63 = load i32, i32* %8
%64 = call i8** @backtrace_symbols(i8** %62, i32 %63)
store i8** %64, i8*** %10
store i32 0, i32* %7
br label %65
65: ; preds = %77, %59
%66 = load i32, i32* %7
%67 = load i32, i32* %8
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %80
69: ; preds = %65
%70 = load i32, i32* %7
%71 = load i8**, i8*** %10
%72 = load i32, i32* %7
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %70, i8* %75)
br label %77
77: ; preds = %69
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %65
80: ; preds = %65
%81 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@.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 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, i32, ...) @log_err(i8* %15, i32 %17)
%19 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
%20 = call i32 @backtrace(i8** %19, i32 2048)
%21 = call i8** @backtrace_symbols(i8** %19, i32 %20)
%22 = icmp sgt i32 %20, 0
br i1 %22, label %23, label %33
23: ; preds = %14
%24 = zext i32 %20 to i64
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %31, %25 ]
%27 = getelementptr inbounds i8*, i8** %21, i64 %26
%28 = load i8*, i8** %27
%29 = trunc i64 %26 to i32
%30 = call i32 (i8*, i32, ...) @log_err(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %29, i8* %28)
%31 = add nuw nsw i64 %26, 1
%32 = icmp eq i64 %31, %24
br i1 %32, label %33, label %25
33: ; preds = %25, %14
%34 = call i32 (...) @abort()
unreachable
}