#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("Not enough arguments, supply a pid to play with\n");
    return -1;
  }
  long pid = atol(argv[1]);
  if (pid == 0) {
    printf("pid conversion from string to int failed\n");
    return -1;
  }
  printf("trying sys call %d on pid %d\n", 289, pid);
  int result = syscall(289, pid);
  if (result == -1) {
    printf("pid %d not found, result == %d\n", pid, result);
  } else {
    printf("new timeslice for pid %d is %d\n", 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    1208 <main+0xd8>
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    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <main+0xd8>
mov    -0x18(%rbp),%rdx
lea    0xeb0(%rip),%rdi
mov    $0x121,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    $0x121,%edi
call   1040 <syscall@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11ec <main+0xbc>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1201 <main+0xd1>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe9f(%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    1191 <main+0x51>
mov    0x8(%rsi),%rdi
call   1060 <atol@plt>
test   %rax,%rax
je     119a <main+0x5a>
mov    %rax,%rbx
lea    0xea0(%rip),%rdi
xor    %ebp,%ebp
mov    $0x121,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x121,%edi
mov    %rbx,%rsi
call   1050 <syscall@plt>
cmp    $0xffffffff,%eax
je     11ad <main+0x6d>
lea    0xeb4(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
jmp    11be <main+0x7e>
lea    0xeef(%rip),%rdi
jmp    11a1 <main+0x61>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
jmp    11c5 <main+0x85>
lea    0xe6a(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
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 = [49 x i8] c"Not enough arguments, supply a pid to play with\0A\00"
@.str.1 = [42 x i8] c"pid conversion from string to int failed\0A\00"
@.str.2 = [30 x i8] c"trying sys call %d on pid %d\0A\00"
@.str.3 = [32 x i8] c"pid %d not found, result == %d\0A\00"
@.str.4 = [32 x i8] c"new timeslice 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 ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %37
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 ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %37
21: ; preds = %12
%22 = load i64, i64* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 289, i64 %22)
%24 = load i64, i64* %6
%25 = call i32 @syscall(i32 289, i64 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load i64, i64* %6
%30 = load i32, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %29, i32 %30)
br label %36
32: ; preds = %21
%33 = load i64, i64* %6
%34 = load i32, i32* %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i64 %33, i32 %34)
br label %36
36: ; preds = %32, %28
store i32 0, i32* %3
br label %37
37: ; preds = %36, %19, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str.2 = [30 x i8] c"trying sys call %d on pid %d\0A\00"
@.str.3 = [32 x i8] c"pid %d not found, result == %d\0A\00"
@.str.4 = [32 x i8] c"new timeslice for pid %d is %d\0A\00"
@str = [41 x i8] c"pid conversion from string to int failed\00"
@str.5 = [48 x i8] c"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 ([48 x i8], [48 x i8]* @str.5, i64 0, i64 0))
br label %21
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 ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %21
13: ; preds = %6
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 289, i64 %9)
%15 = tail call i32 @syscall(i32 289, i64 %9)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %9, i32 -1)
br label %21
19: ; preds = %13
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i64 %9, i32 %15)
br label %21
21: ; preds = %11, %19, %17, %4
%22 = phi i32 [ -1, %4 ], [ -1, %11 ], [ 0, %19 ], [ 0, %17 ]
ret i32 %22
}