#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 */
char *pathlast(char const *);
int /*<<< orphan*/ xasprintf(char **, char *, char const *, ...);
char *cvspath(const char *prefix, const char *file, int attic) {
  const char *last;
  char *path;
  last = pathlast(file);
  if (attic)
    xasprintf(&path, "%s/%.*sAttic/%s", prefix, (int)(last - file), file, last);
  else
    xasprintf(&path, "%s/%s", prefix, file);
  return (path);
}


x86 assembly (clang, -O0):
<cvspath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <pathlast@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117a <cvspath+0x5a>
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    -0x28(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <xasprintf@plt>
jmp    1194 <cvspath+0x74>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1030 <xasprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvspath>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <pathlast@plt>
test   %ebp,%ebp
je     115e <cvspath+0x3e>
mov    %eax,%ecx
sub    %ebx,%ecx
lea    0xeb9(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %r14,%rdx
mov    %rbx,%r8
mov    %rax,%r9
xor    %eax,%eax
call   1030 <xasprintf@plt>
jmp    1177 <cvspath+0x57>
lea    0xeab(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <xasprintf@plt>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%s/%.*sAttic/%s\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @cvspath(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call i8* @pathlast(i8* %9)
store i8* %10, i8** %7
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = load i8*, i8** %7
%16 = load i8*, i8** %5
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
%21 = load i8*, i8** %5
%22 = load i8*, i8** %7
%23 = call i32 (i8**, i8*, i8*, ...) @xasprintf(i8** %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %20, i8* %21, i8* %22)
br label %28
24: ; preds = %3
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = call i32 (i8**, i8*, i8*, ...) @xasprintf(i8** %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
br label %28
28: ; preds = %24, %13
%29 = load i8*, i8** %8
ret i8* %29
}

LLVM IR (-O2):
@.str = [16 x i8] c"%s/%.*sAttic/%s\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @cvspath(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = tail call i8* @pathlast(i8* %1)
%7 = icmp eq i32 %2, 0
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint i8* %1 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = call i32 (i8**, i8*, i8*, ...) @xasprintf(i8** %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %12, i8* %1, i8* %6)
br label %16
14: ; preds = %3
%15 = call i32 (i8**, i8*, i8*, ...) @xasprintf(i8** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %16
16: ; preds = %14, %8
%17 = load i8*, i8** %4
ret i8* %17
}