#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct sigaction {
  int dummy;
};
struct TYPE_3__ {
  int ss_flags;
  scalar_t__ ss_size;
  scalar_t__ ss_sp;
};
typedef TYPE_1__ stack_t;
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
scalar_t__ EINVAL;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, scalar_t__);
int sigaction(int, struct sigaction *, int /*<<< orphan*/);
int sigaltstack(TYPE_1__ *, int /*<<< orphan*/);
int sigprocmask(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main() {
  struct sigaction act;
  sigset_t set;
  stack_t stack;
  errno = 0;
  if (sigaction(0x12345678, &act, 0) != -1 || errno != EINVAL) {
    fprintf(stderr, "sigaction: Expected EINVAL, but got %d\n", errno);
    return 1;
  }
  errno = 0;
  if (sigprocmask(0x12345678, &set, 0) != -1 || errno != EINVAL) {
    fprintf(stderr, "sigprocmask: Expected EINVAL, but got %d\n", errno);
    return 1;
  }
  errno = 0;
  stack.ss_sp = 0;
  stack.ss_size = 0;
  stack.ss_flags = 0x12345678;
  if (sigaltstack(&stack, 0) != -1 || errno != EINVAL) {
    fprintf(stderr, "sigaltstack: Expected EINVAL, but got %d\n", errno);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
movq   $0x0,(%rax)
mov    $0x12345678,%edi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1040 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
mov    0x2e5b(%rip),%rax
mov    (%rax),%rax
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%rax
je     11bb <main+0x7b>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    0x2e38(%rip),%rax
mov    (%rax),%rdx
lea    0xe56(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ac <main+0x16c>
mov    0x2e16(%rip),%rax
movq   $0x0,(%rax)
mov    $0x12345678,%edi
lea    -0xc(%rbp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    11fc <main+0xbc>
mov    0x2def(%rip),%rax
mov    (%rax),%rax
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%rax
je     1227 <main+0xe7>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    0x2dcc(%rip),%rax
mov    (%rax),%rdx
lea    0xe12(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ac <main+0x16c>
mov    0x2daa(%rip),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x12345678,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1060 <sigaltstack@plt>
cmp    $0xffffffff,%eax
jne    127a <main+0x13a>
mov    0x2d71(%rip),%rax
mov    (%rax),%rax
mov    0x2d5f(%rip),%rcx
cmp    (%rcx),%rax
je     12a5 <main+0x165>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%rdx
lea    0xdbe(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ac <main+0x16c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e88(%rip),%r14
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    $0x12345678,%edi
xor    %edx,%edx
call   1040 <sigaction@plt>
mov    (%r14),%rdx
cmp    $0xffffffff,%eax
jne    11e3 <main+0xa3>
mov    0x2e5b(%rip),%r15
cmp    (%r15),%rdx
jne    11e3 <main+0xa3>
movq   $0x0,(%r14)
lea    0x4(%rsp),%rsi
mov    $0x12345678,%edi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    (%r14),%rdx
cmp    $0xffffffff,%eax
jne    11f5 <main+0xb5>
cmp    (%r15),%rdx
jne    11f5 <main+0xb5>
movq   $0x0,(%r14)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
movl   $0x12345678,0x8(%rsp)
12
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1060 <sigaltstack@plt>
mov    (%r14),%rdx
cmp    $0xffffffff,%eax
jne    11d1 <main+0x91>
cmp    (%r15),%rdx
je     120f <main+0xcf>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
jmp    1205 <main+0xc5>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
jmp    1205 <main+0xc5>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sigaction = type { i32 }
%struct.TYPE_3__ = type { i32, i64, i64 }
@errno = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str = [40 x i8] c"sigaction: Expected EINVAL, but got %d\0A\00"
@.str.1 = [42 x i8] c"sigprocmask: Expected EINVAL, but got %d\0A\00"
@.str.2 = [42 x i8] c"sigaltstack: Expected EINVAL, but got %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = alloca i32
%4 = alloca %struct.TYPE_3__
store i32 0, i32* %1
store i64 0, i64* @errno
%5 = call i32 @sigaction(i32 305419896, %struct.sigaction* %2, i32 0)
%6 = icmp ne i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = load i64, i64* @EINVAL
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %7, %0
%12 = load i32, i32* @stderr
%13 = load i64, i64* @errno
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i64 %13)
store i32 1, i32* %1
br label %41
15: ; preds = %7
store i64 0, i64* @errno
%16 = call i32 @sigprocmask(i32 305419896, i32* %3, i32 0)
%17 = icmp ne i32 %16, -1
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = load i64, i64* @errno
%20 = load i64, i64* @EINVAL
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18, %15
%23 = load i32, i32* @stderr
%24 = load i64, i64* @errno
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 %24)
store i32 1, i32* %1
br label %41
26: ; preds = %18
store i64 0, i64* @errno
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 2
store i64 0, i64* %27
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 1
store i64 0, i64* %28
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 0
store i32 305419896, i32* %29
%30 = call i32 @sigaltstack(%struct.TYPE_3__* %4, i32 0)
%31 = icmp ne i32 %30, -1
br i1 %31, label %36, label %32
32: ; preds = %26
%33 = load i64, i64* @errno
%34 = load i64, i64* @EINVAL
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %32, %26
%37 = load i32, i32* @stderr
%38 = load i64, i64* @errno
%39 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i64 %38)
store i32 1, i32* %1
br label %41
40: ; preds = %32
store i32 0, i32* %1
br label %41
41: ; preds = %40, %36, %22, %11
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
%struct.sigaction = type { i32 }
%struct.TYPE_3__ = type { i32, i64, i64 }
@errno = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str = [40 x i8] c"sigaction: Expected EINVAL, but got %d\0A\00"
@.str.1 = [42 x i8] c"sigprocmask: Expected EINVAL, but got %d\0A\00"
@.str.2 = [42 x i8] c"sigaltstack: Expected EINVAL, but got %d\0A\00"
define i32 @main() {
%1 = alloca %struct.sigaction
%2 = alloca i32
%3 = alloca %struct.TYPE_3__
%4 = bitcast %struct.sigaction* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast %struct.TYPE_3__* %3 to i8*
store i64 0, i64* @errno
%7 = call i32 @sigaction(i32 305419896, %struct.sigaction* %1, i32 0)
%8 = icmp eq i32 %7, -1
%9 = load i64, i64* @errno
%10 = load i64, i64* @EINVAL
%11 = icmp eq i64 %9, %10
%12 = select i1 %8, i1 %11, i1 false
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i64 %9)
br label %39
16: ; preds = %0
store i64 0, i64* @errno
%17 = call i32 @sigprocmask(i32 305419896, i32* %2, i32 0)
%18 = icmp eq i32 %17, -1
%19 = load i64, i64* @errno
%20 = load i64, i64* @EINVAL
%21 = icmp eq i64 %19, %20
%22 = select i1 %18, i1 %21, i1 false
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 %19)
br label %39
26: ; preds = %16
store i64 0, i64* @errno
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%29 = bitcast i64* %27 to i8*
store i32 305419896, i32* %28
%30 = call i32 @sigaltstack(%struct.TYPE_3__* %3, i32 0)
%31 = icmp eq i32 %30, -1
%32 = load i64, i64* @errno
%33 = load i64, i64* @EINVAL
%34 = icmp eq i64 %32, %33
%35 = select i1 %31, i1 %34, i1 false
br i1 %35, label %39, label %36
36: ; preds = %26
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i64 %32)
br label %39
39: ; preds = %26, %36, %23, %13
%40 = phi i32 [ 1, %13 ], [ 1, %23 ], [ 1, %36 ], [ 0, %26 ]
ret i32 %40
}