#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 *, ...);
unsigned int syscall(int, long, long);
int main(int argc, char *argv[]) {
  if (argc != 3)
    return -1;
  long tpid = atol(argv[1]);
  long vpid = atol(argv[2]);
  if (tpid == 0 || vpid == 0)
    return -1;
  unsigned int retval = syscall(287, tpid, vpid);
  if (retval >= 0) {
    printf("Succes!! Stole %d ms from victim and its children!\n", retval);
  } else {
    printf("Failed!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     115c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1194 <main+0x64>
cmpq   $0x0,-0x20(%rbp)
jne    11a0 <main+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <main+0xba>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x11f,%edi
call   1040 <syscall@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jb     11d5 <main+0xa5>
mov    -0x24(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xb3>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebp
cmp    $0x3,%edi
jne    1182 <main+0x52>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atol@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
call   1050 <atol@plt>
test   %r14,%r14
je     1182 <main+0x52>
test   %rax,%rax
je     1182 <main+0x52>
mov    $0x11f,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <syscall@plt>
lea    0xe89(%rip),%rdi
xor    %ebp,%ebp
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Succes!! Stole %d ms from victim and its children!\0A\00"
@.str.1 = [9 x i8] c"Failed!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
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, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %39
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 i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i64 @atol(i8* %19)
store i64 %20, i64* %7
%21 = load i64, i64* %6
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %12
%24 = load i64, i64* %7
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23, %12
store i32 -1, i32* %3
br label %39
27: ; preds = %23
%28 = load i64, i64* %6
%29 = load i64, i64* %7
%30 = call i32 @syscall(i32 287, i64 %28, i64 %29)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp uge i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32, i32* %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %38
36: ; preds = %27
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
store i32 0, i32* %3
br label %39
39: ; preds = %38, %26, %11
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [52 x i8] c"Succes!! Stole %d ms from victim and its children!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @atol(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i64 @atol(i8* %9)
%11 = icmp eq i64 %7, 0
%12 = icmp eq i64 %10, 0
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = tail call i32 @syscall(i32 287, i64 %7, i64 %10)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %4, %2
%18 = phi i32 [ -1, %2 ], [ 0, %14 ], [ -1, %4 ]
ret i32 %18
}