#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 */
long atol(char *);
int /*<<< orphan*/ printf(char *, ...);
int syscall(int, long);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf(
        "test_sys_zombify: Not enough arguments, supply a pid to play with\n");
    return -1;
  }
  long pid = atol(argv[1]);
  if (pid == 0) {
    printf("test_sys_zombify: pid conversion from string to int failed\n");
    return -1;
  }
  printf("test_sys_zombify: Trying sys call %d on pid %d\n", 290, (int)pid);
  int result = syscall(290, pid);
  if (result == -1) {
    printf("test_sys_zombify: pid %d not found, result == %d\n", (int)pid,
           result);
  } else {
    printf("test_sys_zombify: Zombify Return code for pid %d is %d\n", (int)pid,
           result);
  }
  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     116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <main+0x70>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <main+0xde>
mov    -0x18(%rbp),%rax
mov    %eax,%edx
lea    0xed2(%rip),%rdi
mov    $0x122,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    $0x122,%edi
call   1040 <syscall@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11f0 <main+0xc0>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xd7>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    118f <main+0x4f>
mov    0x8(%rsi),%rdi
call   1060 <atol@plt>
test   %rax,%rax
je     1198 <main+0x58>
mov    %rax,%rbx
lea    0xea0(%rip),%rdi
xor    %ebp,%ebp
mov    $0x122,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x122,%edi
mov    %rbx,%rsi
call   1050 <syscall@plt>
cmp    $0xffffffff,%eax
je     11ab <main+0x6b>
lea    0xed9(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
jmp    11bb <main+0x7b>
lea    0xf3f(%rip),%rdi
jmp    119f <main+0x5f>
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
jmp    11c2 <main+0x82>
lea    0xe7e(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"test_sys_zombify: Not enough arguments, supply a pid to play with\0A\00"
@.str.1 = [60 x i8] c"test_sys_zombify: pid conversion from string to int failed\0A\00"
@.str.2 = [48 x i8] c"test_sys_zombify: Trying sys call %d on pid %d\0A\00"
@.str.3 = [50 x i8] c"test_sys_zombify: pid %d not found, result == %d\0A\00"
@.str.4 = [56 x i8] c"test_sys_zombify: Zombify Return code for pid %d is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
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 %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @atol(i8* %15)
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
21: ; preds = %12
%22 = load i64, i64* %6
%23 = trunc i64 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 290, i32 %23)
%25 = load i64, i64* %6
%26 = call i32 @syscall(i32 290, i64 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %21
%30 = load i64, i64* %6
%31 = trunc i64 %30 to i32
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %32)
br label %39
34: ; preds = %21
%35 = load i64, i64* %6
%36 = trunc i64 %35 to i32
%37 = load i32, i32* %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i32 %36, i32 %37)
br label %39
39: ; preds = %34, %29
store i32 0, i32* %3
br label %40
40: ; preds = %39, %19, %10
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str.2 = [48 x i8] c"test_sys_zombify: Trying sys call %d on pid %d\0A\00"
@.str.3 = [50 x i8] c"test_sys_zombify: pid %d not found, result == %d\0A\00"
@.str.4 = [56 x i8] c"test_sys_zombify: Zombify Return code for pid %d is %d\0A\00"
@str = [59 x i8] c"test_sys_zombify: pid conversion from string to int failed\00"
@str.5 = [66 x i8] c"test_sys_zombify: Not enough arguments, supply a pid to play with\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.5, i64 0, i64 0))
br label %22
6: ; preds = %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 %11, label %13
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
br label %22
13: ; preds = %6
%14 = trunc i64 %9 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 290, i32 %14)
%16 = tail call i32 @syscall(i32 290, i64 %9)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 -1)
br label %22
20: ; preds = %13
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i32 %14, i32 %16)
br label %22
22: ; preds = %11, %20, %18, %4
%23 = phi i32 [ -1, %4 ], [ -1, %11 ], [ 0, %20 ], [ 0, %18 ]
ret i32 %23
}