#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 FPE_FLTDIV 135
#define FPE_FLTINV 134
#define FPE_FLTOVF 133
#define FPE_FLTRES 132
#define FPE_FLTSUB 131
#define FPE_FLTUND 130
#define FPE_INTDIV 129
#define FPE_INTOVF 128
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ abort();
int backtrace(void **, int);
char **backtrace_symbols(void **, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
void fpe(int sig, siginfo_t *info, void *data) {
  int i;
  int frame_count = 0;
  void *pointers[256];
  switch (info->si_code) {
  case FPE_INTDIV:
    syslog(LOG_ERR, "FPE: integer divide by zero");
    break;
  case FPE_INTOVF:
    syslog(LOG_ERR, "FPE: integer overflow");
    break;
  case FPE_FLTDIV:
    syslog(LOG_ERR, "FPE: floating point divide by zero");
    break;
  case FPE_FLTOVF:
    syslog(LOG_ERR, "FPE: floating point overflow");
    break;
  case FPE_FLTUND:
    syslog(LOG_ERR, "FPE: floating point underflow");
    break;
  case FPE_FLTRES:
    syslog(LOG_ERR, "FPE: floating point inexact result");
    break;
  case FPE_FLTINV:
    syslog(LOG_ERR, "FPE: floating point invalid operation");
    break;
  case FPE_FLTSUB:
    syslog(LOG_ERR, "FPE: floating point sudirript out of range");
    break;
  default:
    syslog(LOG_ERR, "FPE at address %p\n", info->si_addr);
    break;
  }
  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):
<fpe>:
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     126f <fpe+0x12f>
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
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    128d <fpe+0x14d>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe9e(%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    1301 <fpe+0x1c1>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
mov    -0x828(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12be <fpe+0x17e>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<fpe>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    (%rsi),%eax
add    $0xffffff80,%eax
cmp    $0x7,%eax
ja     117f <fpe+0x3f>
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xec2(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsi),%edx
lea    0xf92(%rip),%rsi
xor    %eax,%eax
call   1060 <syslog@plt>
jmp    1221 <fpe+0xe1>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xed2(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xf27(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xecb(%rip),%rsi
jmp    121a <fpe+0xda>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%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    127d <fpe+0x13d>
mov    %rax,%r15
mov    %ebx,%r12d
mov    0x2d8a(%rip),%r13
lea    0xee2(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%r15,%rbx,8),%rcx
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <syslog@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1260 <fpe+0x120>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@LOG_ERR = global i32 0
@.str = [28 x i8] c"FPE: integer divide by zero\00"
@.str.1 = [22 x i8] c"FPE: integer overflow\00"
@.str.2 = [35 x i8] c"FPE: floating point divide by zero\00"
@.str.3 = [29 x i8] c"FPE: floating point overflow\00"
@.str.4 = [30 x i8] c"FPE: floating point underflow\00"
@.str.5 = [35 x i8] c"FPE: floating point inexact result\00"
@.str.6 = [38 x i8] c"FPE: floating point invalid operation\00"
@.str.7 = [43 x i8] c"FPE: floating point sudirript out of range\00"
@.str.8 = [19 x i8] c"FPE at address %p\0A\00"
@.str.9 = [16 x i8] c"frame(%03d): %s\00"
define void @fpe(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 %38 [
i32 129, label %14
i32 128, label %17
i32 135, label %20
i32 133, label %23
i32 130, label %26
i32 132, label %29
i32 134, label %32
i32 131, label %35
]
14: ; preds = %3
%15 = load i32, i32* @LOG_ERR
%16 = call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %44
17: ; preds = %3
%18 = load i32, i32* @LOG_ERR
%19 = call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %44
20: ; preds = %3
%21 = load i32, i32* @LOG_ERR
%22 = call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %44
23: ; preds = %3
%24 = load i32, i32* @LOG_ERR
%25 = call i32 (i32, i8*, ...) @syslog(i32 %24, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %44
26: ; preds = %3
%27 = load i32, i32* @LOG_ERR
%28 = call i32 (i32, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %44
29: ; preds = %3
%30 = load i32, i32* @LOG_ERR
%31 = call i32 (i32, i8*, ...) @syslog(i32 %30, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %44
32: ; preds = %3
%33 = load i32, i32* @LOG_ERR
%34 = call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %44
35: ; preds = %3
%36 = load i32, i32* @LOG_ERR
%37 = call i32 (i32, i8*, ...) @syslog(i32 %36, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0))
br label %44
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*, ...) @syslog(i32 %39, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %38, %35, %32, %29, %26, %23, %20, %17, %14
%45 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%46 = call i32 @backtrace(i8** %45, i32 2048)
store i32 %46, i32* %8
%47 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%48 = load i32, i32* %8
%49 = call i8** @backtrace_symbols(i8** %47, i32 %48)
store i8** %49, i8*** %10
store i32 0, i32* %7
br label %50
50: ; preds = %63, %44
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %66
54: ; preds = %50
%55 = load i32, i32* @LOG_ERR
%56 = load i32, i32* %7
%57 = load i8**, i8*** %10
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 (i32, i8*, ...) @syslog(i32 %55, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %56, i8* %61)
br label %63
63: ; preds = %54
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %50
66: ; preds = %50
%67 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@LOG_ERR = global i32 0
@.str = [28 x i8] c"FPE: integer divide by zero\00"
@.str.1 = [22 x i8] c"FPE: integer overflow\00"
@.str.2 = [35 x i8] c"FPE: floating point divide by zero\00"
@.str.3 = [29 x i8] c"FPE: floating point overflow\00"
@.str.4 = [30 x i8] c"FPE: floating point underflow\00"
@.str.5 = [35 x i8] c"FPE: floating point inexact result\00"
@.str.6 = [38 x i8] c"FPE: floating point invalid operation\00"
@.str.7 = [43 x i8] c"FPE: floating point sudirript out of range\00"
@.str.8 = [19 x i8] c"FPE at address %p\0A\00"
@.str.9 = [16 x i8] c"frame(%03d): %s\00"
define void @fpe(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
switch i32 %7, label %32 [
i32 129, label %8
i32 128, label %11
i32 135, label %14
i32 133, label %17
i32 130, label %20
i32 132, label %23
i32 134, label %26
i32 131, label %29
]
8: ; preds = %3
%9 = load i32, i32* @LOG_ERR
%10 = tail call i32 (i32, i8*, ...) @syslog(i32 %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %37
11: ; preds = %3
%12 = load i32, i32* @LOG_ERR
%13 = tail call i32 (i32, i8*, ...) @syslog(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %37
14: ; preds = %3
%15 = load i32, i32* @LOG_ERR
%16 = tail call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %37
17: ; preds = %3
%18 = load i32, i32* @LOG_ERR
%19 = tail call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %37
20: ; preds = %3
%21 = load i32, i32* @LOG_ERR
%22 = tail call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %37
23: ; preds = %3
%24 = load i32, i32* @LOG_ERR
%25 = tail call i32 (i32, i8*, ...) @syslog(i32 %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %37
26: ; preds = %3
%27 = load i32, i32* @LOG_ERR
%28 = tail call i32 (i32, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %37
29: ; preds = %3
%30 = load i32, i32* @LOG_ERR
%31 = tail call i32 (i32, i8*, ...) @syslog(i32 %30, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0))
br label %37
32: ; preds = %3
%33 = load i32, i32* @LOG_ERR
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%35 = load i32, i32* %34
%36 = tail call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %32, %29, %26, %23, %20, %17, %14, %11, %8
%38 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 0
%39 = call i32 @backtrace(i8** %38, i32 2048)
%40 = call i8** @backtrace_symbols(i8** %38, i32 %39)
%41 = icmp sgt i32 %39, 0
br i1 %41, label %42, label %53
42: ; preds = %37
%43 = zext i32 %39 to i64
br label %44
44: ; preds = %42, %44
%45 = phi i64 [ 0, %42 ], [ %51, %44 ]
%46 = load i32, i32* @LOG_ERR
%47 = getelementptr inbounds i8*, i8** %40, i64 %45
%48 = load i8*, i8** %47
%49 = trunc i64 %45 to i32
%50 = call i32 (i32, i8*, ...) @syslog(i32 %46, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %49, i8* %48)
%51 = add nuw nsw i64 %45, 1
%52 = icmp eq i64 %51, %43
br i1 %52, label %53, label %44
53: ; preds = %44, %37
%54 = call i32 (...) @abort()
unreachable
}