#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 */
struct passwd {
  char *pw_name;
};
typedef int pid_t;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ createsharedmemory();
int getpid();
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ makekey();
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ releasememory();
int /*<<< orphan*/ reportruntimes();
int /*<<< orphan*/ startbubble();
int /*<<< orphan*/ startinsert();
int /*<<< orphan*/ startqsort();
int /*<<< orphan*/ startselection();
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ waitforchildren();
int /*<<< orphan*/ writedata();
int main(int argc, char **argv) {
  pid_t processid = getpid();
  struct passwd *passwd = getpwuid(getuid());
  printf("Master process %d running for %s\n", processid, passwd->pw_name);
  makekey();
  createsharedmemory();
  writedata();
  startbubble();
  startselection();
  startinsert();
  startqsort();
  system("ps u");
  waitforchildren();
  reportruntimes();
  releasememory();
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   10a0 <getuid@plt>
mov    %eax,%edi
call   1080 <getpwuid@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xdcd(%rip),%rdi
call   10d0 <printf@plt>
mov    $0x0,%al
call   10e0 <makekey@plt>
mov    $0x0,%al
call   1100 <createsharedmemory@plt>
mov    $0x0,%al
call   1090 <writedata@plt>
mov    $0x0,%al
call   10f0 <startbubble@plt>
mov    $0x0,%al
call   1040 <startselection@plt>
mov    $0x0,%al
call   10b0 <startinsert@plt>
mov    $0x0,%al
call   1070 <startqsort@plt>
lea    0xdb2(%rip),%rdi
call   10c0 <system@plt>
mov    $0x0,%al
call   1110 <waitforchildren@plt>
mov    $0x0,%al
call   1030 <reportruntimes@plt>
mov    $0x0,%al
call   1060 <releasememory@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10a0 <getuid@plt>
mov    %eax,%edi
call   1080 <getpwuid@plt>
mov    (%rax),%rdx
lea    0xdee(%rip),%rdi
mov    %ebx,%esi
call   10d0 <printf@plt>
xor    %eax,%eax
call   10e0 <makekey@plt>
xor    %eax,%eax
call   1100 <createsharedmemory@plt>
xor    %eax,%eax
call   1090 <writedata@plt>
xor    %eax,%eax
call   10f0 <startbubble@plt>
xor    %eax,%eax
call   1040 <startselection@plt>
xor    %eax,%eax
call   10b0 <startinsert@plt>
xor    %eax,%eax
call   1070 <startqsort@plt>
lea    0xdd1(%rip),%rdi
call   10c0 <system@plt>
xor    %eax,%eax
call   1110 <waitforchildren@plt>
xor    %eax,%eax
call   1030 <reportruntimes@plt>
xor    %eax,%eax
call   1060 <releasememory@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
@.str = [34 x i8] c"Master process %d running for %s\0A\00"
@.str.1 = [5 x i8] c"ps u\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @getpid()
store i32 %8, i32* %6
%9 = call i32 (...) @getuid()
%10 = call %struct.passwd* @getpwuid(i32 %9)
store %struct.passwd* %10, %struct.passwd** %7
%11 = load i32, i32* %6
%12 = load %struct.passwd*, %struct.passwd** %7
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %14)
%16 = call i32 (...) @makekey()
%17 = call i32 (...) @createsharedmemory()
%18 = call i32 (...) @writedata()
%19 = call i32 (...) @startbubble()
%20 = call i32 (...) @startselection()
%21 = call i32 (...) @startinsert()
%22 = call i32 (...) @startqsort()
%23 = call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (...) @waitforchildren()
%25 = call i32 (...) @reportruntimes()
%26 = call i32 (...) @releasememory()
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@.str = [34 x i8] c"Master process %d running for %s\0A\00"
@.str.1 = [5 x i8] c"ps u\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (...) @getuid()
%5 = tail call %struct.passwd* @getpwuid(i32 %4)
%6 = getelementptr inbounds %struct.passwd, %struct.passwd* %5, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %3, i8* %7)
%9 = tail call i32 (...) @makekey()
%10 = tail call i32 (...) @createsharedmemory()
%11 = tail call i32 (...) @writedata()
%12 = tail call i32 (...) @startbubble()
%13 = tail call i32 (...) @startselection()
%14 = tail call i32 (...) @startinsert()
%15 = tail call i32 (...) @startqsort()
%16 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 (...) @waitforchildren()
%18 = tail call i32 (...) @reportruntimes()
%19 = tail call i32 (...) @releasememory()
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}