#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 timeval {
  scalar_t__ tv_usec;
};

/* Variables and functions */
char *getWorkingDirectory();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, scalar_t__);
void testGetWorkingDirectory(void) {
  struct timeval stop, start;
  gettimeofday(&start, NULL);
  char *cwd = getWorkingDirectory();
  gettimeofday(&stop, NULL);
  printf("testGetWorkingDirectory : %s : %lu ms\n", cwd,
         stop.tv_usec - start.tv_usec);
}


x86 assembly (clang, -O0):
<testGetWorkingDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    $0x0,%al
call   1050 <getWorkingDirectory@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
sub    -0x10(%rbp),%rdx
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testGetWorkingDirectory>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
xor    %eax,%eax
call   1050 <getWorkingDirectory@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x8(%rsp),%rdx
sub    (%rsp),%rdx
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i64 }
@.str = [39 x i8] c"testGetWorkingDirectory : %s : %lu ms\0A\00"
define void @testGetWorkingDirectory() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca i8*
%4 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%5 = call i8* (...) @getWorkingDirectory()
store i8* %5, i8** %3
%6 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%7 = load i8*, i8** %3
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%11 = load i64, i64* %10
%12 = sub nsw i64 %9, %11
%13 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %7, i64 %12)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
@.str = [39 x i8] c"testGetWorkingDirectory : %s : %lu ms\0A\00"
define void @testGetWorkingDirectory() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%6 = tail call i8* (...) @getWorkingDirectory()
%7 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%11 = load i64, i64* %10
%12 = sub nsw i64 %9, %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %6, i64 %12)
ret void
}