#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 getpid();
int getppid();
int /*<<< orphan*/ printf(char *, ...);
int biHelp(char *name, char **args, char **envs) {
  printf("Hello! This is KOrovin SHell.\n");
  printf("My pid:{%d}; my ppid:{%d}\n", getpid(), getppid());
  printf("ARGS:\n");
  char **curargs = args;
  while (*curargs) {
    printf(" %s\n", *curargs);
    curargs++;
  }
  printf("ENVIRONMENTS:\n");
  char **curenv = envs;
  while (*curenv) {
    printf(" %s\n", *curenv);
    curenv++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<biHelp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1050 <getppid@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c0 <biHelp+0x90>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    118c <biHelp+0x5c>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     120a <biHelp+0xda>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    11d6 <biHelp+0xa6>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<biHelp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <getppid@plt>
lea    0xe90(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11b6 <biHelp+0x76>
add    $0x8,%rbx
lea    0xe81(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11a0 <biHelp+0x60>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%rsi
test   %rsi,%rsi
je     11f6 <biHelp+0xb6>
add    $0x8,%r14
lea    0xe46(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%rsi
add    $0x8,%r14
test   %rsi,%rsi
jne    11e0 <biHelp+0xa0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Hello! This is KOrovin SHell.\0A\00"
@.str.1 = [27 x i8] c"My pid:{%d}; my ppid:{%d}\0A\00"
@.str.2 = [7 x i8] c"ARGS:\0A\00"
@.str.3 = [5 x i8] c" %s\0A\00"
@.str.4 = [15 x i8] c"ENVIRONMENTS:\0A\00"
define i32 @biHelp(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @getpid()
%11 = call i32 (...) @getppid()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%14 = load i8**, i8*** %5
store i8** %14, i8*** %7
br label %15
15: ; preds = %19, %3
%16 = load i8**, i8*** %7
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i8**, i8*** %7
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i8**, i8*** %7
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %7
br label %15
25: ; preds = %15
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%27 = load i8**, i8*** %6
store i8** %27, i8*** %8
br label %28
28: ; preds = %32, %25
%29 = load i8**, i8*** %8
%30 = load i8*, i8** %29
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = load i8**, i8*** %8
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i8**, i8*** %8
%37 = getelementptr inbounds i8*, i8** %36, i32 1
store i8** %37, i8*** %8
br label %28
38: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"My pid:{%d}; my ppid:{%d}\0A\00"
@.str.3 = [5 x i8] c" %s\0A\00"
@str = [30 x i8] c"Hello! This is KOrovin SHell.\00"
@str.5 = [6 x i8] c"ARGS:\00"
@str.6 = [14 x i8] c"ENVIRONMENTS:\00"
define i32 @biHelp(i8* nocapture readnone %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 (...) @getppid()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %3, %11
%12 = phi i8* [ %16, %11 ], [ %9, %3 ]
%13 = phi i8** [ %15, %11 ], [ %1, %3 ]
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%15 = getelementptr inbounds i8*, i8** %13, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %11
18: ; preds = %11, %3
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = icmp eq i8* %20, null
br i1 %21, label %29, label %22
22: ; preds = %18, %22
%23 = phi i8* [ %27, %22 ], [ %20, %18 ]
%24 = phi i8** [ %26, %22 ], [ %2, %18 ]
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%26 = getelementptr inbounds i8*, i8** %24, i64 1
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %22
29: ; preds = %22, %18
ret i32 0
}