#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 char *pid_t;

/* Variables and functions */
char *getpid();
int /*<<< orphan*/ printf(char *, char *, char *, char *);
void processChild() {
  pid_t pid = getpid();
  char prefix[] = "ProcessChild: ";
  printf("%s%d %s\n", prefix, pid, "step1");
  printf("%s%d %s\n", prefix, pid, "step2");
  printf("%s%d %s\n", prefix, pid, "step3");
}


x86 assembly (clang, -O0):
<processChild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %rax,-0x8(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x17(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x9(%rbp)
lea    -0x17(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xea5(%rip),%rdi
lea    0xea7(%rip),%rcx
call   1040 <printf@plt>
lea    -0x17(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe8a(%rip),%rdi
lea    0xe92(%rip),%rcx
call   1040 <printf@plt>
lea    -0x17(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe6f(%rip),%rdi
lea    0xe7d(%rip),%rcx
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processChild>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %rax,%rbx
movabs $0x203a646c696843,%rax
mov    %rax,0x7(%rsp)
movabs $0x43737365636f7250,%rax
73 73 43
mov    %rax,(%rsp)
lea    0xeb8(%rip),%r14
lea    0xeba(%rip),%rcx
mov    %rsp,%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0xea8(%rip),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0xe99(%rip),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.processChild.prefix = [15 x i8] c"ProcessChild: \00"
@.str = [9 x i8] c"%s%d %s\0A\00"
@.str.1 = [6 x i8] c"step1\00"
@.str.2 = [6 x i8] c"step2\00"
@.str.3 = [6 x i8] c"step3\00"
define void @processChild() {
%1 = alloca i8*
%2 = alloca [15 x i8]
%3 = call i8* (...) @getpid()
store i8* %3, i8** %1
%4 = bitcast [15 x i8]* %2 to i8*
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%6 = load i8*, i8** %1
%7 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%9 = load i8*, i8** %1
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%12 = load i8*, i8** %1
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.processChild.prefix = [15 x i8] c"ProcessChild: \00"
@.str = [9 x i8] c"%s%d %s\0A\00"
@.str.1 = [6 x i8] c"step1\00"
@.str.2 = [6 x i8] c"step2\00"
@.str.3 = [6 x i8] c"step3\00"
define void @processChild() {
%1 = alloca [15 x i8]
%2 = tail call i8* (...) @getpid()
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}