#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 TYPE_3__ {
  int /*<<< orphan*/ ss_size;
  scalar_t__ ss_flags;
  void *ss_sp;
};
typedef TYPE_1__ stack_t;

/* Variables and functions */
int /*<<< orphan*/ SIGSTKSZ;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ perror(char *);
scalar_t__ sigaltstack(TYPE_1__ *, int /*<<< orphan*/ *);
void hipe_sigaltstack(void *ss_sp) {
  stack_t ss;
  ss.ss_sp = ss_sp;
  ss.ss_flags = 0;
  ss.ss_size = SIGSTKSZ;
  if (sigaltstack(&ss, NULL) < 0) {
    perror("sigaltstack");
    abort();
  }
}


x86 assembly (clang, -O0):
<hipe_sigaltstack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <sigaltstack@plt>
cmp    $0x0,%rax
jge    1182 <hipe_sigaltstack+0x52>
lea    0xe8a(%rip),%rdi
call   1040 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hipe_sigaltstack>:
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <sigaltstack@plt>
test   %rax,%rax
js     1162 <hipe_sigaltstack+0x32>
add    $0x18,%rsp
ret
lea    0xe97(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64, i8* }
@SIGSTKSZ = global i32 0
@.str = [12 x i8] c"sigaltstack\00"
define void @hipe_sigaltstack(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.TYPE_3__
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 2
store i8* %4, i8** %5
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
store i64 0, i64* %6
%7 = load i32, i32* @SIGSTKSZ
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
store i32 %7, i32* %8
%9 = call i64 @sigaltstack(%struct.TYPE_3__* %3, i32* null)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %1
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64, i8* }
@SIGSTKSZ = global i32 0
@.str = [12 x i8] c"sigaltstack\00"
define void @hipe_sigaltstack(i8* %0) {
%2 = alloca %struct.TYPE_3__
%3 = bitcast %struct.TYPE_3__* %2 to i8*
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 2
store i8* %0, i8** %4
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 1
store i64 0, i64* %5
%6 = load i32, i32* @SIGSTKSZ
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
store i32 %6, i32* %7
%8 = call i64 @sigaltstack(%struct.TYPE_3__* %2, i32* null)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %1
ret void
}