#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*/ printDec(unsigned int);
int /*<<< orphan*/ printString(char *);
int /*<<< orphan*/ ps_sys(char **, unsigned int *);
void ps() {
  unsigned int processPID[16];
  char *names[16];
  printString("PIDs\n");
  ps_sys(names, processPID);
  int i = 0;
  while (processPID[i] != 0) {
    printString(names[i]);
    printString(" - ");
    printDec(processPID[i]);
    printString("\n");
    i++;
  }
  return;
}


x86 assembly (clang, -O0):
<ps>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printString@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <ps_sys@plt>
movl   $0x0,-0xc4(%rbp)
movslq -0xc4(%rbp),%rax
cmpl   $0x0,-0x40(%rbp,%rax,4)
je     11c3 <ps+0x93>
movslq -0xc4(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
call   1030 <printString@plt>
lea    0xe78(%rip),%rdi
call   1030 <printString@plt>
movslq -0xc4(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edi
call   1050 <printDec@plt>
lea    0xe5a(%rip),%rdi
call   1030 <printString@plt>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    1161 <ps+0x31>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ps>:
push   %r15
push   %r14
push   %rbx
sub    $0xc0,%rsp
lea    0xebd(%rip),%rdi
call   1030 <printString@plt>
lea    0x40(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <ps_sys@plt>
cmpl   $0x0,(%rsp)
je     119d <ps+0x6d>
xor    %ebx,%ebx
lea    0xea2(%rip),%r14
lea    0xe99(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    0x40(%rsp,%rbx,2),%rdi
call   1030 <printString@plt>
mov    %r14,%rdi
call   1030 <printString@plt>
mov    (%rsp,%rbx,1),%edi
call   1050 <printDec@plt>
mov    %r15,%rdi
call   1030 <printString@plt>
cmpl   $0x0,0x4(%rsp,%rbx,1)
lea    0x4(%rbx),%rbx
jne    1170 <ps+0x40>
add    $0xc0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"PIDs\0A\00"
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @ps() {
%1 = alloca [16 x i32]
%2 = alloca [16 x i8*]
%3 = alloca i32
%4 = call i32 @printString(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%7 = call i32 @ps_sys(i8** %5, i32* %6)
store i32 0, i32* %3
br label %8
8: ; preds = %14, %0
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %8
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @printString(i8* %18)
%20 = call i32 @printString(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i32 @printDec(i32 %24)
%26 = call i32 @printString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"PIDs\0A\00"
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @ps() {
%1 = alloca [16 x i32]
%2 = alloca [16 x i8*]
%3 = bitcast [16 x i32]* %1 to i8*
%4 = bitcast [16 x i8*]* %2 to i8*
%5 = tail call i32 @printString(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%8 = call i32 @ps_sys(i8** %6, i32* %7)
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %0, %11
%12 = phi i64 [ %21, %11 ], [ 0, %0 ]
%13 = phi i32* [ %22, %11 ], [ %7, %0 ]
%14 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 %12
%15 = load i8*, i8** %14
%16 = call i32 @printString(i8* %15)
%17 = call i32 @printString(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %13
%19 = call i32 @printDec(i32 %18)
%20 = call i32 @printString(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = add nuw i64 %12, 1
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %11
25: ; preds = %11, %0
ret void
}