#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 {
  long sival_int;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
long extract_long(char *, char *);
scalar_t__ getpid();
scalar_t__ getuid();
int /*<<< orphan*/ helpAndLeave(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, char *, long, long);
int sigqueue(long, long, union sigval);
int main(int argc, char *argv[]) {
  if (argc < 4) {
    helpAndLeave(argv[0], EXIT_FAILURE);
  }
  long pid, signal, data, num_sigs;
  int i;
  union sigval sv;
  num_sigs = 1;
  pid = extract_long(argv[1], "PID");
  signal = extract_long(argv[2], "signal");
  data = extract_long(argv[3], "data argument");
  if (argc > 4) {
    num_sigs = extract_long(argv[4], "num-signals argument");
  }
  printf("%s: PID: %ld, UID %ld\n", argv[0], (long)getpid(), (long)getuid());
  for (i = 0; i < num_sigs; ++i) {
    sv.sival_int = data + i;
    if (sigqueue(pid, signal, sv) == -1) {
      pexit("sigqueue");
    }
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11b5 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
call   1080 <helpAndLeave@plt>
movq   $0x1,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe34(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe20(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe0f(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1227 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdd8(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    12b8 <main+0x138>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1070 <sigqueue@plt>
cmp    $0xffffffff,%eax
jne    12a5 <main+0x125>
lea    0xda5(%rip),%rdi
call   10a0 <pexit@plt>
jmp    12aa <main+0x12a>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1262 <main+0xe2>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
cmp    $0x3,%edi
jg     11a7 <main+0x27>
mov    0x0(%r13),%rdi
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
call   1080 <helpAndLeave@plt>
mov    0x8(%r13),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,%r14
mov    0x10(%r13),%rdi
lea    0xe3f(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,%r15
mov    0x18(%r13),%rdi
lea    0xe33(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,%rbx
mov    $0x1,%r12d
cmp    $0x5,%ebp
jl     11fe <main+0x7e>
mov    0x20(%r13),%rdi
lea    0xe23(%rip),%rsi
call   1030 <extract_long@plt>
mov    %rax,%r12
mov    0x0(%r13),%r13
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1050 <getuid@plt>
lea    0xe14(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rax,%rcx
call   1060 <printf@plt>
test   %r12,%r12
jle    1267 <main+0xe7>
lea    0xe11(%rip),%rbp
jmp    124a <main+0xca>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r12
je     1267 <main+0xe7>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <sigqueue@plt>
cmp    $0xffffffff,%eax
jne    1240 <main+0xc0>
mov    %rbp,%rdi
call   10a0 <pexit@plt>
jmp    1240 <main+0xc0>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%union.sigval = type { i64 }
@EXIT_FAILURE = global i32 0
@.str = [4 x i8] c"PID\00"
@.str.1 = [7 x i8] c"signal\00"
@.str.2 = [14 x i8] c"data argument\00"
@.str.3 = [21 x i8] c"num-signals argument\00"
@.str.4 = [23 x i8] c"%s: PID: %ld, UID %ld\0A\00"
@.str.5 = [9 x i8] c"sigqueue\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca %union.sigval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @helpAndLeave(i8* %17, i32 %18)
br label %20
20: ; preds = %14, %2
store i64 1, i64* %9
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @extract_long(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i64 %24, i64* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i64 @extract_long(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i64 %28, i64* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i64 @extract_long(i8* %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i64 %32, i64* %8
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 4
br i1 %34, label %35, label %40
35: ; preds = %20
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 4
%38 = load i8*, i8** %37
%39 = call i64 @extract_long(i8* %38, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i64 %39, i64* %9
br label %40
40: ; preds = %35, %20
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i64 (...) @getpid()
%45 = call i64 (...) @getuid()
%46 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %43, i64 %44, i64 %45)
store i32 0, i32* %10
br label %47
47: ; preds = %67, %40
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = load i64, i64* %9
%51 = icmp slt i64 %49, %50
br i1 %51, label %52, label %70
52: ; preds = %47
%53 = load i64, i64* %8
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = add nsw i64 %53, %55
%57 = bitcast %union.sigval* %11 to i64*
store i64 %56, i64* %57
%58 = load i64, i64* %6
%59 = load i64, i64* %7
%60 = getelementptr inbounds %union.sigval, %union.sigval* %11, i32 0, i32 0
%61 = load i64, i64* %60
%62 = call i32 @sigqueue(i64 %58, i64 %59, i64 %61)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %52
%65 = call i32 @pexit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %52
br label %67
67: ; preds = %66
%68 = load i32, i32* %10
%69 = add nsw i32 %68, 1
store i32 %69, i32* %10
br label %47
70: ; preds = %47
%71 = load i32, i32* @EXIT_SUCCESS
%72 = call i32 @exit(i32 %71)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [4 x i8] c"PID\00"
@.str.1 = [7 x i8] c"signal\00"
@.str.2 = [14 x i8] c"data argument\00"
@.str.3 = [21 x i8] c"num-signals argument\00"
@.str.4 = [23 x i8] c"%s: PID: %ld, UID %ld\0A\00"
@.str.5 = [9 x i8] c"sigqueue\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @helpAndLeave(i8* %5, i32 %6)
br label %8
8: ; preds = %4, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @extract_long(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i64 @extract_long(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i64 @extract_long(i8* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp sgt i32 %0, 4
br i1 %18, label %19, label %23
19: ; preds = %8
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = tail call i64 @extract_long(i8* %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %19, %8
%24 = phi i64 [ %22, %19 ], [ 1, %8 ]
%25 = load i8*, i8** %1
%26 = tail call i64 (...) @getpid()
%27 = tail call i64 (...) @getuid()
%28 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %25, i64 %26, i64 %27)
%29 = icmp sgt i64 %24, 0
br i1 %29, label %30, label %40
30: ; preds = %23, %37
%31 = phi i64 [ %38, %37 ], [ 0, %23 ]
%32 = add nsw i64 %31, %17
%33 = tail call i32 @sigqueue(i64 %11, i64 %14, i64 %32)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = tail call i32 @pexit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %30, %35
%38 = add nuw nsw i64 %31, 1
%39 = icmp eq i64 %38, %24
br i1 %39, label %40, label %30
40: ; preds = %37, %23
%41 = load i32, i32* @EXIT_SUCCESS
%42 = tail call i32 @exit(i32 %41)
unreachable
}