#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_4__ TYPE_1__;

/* Type definitions */
typedef union sigval {
  int dummy;
} sigval;
struct TYPE_4__ {
  int si_signo;
  int /*<<< orphan*/ si_uid;
  int /*<<< orphan*/ si_pid;
  union sigval si_value;
  int /*<<< orphan*/ si_code;
};
typedef TYPE_1__ siginfo_t;
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SI_QUEUE;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
int syscall(int, int /*<<< orphan*/, int, TYPE_1__ *);
int sigqueue(pid_t pid, int sig, const union sigval value) {
  siginfo_t si;
  memset(&si, 0, sizeof si);
  si.si_signo = sig;
  si.si_code = SI_QUEUE;
  si.si_value = value;
  si.si_pid = getpid();
  si.si_uid = getuid();
  return syscall(178, pid, sig, &si);
}


x86 assembly (clang, -O0):
<sigqueue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edx,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0xb2,%edi
lea    -0x28(%rbp),%rcx
call   1060 <syscall@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigqueue>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r15d
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    %ebx,(%rsp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %ebp,0xc(%rsp)
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,0x4(%rsp)
mov    $0xb2,%edi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r14,%rcx
call   1060 <syscall@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%union.sigval = type { i32 }
%struct.TYPE_4__ = type { i32, i32, i32, %union.sigval, i32 }
@SI_QUEUE = global i32 0
define i32 @sigqueue(i32 %0, i32 %1, i32 %2) {
%4 = alloca %union.sigval
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_4__
%8 = getelementptr inbounds %union.sigval, %union.sigval* %4, i32 0, i32 0
store i32 %2, i32* %8
store i32 %0, i32* %5
store i32 %1, i32* %6
%9 = call i32 @memset(%struct.TYPE_4__* %7, i32 0, i32 20)
%10 = load i32, i32* %6
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* @SI_QUEUE
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 4
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 3
%15 = bitcast %union.sigval* %14 to i8*
%16 = bitcast %union.sigval* %4 to i8*
%17 = call i32 (...) @getpid()
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 2
store i32 %17, i32* %18
%19 = call i32 (...) @getuid()
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 1
store i32 %19, i32* %20
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32 @syscall(i32 178, i32 %21, i32 %22, %struct.TYPE_4__* %7)
ret i32 %23
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i32, i32, %union.sigval, i32 }
%union.sigval = type { i32 }
@SI_QUEUE = global i32 0
define i32 @sigqueue(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.TYPE_4__
%5 = bitcast %struct.TYPE_4__* %4 to i8*
%6 = call i32 @memset(%struct.TYPE_4__* %4, i32 0, i32 20)
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 0
store i32 %1, i32* %7
%8 = load i32, i32* @SI_QUEUE
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 4
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 3, i32 0
store i32 %2, i32* %10
%11 = call i32 (...) @getpid()
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 2
store i32 %11, i32* %12
%13 = call i32 (...) @getuid()
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 1
store i32 %13, i32* %14
%15 = call i32 @syscall(i32 178, i32 %0, i32 %1, %struct.TYPE_4__* %4)
ret i32 %15
}