#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 SIGALRM 129
#define SIGVTALRM 128
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ signal(int const, void (*)(int));
int /*<<< orphan*/ stdout;
void sigroutine(int signo) {
  switch (signo) {
  case SIGALRM: {
    printf("Catch a signal -- SIGALRM \n");
    signal(SIGALRM, sigroutine);
    break;
  }
  case SIGVTALRM: {
    printf("Catch a signal -- SIGVTALRM \n");
    signal(SIGVTALRM, sigroutine);
    break;
  }
  }
  fflush(stdout);
  return;
}


x86 assembly (clang, -O0):
<sigroutine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x80,%eax
je     1186 <sigroutine+0x56>
jmp    1151 <sigroutine+0x21>
mov    -0x8(%rbp),%eax
sub    $0x81,%eax
jne    11a3 <sigroutine+0x73>
jmp    1164 <sigroutine+0x34>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    $0x81,%edi
mov    0x2e7c(%rip),%rsi
call   1040 <signal@plt>
jmp    11a3 <sigroutine+0x73>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x80,%edi
mov    0x2e5a(%rip),%rsi
call   1040 <signal@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigroutine>:
push   %rbx
mov    %edi,%ebx
cmp    $0x81,%edi
je     1151 <sigroutine+0x21>
cmp    $0x80,%ebx
jne    116b <sigroutine+0x3b>
mov    $0x80,%ebx
lea    0xeb1(%rip),%rdi
jmp    1158 <sigroutine+0x28>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e94(%rip),%rsi
mov    %ebx,%edi
call   1040 <signal@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
pop    %rbx
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Catch a signal -- SIGALRM \0A\00"
@.str.1 = [30 x i8] c"Catch a signal -- SIGVTALRM \0A\00"
@stdout = global i32 0
define void @sigroutine(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %10 [
i32 129, label %4
i32 128, label %7
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @signal(i32 129, void (i32)* @sigroutine)
br label %10
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @signal(i32 128, void (i32)* @sigroutine)
br label %10
10: ; preds = %1, %7, %4
%11 = load i32, i32* @stdout
%12 = call i32 @fflush(i32 %11)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [29 x i8] c"Catch a signal -- SIGVTALRM \00"
@str.2 = [27 x i8] c"Catch a signal -- SIGALRM \00"
define void @sigroutine(i32 %0) {
switch i32 %0, label %8 [
i32 129, label %3
i32 128, label %2
]
2: ; preds = %1
br label %3
3: ; preds = %1, %2
%4 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.2, i64 0, i64 0), %1 ]
%5 = phi i32 [ 128, %2 ], [ %0, %1 ]
%6 = tail call i32 @puts(i8* dereferenceable(1) %4)
%7 = tail call i32 @signal(i32 %5, void (i32)* @sigroutine)
br label %8
8: ; preds = %3, %1
%9 = load i32, i32* @stdout
%10 = tail call i32 @fflush(i32 %9)
ret void
}