#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ mysyscall(char *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: %s [pid]\n", argv[0]);
    exit(-1);
  }
  char process_name[16];
  unsigned int pid = (unsigned int)atoi(argv[1]);
  if (mysyscall(process_name, pid) == 0)
    printf("%s\n", process_name);
  else
    printf("Process with pid %u does not exist\n", pid);
  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   $0x2,-0x8(%rbp)
je     117f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <mysyscall@plt>
cmp    $0x0,%rax
jne    11bc <main+0x7c>
lea    -0x20(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11cd <main+0x8d>
mov    -0x24(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1197 <main+0x47>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    %ebx,%esi
call   1030 <mysyscall@plt>
test   %rax,%rax
je     1187 <main+0x37>
lea    0xe95(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    118f <main+0x3f>
mov    %rsp,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    (%rsi),%rsi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Usage: %s [pid]\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [36 x i8] c"Process with pid %u does not exist\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%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 %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @atoi(i8* %19)
%21 = trunc i64 %20 to i32
store i32 %21, i32* %7
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %7
%24 = call i64 @mysyscall(i8* %22, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %32
29: ; preds = %16
%30 = load i32, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %26
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Usage: %s [pid]\0A\00"
@.str.2 = [36 x i8] c"Process with pid %u does not exist\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @atoi(i8* %12)
%14 = trunc i64 %13 to i32
%15 = call i64 @mysyscall(i8* %10, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %9
%18 = call i32 @puts(i8* %10)
br label %21
19: ; preds = %9
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %21
21: ; preds = %19, %17
ret i32 0
}