#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 /*<<< orphan*/ sival_int;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ printf(char *);
int sig(int /*<<< orphan*/, int /*<<< orphan*/, union sigval);
int main(int argc, char **argv) {
  int ret;
  pid_t pid;
  union sigval sg;
  if (argc != 2) {
    printf("args error\n");
    exit(1);
  }
  pid = atoi(argv[1]);
  sg.sival_int = getpid();
  ret = sig(pid, SIGUSR1, sg);
  if (ret != 0) {
    printf("Send error\n");
  } else {
    printf("Done!\n");
  }
  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     1186 <main+0x36>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%edx
call   1070 <sig@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d2 <main+0x82>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
jmp    11de <main+0x8e>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    1197 <main+0x47>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x2e79(%rip),%rcx
mov    (%rcx),%esi
mov    %ebx,%edi
mov    %eax,%edx
call   1070 <sig@plt>
test   %eax,%eax
lea    0xe7d(%rip),%rax
lea    0xe7c(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%union.sigval = type { i32 }
@.str = [12 x i8] c"args error\0A\00"
@SIGUSR1 = global i32 0
@.str.1 = [12 x i8] c"Send error\0A\00"
@.str.2 = [7 x i8] c"Done!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %union.sigval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
%19 = call i32 (...) @getpid()
%20 = bitcast %union.sigval* %8 to i32*
store i32 %19, i32* %20
%21 = load i32, i32* %7
%22 = load i32, i32* @SIGUSR1
%23 = getelementptr inbounds %union.sigval, %union.sigval* %8, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @sig(i32 %21, i32 %22, i32 %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %14
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %32
30: ; preds = %14
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@str = [6 x i8] c"Done!\00"
@str.3 = [11 x i8] c"Send error\00"
@str.4 = [11 x i8] c"args error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 (...) @getpid()
%12 = load i32, i32* @SIGUSR1
%13 = tail call i32 @sig(i32 %10, i32 %12, i32 %11)
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.3, i64 0, i64 0)
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
ret i32 0
}