#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 scalar_t__ wchar_t;

/* Variables and functions */
scalar_t__ _fatstoragepartlong(scalar_t__ **, scalar_t__ const **);
scalar_t__ *malloc(int);
int wcslen(scalar_t__ const *);
wchar_t *fatstoragepathlong(const wchar_t *path) {
  wchar_t *start, *dst;
  start = malloc(sizeof(wchar_t) * (wcslen(path) + 1));
  for (dst = start; _fatstoragepartlong(&dst, &path) && *path;) {
    path++;
    dst++;
  }
  return start;
}


x86 assembly (clang, -O0):
<fatstoragepathlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <wcslen@plt>
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <_fatstoragepartlong@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     118e <fatstoragepathlong+0x5e>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    119e <fatstoragepathlong+0x6e>
jmp    11bb <fatstoragepathlong+0x8b>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1161 <fatstoragepathlong+0x31>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fatstoragepathlong>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,(%rsp)
call   1040 <wcslen@plt>
lea    0x8(,%rax,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <_fatstoragepartlong@plt>
test   %rax,%rax
je     1198 <fatstoragepathlong+0x68>
lea    0x8(%rsp),%r15
mov    %rsp,%rbx
mov    (%rsp),%rax
cmpq   $0x0,(%rax)
je     1198 <fatstoragepathlong+0x68>
add    $0x8,%rax
mov    %rax,(%rsp)
addq   $0x8,0x8(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <_fatstoragepartlong@plt>
test   %rax,%rax
jne    1170 <fatstoragepathlong+0x40>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64* @fatstoragepathlong(i64* %0) {
%2 = alloca i64*
%3 = alloca i64*
%4 = alloca i64*
store i64* %0, i64** %2
%5 = load i64*, i64** %2
%6 = call i32 @wcslen(i64* %5)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call i64* @malloc(i32 %10)
store i64* %11, i64** %3
%12 = load i64*, i64** %3
store i64* %12, i64** %4
br label %13
13: ; preds = %22, %1
%14 = call i64 @_fatstoragepartlong(i64** %4, i64** %2)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i64*, i64** %2
%18 = load i64, i64* %17
%19 = icmp ne i64 %18, 0
br label %20
20: ; preds = %16, %13
%21 = phi i1 [ false, %13 ], [ %19, %16 ]
br i1 %21, label %22, label %27
22: ; preds = %20
%23 = load i64*, i64** %2
%24 = getelementptr inbounds i64, i64* %23, i32 1
store i64* %24, i64** %2
%25 = load i64*, i64** %4
%26 = getelementptr inbounds i64, i64* %25, i32 1
store i64* %26, i64** %4
br label %13
27: ; preds = %20
%28 = load i64*, i64** %3
ret i64* %28
}

LLVM IR (-O2):
define i64* @fatstoragepathlong(i64* %0) {
%2 = alloca i64*
%3 = alloca i64*
store i64* %0, i64** %2
%4 = bitcast i64** %3 to i8*
%5 = tail call i32 @wcslen(i64* %0)
%6 = shl i32 %5, 3
%7 = add i32 %6, 8
%8 = tail call i64* @malloc(i32 %7)
store i64* %8, i64** %3
%9 = call i64 @_fatstoragepartlong(i64** %3, i64** %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %1, %15
%12 = load i64*, i64** %2
%13 = load i64, i64* %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = getelementptr inbounds i64, i64* %12, i64 1
store i64* %16, i64** %2
%17 = load i64*, i64** %3
%18 = getelementptr inbounds i64, i64* %17, i64 1
store i64* %18, i64** %3
%19 = call i64 @_fatstoragepartlong(i64** %3, i64** %2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %15, %1
ret i64* %8
}