#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
long atol(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int syscall(int, long);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc != 2)
    usage();
  long pid = atol(argv[1]);
  if (pid) {
    printf("test_myjoin: Will be waiting here forever until you DIE \n");
    if (syscall(290, pid) == -1)
      printf("test_myjoin: err... never mind something messed up\n");
  } else
    usage();
  printf("test_myjoin: I AM FREE!!!\n");
  exit(EXIT_SUCCESS);
}


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     1177 <main+0x27>
mov    $0x0,%al
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c7 <main+0x77>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    $0x122,%edi
call   1040 <syscall@plt>
cmp    $0xffffffff,%eax
jne    11c2 <main+0x72>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <main+0x7e>
mov    $0x0,%al
call   1050 <usage@plt>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1160 <main+0x10>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x8(%rbx),%rdi
call   1060 <atol@plt>
test   %rax,%rax
jne    1177 <main+0x27>
xor    %eax,%eax
call   1050 <usage@plt>
jmp    11a4 <main+0x54>
mov    %rax,%rbx
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    $0x122,%edi
mov    %rbx,%rsi
call   1040 <syscall@plt>
cmp    $0xffffffff,%eax
jne    11a4 <main+0x54>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"test_myjoin: Will be waiting here forever until you DIE \0A\00"
@.str.1 = [52 x i8] c"test_myjoin: err... never mind something messed up\0A\00"
@.str.2 = [27 x i8] c"test_myjoin: I AM FREE!!!\0A\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @usage()
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @atol(i8* %14)
store i64 %15, i64* %6
%16 = load i64, i64* %6
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%20 = load i64, i64* %6
%21 = call i32 @syscall(i32 290, i64 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %18
br label %28
26: ; preds = %11
%27 = call i32 (...) @usage()
br label %28
28: ; preds = %26, %25
%29 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @EXIT_SUCCESS
%31 = call i32 @exit(i32 %30)
unreachable
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [26 x i8] c"test_myjoin: I AM FREE!!!\00"
@str.3 = [57 x i8] c"test_myjoin: Will be waiting here forever until you DIE \00"
@str.4 = [51 x i8] c"test_myjoin: err... never mind something messed up\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @atol(i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.3, i64 0, i64 0))
%13 = tail call i32 @syscall(i32 290, i64 %9)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.4, i64 0, i64 0))
br label %19
17: ; preds = %6
%18 = tail call i32 (...) @usage()
br label %19
19: ; preds = %11, %15, %17
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%21 = load i32, i32* @EXIT_SUCCESS
%22 = tail call i32 @exit(i32 %21)
unreachable
}