#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 */

/* Variables and functions */
int /*<<< orphan*/ *getcwd(char *, size_t);
scalar_t__ mu__malloc(char *, int, size_t);
scalar_t__ mu__realloc(char *, int, char *, size_t);
char *getCurrentDirectory(void) {
  char *buffer = NULL;
  size_t bufferLength = 64;
  buffer = (char *)mu__malloc(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/path.c",
      278, bufferLength);
  while (getcwd(buffer, bufferLength) == NULL) {
    bufferLength *= 2;
    buffer = (char *)mu__realloc(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/path.c",
        281, buffer, bufferLength);
  }
  return buffer;
}


x86 assembly (clang, -O0):
<getCurrentDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x40,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xead(%rip),%rdi
mov    $0x116,%esi
call   1050 <mu__malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <getcwd@plt>
cmp    $0x0,%rax
jne    11a6 <getCurrentDirectory+0x76>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6d(%rip),%rdi
mov    $0x119,%esi
call   1030 <mu__realloc@plt>
mov    %rax,-0x8(%rbp)
jmp    1161 <getCurrentDirectory+0x31>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCurrentDirectory>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rdi
mov    $0x40,%ebx
mov    $0x40,%edx
mov    $0x116,%esi
call   1050 <mu__malloc@plt>
mov    %rax,%r14
mov    $0x40,%esi
mov    %rax,%rdi
call   1040 <getcwd@plt>
test   %rax,%rax
jne    1199 <getCurrentDirectory+0x69>
lea    0xe94(%rip),%r15
nopl   0x0(%rax)
add    %rbx,%rbx
mov    %r15,%rdi
mov    $0x119,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <mu__realloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <getcwd@plt>
test   %rax,%rax
je     1170 <getCurrentDirectory+0x40>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/path.c\00"
define i8* @getCurrentDirectory() {
%1 = alloca i8*
%2 = alloca i64
store i8* null, i8** %1
store i64 64, i64* %2
%3 = load i64, i64* %2
%4 = call i64 @mu__malloc(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 278, i64 %3)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %1
br label %6
6: ; preds = %11, %0
%7 = load i8*, i8** %1
%8 = load i64, i64* %2
%9 = call i32* @getcwd(i8* %7, i64 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i64, i64* %2
%13 = mul i64 %12, 2
store i64 %13, i64* %2
%14 = load i8*, i8** %1
%15 = load i64, i64* %2
%16 = call i64 @mu__realloc(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 281, i8* %14, i64 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %1
br label %6
18: ; preds = %6
%19 = load i8*, i8** %1
ret i8* %19
}

LLVM IR (-O2):
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/path.c\00"
define i8* @getCurrentDirectory() {
%1 = tail call i64 @mu__malloc(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 278, i64 64)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32* @getcwd(i8* %2, i64 64)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %15
5: ; preds = %0, %5
%6 = phi i8* [ %10, %5 ], [ %2, %0 ]
%7 = phi i64 [ %8, %5 ], [ 64, %0 ]
%8 = shl i64 %7, 1
%9 = tail call i64 @mu__realloc(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 281, i8* %6, i64 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32* @getcwd(i8* %10, i64 %8)
%12 = icmp eq i32* %11, null
br i1 %12, label %5, label %13
13: ; preds = %5
%14 = inttoptr i64 %9 to i8*
br label %15
15: ; preds = %13, %0
%16 = phi i8* [ %2, %0 ], [ %14, %13 ]
ret i8* %16
}