#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 */
void EXIT_SUCCESS(int);
scalar_t__ SIG_ERR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ signal(int, void (*)(int));
int /*<<< orphan*/ stderr;
void (*xsignal(int sig, void (*func)(int)))(int) {
  if ((signal(sig, func)) == SIG_ERR) {
    fprintf(stderr, "%s\n", "Error: signal: Error in signal()\n");
    return (SIG_ERR);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<xsignal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <signal@plt>
mov    0x2e96(%rip),%rcx
cmp    (%rcx),%rax
jne    117a <xsignal+0x5a>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
lea    0xea2(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1185 <xsignal+0x65>
mov    0x2e4f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xsignal>:
push   %rbx
call   1030 <signal@plt>
mov    0x2eab(%rip),%rbx
cmp    (%rbx),%rax
jne    1153 <xsignal+0x33>
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0xebe(%rip),%rsi
lea    0xebb(%rip),%rdx
call   1040 <fprintf@plt>
mov    (%rbx),%rax
pop    %rbx
ret
mov    0x2e76(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@SIG_ERR = global i64 0
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [34 x i8] c"Error: signal: Error in signal()\0A\00"
define void (i32)* @xsignal(i32 %0, void (i32)* %1) {
%3 = alloca void (i32)*
%4 = alloca i32
%5 = alloca void (i32)*
store i32 %0, i32* %4
store void (i32)* %1, void (i32)** %5
%6 = load i32, i32* %4
%7 = load void (i32)*, void (i32)** %5
%8 = call i64 @signal(i32 %6, void (i32)* %7)
%9 = load i64, i64* @SIG_ERR
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%14 = load i64, i64* @SIG_ERR
%15 = inttoptr i64 %14 to void (i32)*
store void (i32)* %15, void (i32)** %3
br label %17
16: ; preds = %2
store void (i32)* @EXIT_SUCCESS, void (i32)** %3
br label %17
17: ; preds = %16, %11
%18 = load void (i32)*, void (i32)** %3
ret void (i32)* %18
}

LLVM IR (-O2):
@SIG_ERR = global i64 0
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [34 x i8] c"Error: signal: Error in signal()\0A\00"
define void (i32)* @xsignal(i32 %0, void (i32)* %1) {
%3 = tail call i64 @signal(i32 %0, void (i32)* %1)
%4 = load i64, i64* @SIG_ERR
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%9 = load i64, i64* @SIG_ERR
%10 = inttoptr i64 %9 to void (i32)*
br label %11
11: ; preds = %2, %6
%12 = phi void (i32)* [ %10, %6 ], [ @EXIT_SUCCESS, %2 ]
ret void (i32)* %12
}