#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ ece391_fdputs(int, int /*<<< orphan*/ *);
void alarm_sighandler(int signum) {
  ece391_fdputs(1, (uint8_t *)"Alarm signal handler called, signum: ");
  switch (signum) {
  case 0:
    ece391_fdputs(1, (uint8_t *)"0\n");
    break;
  case 1:
    ece391_fdputs(1, (uint8_t *)"1\n");
    break;
  case 2:
    ece391_fdputs(1, (uint8_t *)"2\n");
    break;
  case 3:
    ece391_fdputs(1, (uint8_t *)"3\n");
    break;
  default:
    ece391_fdputs(1, (uint8_t *)"invalid\n");
    break;
  }
}


x86 assembly (clang, -O0):
<alarm_sighandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeee(%rip),%rsi
mov    $0x1,%edi
call   1030 <ece391_fdputs@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     11a9 <alarm_sighandler+0x99>
mov    -0x10(%rbp),%rax
lea    0xeb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
lea    0xed9(%rip),%rsi
call   1030 <ece391_fdputs@plt>
jmp    11ba <alarm_sighandler+0xaa>
mov    $0x1,%edi
lea    0xec6(%rip),%rsi
call   1030 <ece391_fdputs@plt>
jmp    11ba <alarm_sighandler+0xaa>
mov    $0x1,%edi
lea    0xeb3(%rip),%rsi
call   1030 <ece391_fdputs@plt>
jmp    11ba <alarm_sighandler+0xaa>
mov    $0x1,%edi
lea    0xea0(%rip),%rsi
call   1030 <ece391_fdputs@plt>
jmp    11ba <alarm_sighandler+0xaa>
mov    $0x1,%edi
lea    0xe8d(%rip),%rsi
call   1030 <ece391_fdputs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alarm_sighandler>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rsi
mov    $0x1,%edi
call   1030 <ece391_fdputs@plt>
cmp    $0x3,%ebx
ja     113c <alarm_sighandler+0x2c>
movslq %ebx,%rax
lea    0xf09(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1143 <alarm_sighandler+0x33>
lea    0xeef(%rip),%rsi
mov    $0x1,%edi
pop    %rbx
jmp    1030 <ece391_fdputs@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Alarm signal handler called, signum: \00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [3 x i8] c"2\0A\00"
@.str.4 = [3 x i8] c"3\0A\00"
@.str.5 = [9 x i8] c"invalid\0A\00"
define void @alarm_sighandler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @ece391_fdputs(i32 1, i32* bitcast ([38 x i8]* @.str to i32*))
%4 = load i32, i32* %2
switch i32 %4, label %13 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
]
5: ; preds = %1
%6 = call i32 @ece391_fdputs(i32 1, i32* bitcast ([3 x i8]* @.str.1 to i32*))
br label %15
7: ; preds = %1
%8 = call i32 @ece391_fdputs(i32 1, i32* bitcast ([3 x i8]* @.str.2 to i32*))
br label %15
9: ; preds = %1
%10 = call i32 @ece391_fdputs(i32 1, i32* bitcast ([3 x i8]* @.str.3 to i32*))
br label %15
11: ; preds = %1
%12 = call i32 @ece391_fdputs(i32 1, i32* bitcast ([3 x i8]* @.str.4 to i32*))
br label %15
13: ; preds = %1
%14 = call i32 @ece391_fdputs(i32 1, i32* bitcast ([9 x i8]* @.str.5 to i32*))
br label %15
15: ; preds = %13, %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Alarm signal handler called, signum: \00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [3 x i8] c"2\0A\00"
@.str.4 = [3 x i8] c"3\0A\00"
@.str.5 = [9 x i8] c"invalid\0A\00"
@reltable.alarm_sighandler = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.alarm_sighandler to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.alarm_sighandler to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.alarm_sighandler to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.alarm_sighandler to i64)) to i32)]
define void @alarm_sighandler(i32 %0) {
%2 = tail call i32 @ece391_fdputs(i32 1, i32* bitcast ([38 x i8]* @.str to i32*))
%3 = icmp ult i32 %0, 4
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.alarm_sighandler to i8*), i64 %6)
%8 = bitcast i8* %7 to i32*
br label %9
9: ; preds = %1, %4
%10 = phi i32* [ %8, %4 ], [ bitcast ([9 x i8]* @.str.5 to i32*), %1 ]
%11 = tail call i32 @ece391_fdputs(i32 1, i32* %10)
ret void
}