#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 */
#define SIGHUP 129
#define SIGINT 128
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ signal(int const, int /*<<< orphan*/);
void signal_function(int signal_num) {
  switch (signal_num) {
  case SIGHUP:
    printf("get a signal --- sighup\n");
    break;
  case SIGINT:
    printf("get a signal --- sigint\n");
    signal(SIGINT, SIG_DFL);
    break;
  case 33:
    printf("get a signal --- sigmy\n");
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<signal_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x21,%eax
je     119a <signal_function+0x7a>
jmp    113f <signal_function+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
je     1176 <signal_function+0x56>
jmp    1152 <signal_function+0x32>
mov    -0x8(%rbp),%eax
sub    $0x81,%eax
jne    11ab <signal_function+0x8b>
jmp    1165 <signal_function+0x45>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <signal_function+0x90>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
mov    $0x80,%edi
call   1040 <signal@plt>
jmp    11b0 <signal_function+0x90>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <signal_function+0x90>
jmp    11b0 <signal_function+0x90>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_function>:
cmp    $0x21,%edi
je     1141 <signal_function+0x21>
cmp    $0x80,%edi
je     114d <signal_function+0x2d>
cmp    $0x81,%edi
jne    116e <signal_function+0x4e>
lea    0xef3(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xeb8(%rip),%rdi
jmp    1030 <puts@plt>
push   %rax
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    $0x80,%edi
pop    %rax
jmp    1040 <signal@plt>
ret

LLVM IR (-O0):
@.str = [25 x i8] c"get a signal --- sighup\0A\00"
@.str.1 = [25 x i8] c"get a signal --- sigint\0A\00"
@SIG_DFL = global i32 0
@.str.2 = [24 x i8] c"get a signal --- sigmy\0A\00"
define void @signal_function(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %12 [
i32 129, label %4
i32 128, label %6
i32 33, label %10
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %13
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @SIG_DFL
%9 = call i32 @signal(i32 128, i32 %8)
br label %13
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %13
12: ; preds = %1
br label %13
13: ; preds = %12, %10, %6, %4
ret void
}

LLVM IR (-O2):
@SIG_DFL = global i32 0
@str = [23 x i8] c"get a signal --- sigmy\00"
@str.3 = [24 x i8] c"get a signal --- sigint\00"
@str.4 = [24 x i8] c"get a signal --- sighup\00"
define void @signal_function(i32 %0) {
switch i32 %0, label %10 [
i32 129, label %2
i32 128, label %4
i32 33, label %8
]
2: ; preds = %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
br label %10
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
%6 = load i32, i32* @SIG_DFL
%7 = tail call i32 @signal(i32 128, i32 %6)
br label %10
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %1, %8, %4, %2
ret void
}