#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 */
scalar_t__ _fatstoragepart(char **, char const **);
char *malloc(scalar_t__);
scalar_t__ strlen(char const *);
char *fatstoragepath(const char *path) {
  char *start, *dst;
  start = malloc(strlen(path) + 1);
  for (dst = start; _fatstoragepart(&dst, &path) && *path;) {
    path++;
    dst++;
  }
  return start;
}


x86 assembly (clang, -O0):
<fatstoragepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <_fatstoragepart@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     118c <fatstoragepath+0x5c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    119c <fatstoragepath+0x6c>
jmp    11b9 <fatstoragepath+0x89>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115d <fatstoragepath+0x2d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fatstoragepath>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,(%rsp)
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <_fatstoragepart@plt>
test   %rax,%rax
je     1197 <fatstoragepath+0x67>
lea    0x8(%rsp),%r15
mov    %rsp,%rbx
nopl   (%rax)
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1197 <fatstoragepath+0x67>
add    $0x1,%rax
mov    %rax,(%rsp)
addq   $0x1,0x8(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <_fatstoragepart@plt>
test   %rax,%rax
jne    1170 <fatstoragepath+0x40>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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