#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ getPath(char *, char *);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int main(void) {
  FILE *expectedResultFile;
  char myPath[1000] = {'\0'};
  char myPath2[1000] = {'\0'};
  char home[1000] = {'\0'};
  strcpy(home, getenv("HOME"));
  getPath(myPath, "SEARCHDIR");
  printf("%s\n", myPath);
  getPath(myPath2, "MAILBOX");
  printf("%s\n", myPath2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xbf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1060 <memset@plt>
lea    -0x7f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1060 <memset@plt>
lea    -0xbe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1060 <memset@plt>
lea    -0xbe0(%rbp),%rax
mov    %rax,-0xbe8(%rbp)
lea    0xe50(%rip),%rdi
call   1030 <getenv@plt>
mov    -0xbe8(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x400(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <getPath@plt>
lea    -0x400(%rbp),%rsi
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x7f0(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1070 <getPath@plt>
lea    -0x7f0(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xbf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xbd0,%rsp
lea    0x7e0(%rsp),%r15
mov    $0x3e8,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x3f0(%rsp),%r14
mov    $0x3e8,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rbx
mov    $0x3e8,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe5d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xe4c(%rip),%rsi
mov    %r15,%rdi
call   1070 <getPath@plt>
lea    0xe47(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
lea    0xe39(%rip),%rsi
mov    %r14,%rdi
call   1070 <getPath@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xbd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [10 x i8] c"SEARCHDIR\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [8 x i8] c"MAILBOX\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
store i32 0, i32* %1
%6 = bitcast [1000 x i8]* %3 to i8*
%7 = bitcast [1000 x i8]* %4 to i8*
%8 = bitcast [1000 x i8]* %5 to i8*
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%10 = call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @strcpy(i8* %9, i32 %10)
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%13 = call i32 @getPath(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%17 = call i32 @getPath(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [10 x i8] c"SEARCHDIR\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [8 x i8] c"MAILBOX\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcpy(i8* %6, i32 %7)
%9 = call i32 @getPath(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%11 = call i32 @getPath(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
}