#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 {
  int sival_int;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SIGINT;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int sigqueue(int, int /*<<< orphan*/, union sigval);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage:%s pid\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  pid_t pid = atoi(argv[1]);
  sleep(2);
  union sigval mysigval;
  mysigval.sival_int = 100;
  printf("sending SIGINT signal to %d......\n", pid);
  if (sigqueue(pid, SIGINT, mysigval) == -1) {
    perror("sigqueue error");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ba <main+0x4a>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    $0x2,%edi
call   1090 <sleep@plt>
movl   $0x64,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
call   1050 <sigqueue@plt>
cmp    $0xffffffff,%eax
jne    1221 <main+0xb1>
lea    0xe23(%rip),%rdi
call   1060 <perror@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11b7 <main+0x47>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    $0x2,%edi
call   1090 <sleep@plt>
lea    0xe7c(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x64,%edx
call   1050 <sigqueue@plt>
cmp    $0xffffffff,%eax
je     11d1 <main+0x61>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe36(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11dd <main+0x6d>
lea    0xe59(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%union.sigval = type { i32 }
@stderr = global i32 0
@.str = [14 x i8] c"usage:%s pid\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [35 x i8] c"sending SIGINT signal to %d......\0A\00"
@SIGINT = global i32 0
@.str.2 = [15 x i8] c"sigqueue error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %union.sigval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = call i32 @sleep(i32 2)
%24 = bitcast %union.sigval* %7 to i32*
store i32 100, i32* %24
%25 = load i32, i32* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
%28 = load i32, i32* @SIGINT
%29 = getelementptr inbounds %union.sigval, %union.sigval* %7, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @sigqueue(i32 %27, i32 %28, i32 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %37
33: ; preds = %18
%34 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"usage:%s pid\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [35 x i8] c"sending SIGINT signal to %d......\0A\00"
@SIGINT = global i32 0
@.str.2 = [15 x i8] c"sigqueue error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32 @sleep(i32 2)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%16 = load i32, i32* @SIGINT
%17 = tail call i32 @sigqueue(i32 %13, i32 %16, i32 100)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %10
%20 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %10
ret i32 0
}