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

/* Variables and functions */
int SIGFPE;
int SIGILL;
int SIGINT;
int /*<<< orphan*/ printf(char *);
void catch_function(int sig) {
  printf("catch function is processing the signal\n");
  if (sig == SIGINT) {
    printf("catch int\n");
  } else if (sig == SIGFPE) {
    printf("catch float overflow\n");
  } else if (sig == SIGILL) {
    printf("catch illegal operation\n");
  }
}


x86 assembly (clang, -O0):
<catch_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    0x2eb7(%rip),%rcx
cmp    (%rcx),%eax
jne    114a <catch_function+0x3a>
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <catch_function+0x85>
mov    -0x4(%rbp),%eax
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
jne    116d <catch_function+0x5d>
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
jmp    1190 <catch_function+0x80>
mov    -0x4(%rbp),%eax
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%eax
jne    118b <catch_function+0x7b>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
jmp    1190 <catch_function+0x80>
jmp    1195 <catch_function+0x85>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<catch_function>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ec2(%rip),%rax
cmp    %ebx,(%rax)
jne    1137 <catch_function+0x27>
lea    0xf24(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
mov    0x2ea2(%rip),%rax
cmp    %ebx,(%rax)
jne    114f <catch_function+0x3f>
lea    0xef7(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
mov    0x2e82(%rip),%rax
cmp    %ebx,(%rax)
jne    1167 <catch_function+0x57>
lea    0xec7(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"catch function is processing the signal\0A\00"
@SIGINT = global i32 0
@.str.1 = [11 x i8] c"catch int\0A\00"
@SIGFPE = global i32 0
@.str.2 = [22 x i8] c"catch float overflow\0A\00"
@SIGILL = global i32 0
@.str.3 = [25 x i8] c"catch illegal operation\0A\00"
define void @catch_function(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = load i32, i32* @SIGINT
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %23
9: ; preds = %1
%10 = load i32, i32* %2
%11 = load i32, i32* @SIGFPE
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %22
15: ; preds = %9
%16 = load i32, i32* %2
%17 = load i32, i32* @SIGILL
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
br label %22
22: ; preds = %21, %13
br label %23
23: ; preds = %22, %7
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGFPE = global i32 0
@SIGILL = global i32 0
@str = [40 x i8] c"catch function is processing the signal\00"
@str.4 = [24 x i8] c"catch illegal operation\00"
@str.5 = [21 x i8] c"catch float overflow\00"
@str.6 = [10 x i8] c"catch int\00"
define void @catch_function(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @SIGINT
%4 = icmp eq i32 %3, %0
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = load i32, i32* @SIGFPE
%7 = icmp eq i32 %6, %0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i32, i32* @SIGILL
%10 = icmp eq i32 %9, %0
br i1 %10, label %11, label %14
11: ; preds = %8, %5, %1
%12 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0), %1 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0), %5 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0), %8 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %8
ret void
}