#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 /*<<< orphan*/ SIGALRM;
scalar_t__ SIG_ERR;
int /*<<< orphan*/ alarm(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ pause();
scalar_t__ signal(int /*<<< orphan*/, void (*)(int));
int /*<<< orphan*/ stderr;
main() {
  int *y;
  void my_alrm_handler(int);
  if (signal(SIGALRM, my_alrm_handler) == SIG_ERR) {
    fprintf(stderr, "signal handler registration failed\n");
    exit(1);
  }
  while (1) {
    alarm(3);
    pause();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rsi
call   1040 <signal@plt>
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%rax
jne    11a3 <main+0x53>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11a8 <main+0x58>
mov    $0x3,%edi
call   1030 <alarm@plt>
mov    $0x0,%al
call   1060 <pause@plt>
jmp    11a8 <main+0x58>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    0x2e8f(%rip),%rsi
call   1040 <signal@plt>
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
je     1193 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x3,%edi
call   1030 <alarm@plt>
xor    %eax,%eax
call   1060 <pause@plt>
jmp    1180 <main+0x30>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@SIGALRM = global i32 0
@SIG_ERR = global i64 0
@stderr = global i32 0
@.str = [36 x i8] c"signal handler registration failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = load i32, i32* @SIGALRM
%4 = call i64 @signal(i32 %3, void (i32)* @my_alrm_handler)
%5 = load i64, i64* @SIG_ERR
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
br label %12
12: ; preds = %11, %12
%13 = call i32 @alarm(i32 3)
%14 = call i32 (...) @pause()
br label %12
}

LLVM IR (-O2):
@SIGALRM = global i32 0
@SIG_ERR = global i64 0
@stderr = global i32 0
@.str = [36 x i8] c"signal handler registration failed\0A\00"
define i32 @main() {
%1 = load i32, i32* @SIGALRM
%2 = tail call i64 @signal(i32 %1, void (i32)* @my_alrm_handler)
%3 = load i64, i64* @SIG_ERR
%4 = icmp eq i64 %2, %3
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0, %9
%10 = tail call i32 @alarm(i32 3)
%11 = tail call i32 (...) @pause()
br label %9
}