#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 */
union sigval {
  void *sival_ptr;
  int sival_int;
};
struct sigaction {
  int /*<<< orphan*/ sa_handler;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_IGN;
int getpid();
int getuid();
int /*<<< orphan*/ printf(char *, ...);
int sigaction(int /*<<< orphan*/, struct sigaction *, int /*<<< orphan*/ *);
int sigqueue(int, int /*<<< orphan*/, union sigval);
int main(void) {
  struct sigaction sa = {.sa_handler = SIG_IGN};
  union sigval value = {.sival_ptr = (void *)(unsigned long)0xdeadbeefbadc0ded};
  pid_t pid = getpid();
  if (sigaction(SIGUSR1, &sa, NULL) == -1)
    return 77;
  if (sigqueue(pid, SIGUSR1, value) == -1)
    return 77;
  printf("rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, "
         "si_code=SI_QUEUE, si_pid=%u, si_uid=%u, "
         "si_value={int=%d, ptr=%p}}) = 0\n",
         pid, pid, getuid(), value.sival_int, value.sival_ptr);
  printf("+++ exited with 0 +++\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0xe8e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11ab <main+0x5b>
movl   $0x4d,-0x4(%rbp)
jmp    121b <main+0xcb>
mov    -0x14(%rbp),%edi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1070 <sigqueue@plt>
cmp    $0xffffffff,%eax
jne    11d5 <main+0x85>
movl   $0x4d,-0x4(%rbp)
jmp    121b <main+0xcb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
mov    -0x10(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%ebp
mov    0x2e65(%rip),%r15
mov    (%r15),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1040 <sigaction@plt>
mov    $0x4d,%ebx
cmp    $0xffffffff,%eax
je     11e8 <main+0x88>
movabs $0xdeadbeefbadc0ded,%r14
be ad de
mov    (%r15),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1080 <sigqueue@plt>
cmp    $0xffffffff,%eax
je     11e8 <main+0x88>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getuid@plt>
lea    0xe3a(%rip),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %eax,%ecx
mov    $0xbadc0ded,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%union.sigval = type { i8* }
%struct.sigaction = type { i32 }
@SIG_IGN = global i32 0
@__const.main.value = %union.sigval { i8* inttoptr (i64 -2401053089477161491 to i8*) }
@SIGUSR1 = global i32 0
@.str = [121 x i8] c"rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_QUEUE, si_pid=%u, si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\0A\00"
@.str.1 = [23 x i8] c"+++ exited with 0 +++\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = alloca %union.sigval
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
%6 = load i32, i32* @SIG_IGN
store i32 %6, i32* %5
%7 = bitcast %union.sigval* %3 to i8*
%8 = call i32 (...) @getpid()
store i32 %8, i32* %4
%9 = load i32, i32* @SIGUSR1
%10 = call i32 @sigaction(i32 %9, %struct.sigaction* %2, i32* null)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 77, i32* %1
br label %31
13: ; preds = %0
%14 = load i32, i32* %4
%15 = load i32, i32* @SIGUSR1
%16 = getelementptr inbounds %union.sigval, %union.sigval* %3, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = call i32 @sigqueue(i32 %14, i32 %15, i8* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 77, i32* %1
br label %31
21: ; preds = %13
%22 = load i32, i32* %4
%23 = load i32, i32* %4
%24 = call i32 (...) @getuid()
%25 = bitcast %union.sigval* %3 to i32*
%26 = load i32, i32* %25
%27 = bitcast %union.sigval* %3 to i8**
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23, i32 %24, i32 %26, i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %31
31: ; preds = %21, %20, %12
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
%struct.sigaction = type { i32 }
@SIG_IGN = global i32 0
@SIGUSR1 = global i32 0
@.str = [121 x i8] c"rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, si_code=SI_QUEUE, si_pid=%u, si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\0A\00"
@str = [22 x i8] c"+++ exited with 0 +++\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 0
%4 = load i32, i32* @SIG_IGN
store i32 %4, i32* %3
%5 = tail call i32 (...) @getpid()
%6 = load i32, i32* @SIGUSR1
%7 = call i32 @sigaction(i32 %6, %struct.sigaction* %1, i32* null)
%8 = icmp eq i32 %7, -1
br i1 %8, label %17, label %9
9: ; preds = %0
%10 = load i32, i32* @SIGUSR1
%11 = call i32 @sigqueue(i32 %5, i32 %10, i8* inttoptr (i64 -2401053089477161491 to i8*))
%12 = icmp eq i32 %11, -1
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = call i32 (...) @getuid()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([121 x i8], [121 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %5, i32 %14, i32 -1159983635, i8* inttoptr (i64 -2401053089477161491 to i8*))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %9, %0, %13
%18 = phi i32 [ 0, %13 ], [ 77, %0 ], [ 77, %9 ]
ret i32 %18
}