#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 *grealloc(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
char *fullColor(char *prefix, char *str) {
  static char *fulls;
  static int allocated;
  int len = strlen(prefix) + strlen(str) + 3;
  if (len >= allocated) {
    allocated = len + 10;
    fulls = grealloc(fulls, allocated);
  }
  sprintf(fulls, "/%s/%s", prefix, str);
  return fulls;
}


x86 assembly (clang, -O0):
<fullColor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    0x2edd(%rip),%eax
jl     1196 <fullColor+0x66>
mov    -0x14(%rbp),%eax
add    $0xa,%eax
mov    %eax,0x2ecb(%rip)
mov    0x2ebc(%rip),%rdi
mov    0x2ebe(%rip),%esi
call   1030 <grealloc@plt>
mov    %rax,0x2eaa(%rip)
mov    0x2ea3(%rip),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe54(%rip),%rsi
call   1050 <sprintf@plt>
mov    0x2e88(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fullColor>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbx,1),%ecx
add    $0x3,%ecx
cmp    0x2ef2(%rip),%ecx
jge    1161 <fullColor+0x31>
mov    0x2ee1(%rip),%rdi
jmp    1184 <fullColor+0x54>
add    %ebx,%eax
add    $0xd,%eax
mov    %eax,0x2edc(%rip)
mov    0x2ecd(%rip),%rdi
mov    %eax,%esi
call   1030 <grealloc@plt>
mov    %rax,%rdi
mov    %rax,0x2ebc(%rip)
lea    0xe75(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
mov    0x2ea3(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@fullColor.fulls = internal global i8* null
@fullColor.allocated = internal global i32 0
@.str = [7 x i8] c"/%s/%s\00"
define i8* @fullColor(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %7, %9
%11 = add nsw i32 %10, 3
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = load i32, i32* @fullColor.allocated
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 10
store i32 %17, i32* @fullColor.allocated
%18 = load i8*, i8** @fullColor.fulls
%19 = load i32, i32* @fullColor.allocated
%20 = call i8* @grealloc(i8* %18, i32 %19)
store i8* %20, i8** @fullColor.fulls
br label %21
21: ; preds = %15, %2
%22 = load i8*, i8** @fullColor.fulls
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i8*, i8** @fullColor.fulls
ret i8* %26
}

LLVM IR (-O2):
@fullColor.fulls = internal unnamed_addr global i8* null
@fullColor.allocated = internal unnamed_addr global i32 0
@.str = [7 x i8] c"/%s/%s\00"
define i8* @fullColor(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, %3
%6 = add nsw i32 %5, 3
%7 = load i32, i32* @fullColor.allocated
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i8*, i8** @fullColor.fulls
br label %15
11: ; preds = %2
%12 = add nsw i32 %5, 13
store i32 %12, i32* @fullColor.allocated
%13 = load i8*, i8** @fullColor.fulls
%14 = tail call i8* @grealloc(i8* %13, i32 %12)
store i8* %14, i8** @fullColor.fulls
br label %15
15: ; preds = %9, %11
%16 = phi i8* [ %10, %9 ], [ %14, %11 ]
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%18 = load i8*, i8** @fullColor.fulls
ret i8* %18
}