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

/* Variables and functions */
int /*<<< orphan*/ atol(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
long syscall(int, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Please include the pid as a command line parameter.\n");
    return 1;
  }
  pid_t pid = atol(argv[1]);
  long timeslice = syscall(287, pid);
  if (timeslice < 0) {
    perror("Failure in quad");
    return 2;
  }
  printf("Success! New timeslice: %ld\n", timeslice);
  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)
jge    117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x11f,%edi
call   1040 <syscall@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    11be <main+0x7e>
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    11d7 <main+0x97>
mov    -0x20(%rbp),%rsi
lea    0xe7c(%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   %rbx
cmp    $0x1,%edi
jg     1169 <main+0x19>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    1196 <main+0x46>
mov    0x8(%rsi),%rdi
call   1060 <atol@plt>
mov    $0x11f,%edi
mov    %eax,%esi
call   1050 <syscall@plt>
test   %rax,%rax
js     119a <main+0x4a>
lea    0xe86(%rip),%rdi
xor    %ebx,%ebx
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe5f(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%ebx
jmp    1196 <main+0x46>

LLVM IR (-O0):
@.str = [53 x i8] c"Please include the pid as a command line parameter.\0A\00"
@.str.1 = [16 x i8] c"Failure in quad\00"
@.str.2 = [29 x i8] c"Success! New timeslice: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %26
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atol(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i64 @syscall(i32 287, i32 %17)
store i64 %18, i64* %7
%19 = load i64, i64* %7
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %26
23: ; preds = %12
%24 = load i64, i64* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 %24)
store i32 0, i32* %3
br label %26
26: ; preds = %23, %21, %10
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"Failure in quad\00"
@.str.2 = [29 x i8] c"Success! New timeslice: %ld\0A\00"
@str = [52 x i8] c"Please include the pid as a command line parameter.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
br label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atol(i8* %8)
%10 = tail call i64 @syscall(i32 287, i32 %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 %10)
br label %16
16: ; preds = %12, %14, %4
%17 = phi i32 [ 1, %4 ], [ 2, %12 ], [ 0, %14 ]
ret i32 %17
}