#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 uid_t;
struct stat {
  int st_uid;
};
struct passwd {
  char *pw_name;
};
typedef size_t ssize_t;
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
struct passwd *getpwuid(int);
size_t readlink(char *, char *, int);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send_proc_file(int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ stat(char *, struct stat *);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void get_active_processes(char *pids, int clientfd) {
  char *cur = pids;
  char *end = strchr(cur, '\0');
  char buff[250];
  char path_buff[250];
  char *proc_root = "/proc/";
  int proc_root_size = strlen(proc_root);
  strncpy(path_buff, "/proc/", proc_root_size + 1);
  char *rest_of_path = path_buff + proc_root_size;
  while (cur != NULL && cur < end) {
    char *delim = strchr(cur, ' ');
    char *next;
    if (delim == NULL) {
      next = NULL;
    } else {
      *delim = '\0';
      next = delim + 1;
    }
    int cur_len = strlen(cur);
    snprintf(rest_of_path, cur_len + 2, "%s/", cur);
    char *path_basename = rest_of_path + cur_len + 1;
    send(clientfd, "PID(", 4, 0);
    send(clientfd, cur, cur_len, 0);
    send(clientfd, ")", 1, 0);
    send(clientfd, "\n", 1, 0);
    char *cwd = "cwd";
    strncpy(path_basename, cwd, strlen(cwd) + 1);
    ssize_t len = readlink(path_buff, buff, sizeof(buff) - 1);
    buff[len] = '\0';
    send(clientfd, buff, strlen(buff), 0);
    send(clientfd, "\n", 1, 0);
    char *exe = "exe";
    strncpy(path_basename, exe, strlen(exe) + 1);
    len = readlink(path_buff, buff, sizeof(buff) - 1);
    buff[len] = '\0';
    send(clientfd, buff, strlen(buff), 0);
    send(clientfd, "\n", 1, 0);
    *path_basename = '\0';
    struct stat st;
    stat(path_buff, &st);
    uid_t uid = st.st_uid;
    snprintf(buff, sizeof(buff), "%u\n", uid);
    send(clientfd, buff, strlen(buff), 0);
    struct passwd *p = getpwuid(uid);
    send(clientfd, p->pw_name, strlen(p->pw_name), 0);
    send(clientfd, "\n", 1, 0);
    char *cmdline = "cmdline";
    strncpy(path_basename, cmdline, strlen(cmdline) + 1);
    send_proc_file(clientfd, path_buff);
    send(clientfd, "\n", 1, 0);
    char *environ = "environ";
    strncpy(path_basename, environ, strlen(environ) + 1);
    send_proc_file(clientfd, path_buff);
    send(clientfd, "\n", 1, 0);
    cur = next;
  }
  send(clientfd, "\0", 1, 0);
}


x86 assembly (clang, -O0):
<get_active_processes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1090 <strchr@plt>
mov    %rax,-0x20(%rbp)
lea    0xe40(%rip),%rax
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x22c(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x22c(%rbp),%edx
add    $0x1,%edx
lea    0xe10(%rip),%rsi
call   1030 <strncpy@plt>
lea    -0x220(%rbp),%rax
movslq -0x22c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x238(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x299(%rbp)
je     1231 <get_active_processes+0xa1>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
setb   %al
mov    %al,-0x299(%rbp)
mov    -0x299(%rbp),%al
test   $0x1,%al
jne    1244 <get_active_processes+0xb4>
jmp    16ab <get_active_processes+0x51b>
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
mov    %rax,-0x240(%rbp)
cmpq   $0x0,-0x240(%rbp)
jne    1277 <get_active_processes+0xe7>
movq   $0x0,-0x248(%rbp)
jmp    1293 <get_active_processes+0x103>
mov    -0x240(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x248(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x24c(%rbp)
mov    -0x238(%rbp),%rdi
mov    -0x24c(%rbp),%esi
add    $0x2,%esi
mov    -0x18(%rbp),%rcx
lea    0xd4a(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
mov    -0x238(%rbp),%rax
movslq -0x24c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x258(%rbp)
mov    -0xc(%rbp),%edi
lea    0xd21(%rip),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x24c(%rbp),%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0xc(%rbp),%edi
lea    0xcfc(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0xc(%rbp),%edi
lea    0xcf2(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xcd5(%rip),%rax
mov    %rax,-0x260(%rbp)
mov    -0x258(%rbp),%rax
mov    %rax,-0x320(%rbp)
mov    -0x260(%rbp),%rax
mov    %rax,-0x318(%rbp)
mov    -0x260(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x320(%rbp),%rdi
mov    -0x318(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0xf9,%edx
call   1040 <readlink@plt>
mov    %rax,-0x268(%rbp)
mov    -0x268(%rbp),%rax
movb   $0x0,-0x120(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x308(%rbp)
lea    -0x120(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x30c(%rbp),%edi
mov    -0x308(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0xc(%rbp),%edi
lea    0xc27(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xc0e(%rip),%rax
mov    %rax,-0x270(%rbp)
mov    -0x258(%rbp),%rax
mov    %rax,-0x300(%rbp)
mov    -0x270(%rbp),%rax
mov    %rax,-0x2f8(%rbp)
mov    -0x270(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x300(%rbp),%rdi
mov    -0x2f8(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0xf9,%edx
call   1040 <readlink@plt>
mov    %rax,-0x268(%rbp)
mov    -0x268(%rbp),%rax
movb   $0x0,-0x120(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2ec(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x2e8(%rbp)
lea    -0x120(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2ec(%rbp),%edi
mov    -0x2e8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0xc(%rbp),%edi
lea    0xb5c(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0x258(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x220(%rbp),%rdi
lea    -0x278(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x278(%rbp),%eax
mov    %eax,-0x27c(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x27c(%rbp),%ecx
mov    $0xfa,%esi
lea    0xb0c(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2dc(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x2d8(%rbp)
lea    -0x120(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2dc(%rbp),%edi
mov    -0x2d8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0x27c(%rbp),%edi
call   1060 <getpwuid@plt>
mov    %rax,-0x288(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2cc(%rbp)
mov    -0x288(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x2c8(%rbp)
mov    -0x288(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
mov    -0x2cc(%rbp),%edi
mov    -0x2c8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0xc(%rbp),%edi
lea    0xa73(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xa62(%rip),%rax
mov    %rax,-0x290(%rbp)
mov    -0x258(%rbp),%rax
mov    %rax,-0x2c0(%rbp)
mov    -0x290(%rbp),%rax
mov    %rax,-0x2b8(%rbp)
mov    -0x290(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2c0(%rbp),%rdi
mov    -0x2b8(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0xc(%rbp),%edi
lea    -0x220(%rbp),%rsi
call   1050 <send_proc_file@plt>
mov    -0xc(%rbp),%edi
lea    0xa00(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0x9f7(%rip),%rax
mov    %rax,-0x298(%rbp)
mov    -0x258(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
mov    -0x298(%rbp),%rax
mov    %rax,-0x2a8(%rbp)
mov    -0x298(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2b0(%rbp),%rdi
mov    -0x2a8(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0xc(%rbp),%edi
lea    -0x220(%rbp),%rsi
call   1050 <send_proc_file@plt>
mov    -0xc(%rbp),%edi
lea    0x98d(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0x248(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    120d <get_active_processes+0x7d>
mov    -0xc(%rbp),%edi
lea    0x979(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_active_processes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
call   1070 <strlen@plt>
mov    %rax,%r12
lea    0xe4a(%rip),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%edx
lea    0x30(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
test   %r14,%r14
je     149a <get_active_processes+0x30a>
add    %r14,%r12
mov    %r12,0x20(%rsp)
cmp    %r14,%r12
jbe    149a <get_active_processes+0x30a>
movslq %ebp,%rax
add    %rsp,%rax
add    $0x30,%rax
mov    %rax,0x10(%rsp)
add    $0x1,%rax
mov    %rax,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     1230 <get_active_processes+0xa0>
mov    %rax,%r12
movb   $0x0,(%rax)
add    $0x1,%r12
jmp    1233 <get_active_processes+0xa3>
xchg   %ax,%ax
xor    %r12d,%r12d
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
lea    0x2(%rbp),%esi
mov    0x10(%rsp),%rdi
lea    0xdbb(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10a0 <snprintf@plt>
movslq %ebp,%rbx
mov    0x18(%rsp),%rax
lea    (%rax,%rbx,1),%rbp
mov    %r15d,%edi
lea    0xd9f(%rip),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %r15d,%edi
lea    0xd7f(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %r15d,%edi
lea    0xd75(%rip),%r13
mov    %r13,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xd55(%rip),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbp,%rdi
mov    %rbp,0x28(%rsp)
mov    %r14,%rsi
call   1030 <strncpy@plt>
lea    0x30(%rsp),%rdi
lea    0x130(%rsp),%r14
mov    %r14,%rsi
mov    $0xf9,%edx
call   1040 <readlink@plt>
movb   $0x0,0x130(%rsp,%rax,1)
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xcec(%rip),%r13
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <strncpy@plt>
lea    0x30(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0xf9,%edx
call   1040 <readlink@plt>
movb   $0x0,0x130(%rsp,%rax,1)
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %r15d,%edi
lea    0xc9e(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    0x10(%rsp),%rax
movb   $0x0,0x1(%rax,%rbx,1)
mov    %r13,%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
mov    0x8(%rsp),%ebp
mov    %r14,%rdi
mov    $0xfa,%esi
lea    0xc66(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <snprintf@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %ebp,%edi
call   1060 <getpwuid@plt>
mov    (%rax),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %r15d,%edi
lea    0xc1d(%rip),%r14
mov    %r14,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xc09(%rip),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1050 <send_proc_file@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xbd2(%rip),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1050 <send_proc_file@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
test   %r12,%r12
je     149a <get_active_processes+0x30a>
mov    %r12,%r14
cmp    0x20(%rsp),%r12
jb     1210 <get_active_processes+0x80>
lea    0xb8d(%rip),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.passwd = type { i8* }
@.str = [7 x i8] c"/proc/\00"
@.str.1 = [4 x i8] c"%s/\00"
@.str.2 = [5 x i8] c"PID(\00"
@.str.3 = [2 x i8] c")\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [4 x i8] c"cwd\00"
@.str.6 = [4 x i8] c"exe\00"
@.str.7 = [4 x i8] c"%u\0A\00"
@.str.8 = [8 x i8] c"cmdline\00"
@.str.9 = [8 x i8] c"environ\00"
@.str.10 = [2 x i8] zeroinitializer
define void @get_active_processes(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [250 x i8]
%8 = alloca [250 x i8]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i8*
%19 = alloca %struct.stat
%20 = alloca i32
%21 = alloca %struct.passwd*
%22 = alloca i8*
%23 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%24 = load i8*, i8** %3
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = call i8* @strchr(i8* %25, i8 signext 0)
store i8* %26, i8** %6
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %9
%27 = load i8*, i8** %9
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %10
%29 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
%32 = call i32 @strncpy(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%34 = load i32, i32* %10
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8* %36, i8** %11
br label %37
37: ; preds = %56, %2
%38 = load i8*, i8** %5
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i8*, i8** %5
%42 = load i8*, i8** %6
%43 = icmp ult i8* %41, %42
br label %44
44: ; preds = %40, %37
%45 = phi i1 [ false, %37 ], [ %43, %40 ]
br i1 %45, label %46, label %164
46: ; preds = %44
%47 = load i8*, i8** %5
%48 = call i8* @strchr(i8* %47, i8 signext 32)
store i8* %48, i8** %12
%49 = load i8*, i8** %12
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %52
51: ; preds = %46
store i8* null, i8** %13
br label %56
52: ; preds = %46
%53 = load i8*, i8** %12
store i8 0, i8* %53
%54 = load i8*, i8** %12
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** %13
br label %56
56: ; preds = %52, %51
%57 = load i8*, i8** %5
%58 = call i32 @strlen(i8* %57)
store i32 %58, i32* %14
%59 = load i8*, i8** %11
%60 = load i32, i32* %14
%61 = add nsw i32 %60, 2
%62 = load i8*, i8** %5
%63 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %59, i32 %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %62)
%64 = load i8*, i8** %11
%65 = load i32, i32* %14
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8* %68, i8** %15
%69 = load i32, i32* %4
%70 = call i32 @send(i32 %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 0)
%71 = load i32, i32* %4
%72 = load i8*, i8** %5
%73 = load i32, i32* %14
%74 = call i32 @send(i32 %71, i8* %72, i32 %73, i32 0)
%75 = load i32, i32* %4
%76 = call i32 @send(i32 %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 0)
%77 = load i32, i32* %4
%78 = call i32 @send(i32 %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %16
%79 = load i8*, i8** %15
%80 = load i8*, i8** %16
%81 = load i8*, i8** %16
%82 = call i32 @strlen(i8* %81)
%83 = add nsw i32 %82, 1
%84 = call i32 @strncpy(i8* %79, i8* %80, i32 %83)
%85 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%86 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%87 = call i64 @readlink(i8* %85, i8* %86, i32 249)
store i64 %87, i64* %17
%88 = load i64, i64* %17
%89 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 %88
store i8 0, i8* %89
%90 = load i32, i32* %4
%91 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%92 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%93 = call i32 @strlen(i8* %92)
%94 = call i32 @send(i32 %90, i8* %91, i32 %93, i32 0)
%95 = load i32, i32* %4
%96 = call i32 @send(i32 %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %18
%97 = load i8*, i8** %15
%98 = load i8*, i8** %18
%99 = load i8*, i8** %18
%100 = call i32 @strlen(i8* %99)
%101 = add nsw i32 %100, 1
%102 = call i32 @strncpy(i8* %97, i8* %98, i32 %101)
%103 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%104 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%105 = call i64 @readlink(i8* %103, i8* %104, i32 249)
store i64 %105, i64* %17
%106 = load i64, i64* %17
%107 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 %106
store i8 0, i8* %107
%108 = load i32, i32* %4
%109 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%110 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%111 = call i32 @strlen(i8* %110)
%112 = call i32 @send(i32 %108, i8* %109, i32 %111, i32 0)
%113 = load i32, i32* %4
%114 = call i32 @send(i32 %113, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%115 = load i8*, i8** %15
store i8 0, i8* %115
%116 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%117 = call i32 @stat(i8* %116, %struct.stat* %19)
%118 = getelementptr inbounds %struct.stat, %struct.stat* %19, i32 0, i32 0
%119 = load i32, i32* %118
store i32 %119, i32* %20
%120 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%121 = load i32, i32* %20
%122 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %120, i32 250, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %121)
%123 = load i32, i32* %4
%124 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%125 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%126 = call i32 @strlen(i8* %125)
%127 = call i32 @send(i32 %123, i8* %124, i32 %126, i32 0)
%128 = load i32, i32* %20
%129 = call %struct.passwd* @getpwuid(i32 %128)
store %struct.passwd* %129, %struct.passwd** %21
%130 = load i32, i32* %4
%131 = load %struct.passwd*, %struct.passwd** %21
%132 = getelementptr inbounds %struct.passwd, %struct.passwd* %131, i32 0, i32 0
%133 = load i8*, i8** %132
%134 = load %struct.passwd*, %struct.passwd** %21
%135 = getelementptr inbounds %struct.passwd, %struct.passwd* %134, i32 0, i32 0
%136 = load i8*, i8** %135
%137 = call i32 @strlen(i8* %136)
%138 = call i32 @send(i32 %130, i8* %133, i32 %137, i32 0)
%139 = load i32, i32* %4
%140 = call i32 @send(i32 %139, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %22
%141 = load i8*, i8** %15
%142 = load i8*, i8** %22
%143 = load i8*, i8** %22
%144 = call i32 @strlen(i8* %143)
%145 = add nsw i32 %144, 1
%146 = call i32 @strncpy(i8* %141, i8* %142, i32 %145)
%147 = load i32, i32* %4
%148 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%149 = call i32 @send_proc_file(i32 %147, i8* %148)
%150 = load i32, i32* %4
%151 = call i32 @send(i32 %150, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8** %23
%152 = load i8*, i8** %15
%153 = load i8*, i8** %23
%154 = load i8*, i8** %23
%155 = call i32 @strlen(i8* %154)
%156 = add nsw i32 %155, 1
%157 = call i32 @strncpy(i8* %152, i8* %153, i32 %156)
%158 = load i32, i32* %4
%159 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%160 = call i32 @send_proc_file(i32 %158, i8* %159)
%161 = load i32, i32* %4
%162 = call i32 @send(i32 %161, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%163 = load i8*, i8** %13
store i8* %163, i8** %5
br label %37
164: ; preds = %44
%165 = load i32, i32* %4
%166 = call i32 @send(i32 %165, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 1, i32 0)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.passwd = type { i8* }
@.str = [7 x i8] c"/proc/\00"
@.str.1 = [4 x i8] c"%s/\00"
@.str.2 = [5 x i8] c"PID(\00"
@.str.3 = [2 x i8] c")\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [4 x i8] c"cwd\00"
@.str.6 = [4 x i8] c"exe\00"
@.str.7 = [4 x i8] c"%u\0A\00"
@.str.8 = [8 x i8] c"cmdline\00"
@.str.9 = [8 x i8] c"environ\00"
@.str.10 = [2 x i8] zeroinitializer
define void @get_active_processes(i8* %0, i32 %1) {
%3 = alloca [250 x i8]
%4 = alloca [250 x i8]
%5 = alloca %struct.stat
%6 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %0)
%7 = getelementptr i8, i8* %0, i64 %6
%8 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 0
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = add nsw i32 %10, 1
%12 = call i32 @strncpy(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 %13
%15 = icmp ne i8* %0, null
%16 = icmp ugt i8* %7, %0
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %18, label %79
18: ; preds = %2
%19 = bitcast %struct.stat* %5 to i8*
%20 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%21 = getelementptr inbounds i8, i8* %14, i64 1
br label %22
22: ; preds = %18, %28
%23 = phi i8* [ %0, %18 ], [ %29, %28 ]
%24 = call i8* @strchr(i8* %23, i8 signext 32)
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %26
26: ; preds = %22
store i8 0, i8* %24
%27 = getelementptr inbounds i8, i8* %24, i64 1
br label %28
28: ; preds = %22, %26
%29 = phi i8* [ %27, %26 ], [ null, %22 ]
%30 = call i32 @strlen(i8* %23)
%31 = add nsw i32 %30, 2
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%33 = sext i32 %30 to i64
%34 = getelementptr inbounds i8, i8* %21, i64 %33
%35 = call i32 @send(i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 0)
%36 = call i32 @send(i32 %1, i8* %23, i32 %30, i32 0)
%37 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 0)
%38 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%39 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%40 = add nsw i32 %39, 1
%41 = call i32 @strncpy(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = call i64 @readlink(i8* %9, i8* %8, i32 249)
%43 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 %42
store i8 0, i8* %43
%44 = call i32 @strlen(i8* %8)
%45 = call i32 @send(i32 %1, i8* %8, i32 %44, i32 0)
%46 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%47 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%48 = add nsw i32 %47, 1
%49 = call i32 @strncpy(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %48)
%50 = call i64 @readlink(i8* %9, i8* %8, i32 249)
%51 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 %50
store i8 0, i8* %51
%52 = call i32 @strlen(i8* %8)
%53 = call i32 @send(i32 %1, i8* %8, i32 %52, i32 0)
%54 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
store i8 0, i8* %34
%55 = call i32 @stat(i8* %9, %struct.stat* %5)
%56 = load i32, i32* %20
%57 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 250, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %56)
%58 = call i32 @strlen(i8* %8)
%59 = call i32 @send(i32 %1, i8* %8, i32 %58, i32 0)
%60 = call %struct.passwd* @getpwuid(i32 %56)
%61 = getelementptr inbounds %struct.passwd, %struct.passwd* %60, i64 0, i32 0
%62 = load i8*, i8** %61
%63 = call i32 @strlen(i8* %62)
%64 = call i32 @send(i32 %1, i8* %62, i32 %63, i32 0)
%65 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%66 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%67 = add nsw i32 %66, 1
%68 = call i32 @strncpy(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %67)
%69 = call i32 @send_proc_file(i32 %1, i8* %9)
%70 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%71 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%72 = add nsw i32 %71, 1
%73 = call i32 @strncpy(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 %72)
%74 = call i32 @send_proc_file(i32 %1, i8* %9)
%75 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%76 = icmp ne i8* %29, null
%77 = icmp ult i8* %29, %7
%78 = select i1 %76, i1 %77, i1 false
br i1 %78, label %22, label %79
79: ; preds = %28, %2
%80 = call i32 @send(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 1, i32 0)
ret void
}