#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 */
struct sigaction {
  int sa_flags;
  int /*<<< orphan*/ sa_mask;
  int /*<<< orphan*/ *sa_sigaction;
};

/* Variables and functions */
scalar_t__ ENOSYS;
int SA_RESTART;
int SA_SIGINFO;
int /*<<< orphan*/ SIGFPE;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sigaction(int /*<<< orphan*/, struct sigaction *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int main(void) {
  struct sigaction sa;
  int err;
  sa.sa_sigaction = NULL;
  sa.sa_flags = SA_RESTART | SA_SIGINFO;
  sigemptyset(&sa.sa_mask);
  err = sigaction(SIGFPE, &sa, NULL);
  if (err == -1 && errno == ENOSYS)
    printf("ENOSYS\n");
  printf("xyzzy\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    0x2e59(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11c2 <main+0x82>
mov    0x2e25(%rip),%rax
mov    (%rax),%rax
mov    0x2e33(%rip),%rcx
cmp    (%rcx),%rax
jne    11c2 <main+0x82>
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
mov    0x2e94(%rip),%rax
mov    0x2e65(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,0x8(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11a9 <main+0x69>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%rax
jne    11a9 <main+0x69>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.sigaction = type { i32, i32, i32* }
@SA_RESTART = global i32 0
@SA_SIGINFO = global i32 0
@SIGFPE = global i32 0
@errno = global i64 0
@ENOSYS = global i64 0
@.str = [8 x i8] c"ENOSYS\0A\00"
@.str.1 = [7 x i8] c"xyzzy\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 2
store i32* null, i32** %4
%5 = load i32, i32* @SA_RESTART
%6 = load i32, i32* @SA_SIGINFO
%7 = or i32 %5, %6
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 1
%10 = call i32 @sigemptyset(i32* %9)
%11 = load i32, i32* @SIGFPE
%12 = call i32 @sigaction(i32 %11, %struct.sigaction* %2, i32* null)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %0
%16 = load i64, i64* @errno
%17 = load i64, i64* @ENOSYS
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15, %0
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32, i32* }
@SA_RESTART = global i32 0
@SA_SIGINFO = global i32 0
@SIGFPE = global i32 0
@errno = global i64 0
@ENOSYS = global i64 0
@str = [6 x i8] c"xyzzy\00"
@str.2 = [7 x i8] c"ENOSYS\00"
define i32 @main() {
%1 = alloca %struct.sigaction
%2 = bitcast %struct.sigaction* %1 to i8*
%3 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 2
store i32* null, i32** %3
%4 = load i32, i32* @SA_RESTART
%5 = load i32, i32* @SA_SIGINFO
%6 = or i32 %5, %4
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 1
%9 = call i32 @sigemptyset(i32* %8)
%10 = load i32, i32* @SIGFPE
%11 = call i32 @sigaction(i32 %10, %struct.sigaction* %1, i32* null)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i64, i64* @errno
%15 = load i64, i64* @ENOSYS
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %13, %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%21 = call i32 @exit(i32 0)
unreachable
}