#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 */
int /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
char *getNum(int const, char const **);
int /*<<< orphan*/ printStatus(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(const int argc, char const **argv) {
  const char *PID = getNum(argc, argv);
  if (PID) {
    char path[100];
    strcpy(path, "/proc/");
    strcat(path, PID);
    strcat(path, "/status");
    if (access(path, F_OK) != 0) {
      printf("No Process found having this PID\n");
      return -1;
    } else
      printStatus(path);
  } else
    printf("Enter Number\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <getNum@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1203 <main+0xa3>
lea    -0x80(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x80(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x80(%rbp),%rdi
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
je     11f5 <main+0x95>
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1216 <main+0xb6>
lea    -0x80(%rbp),%rdi
call   1040 <printStatus@plt>
jmp    120f <main+0xaf>
lea    0xe27(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
call   1080 <getNum@plt>
test   %rax,%rax
je     11c9 <main+0x69>
mov    %rax,%rbx
lea    0xe85(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
lea    0xe6f(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1060 <access@plt>
test   %rax,%rax
je     11d7 <main+0x77>
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    11e1 <main+0x81>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
jmp    11df <main+0x7f>
mov    %rsp,%rdi
call   1050 <printStatus@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"/proc/\00"
@.str.1 = [8 x i8] c"/status\00"
@F_OK = global i32 0
@.str.2 = [34 x i8] c"No Process found having this PID\0A\00"
@.str.3 = [14 x i8] c"Enter Number\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i8* @getNum(i32 %8, i8** %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %31
13: ; preds = %2
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = call i32 @strcat(i8* %16, i8* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%22 = load i32, i32* @F_OK
%23 = call i64 @access(i8* %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %13
%26 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %34
27: ; preds = %13
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%29 = call i32 @printStatus(i8* %28)
br label %30
30: ; preds = %27
br label %33
31: ; preds = %2
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %30
store i32 0, i32* %3
br label %34
34: ; preds = %33, %25
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [7 x i8] c"/proc/\00"
@.str.1 = [8 x i8] c"/status\00"
@F_OK = global i32 0
@str = [13 x i8] c"Enter Number\00"
@str.4 = [33 x i8] c"No Process found having this PID\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [100 x i8]
%4 = tail call i8* @getNum(i32 %0, i8** %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcat(i8* %7, i8* %4)
%10 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @F_OK
%12 = call i64 @access(i8* %7, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 @printStatus(i8* %7)
br label %20
16: ; preds = %6
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.4, i64 0, i64 0))
br label %20
18: ; preds = %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %14, %16
%21 = phi i32 [ -1, %16 ], [ 0, %14 ], [ 0, %18 ]
ret i32 %21
}