#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*/ cutils_fmtc_repr(char *, size_t, char const *, size_t);
char *realloc(char *, size_t);
size_t strlen(char const *);
bool cutils_cdar_DynamicArray_char_ptr_format(const char **i, char **b,
                                              size_t *s) {
  size_t l = strlen(*i);
  if (*s < l + 3)
    if (!(*b = realloc(*b, (*s = l * 2 + 3))))
      return false;
  cutils_fmtc_repr(*b, *s, *i, l);
  return true;
}


x86 assembly (clang, -O0):
<cutils_cdar_DynamicArray_char_ptr_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
add    $0x3,%rcx
cmp    %rcx,%rax
jae    11ad <cutils_cdar_DynamicArray_char_ptr_format+0x7d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
shl    $0x1,%rsi
add    $0x3,%rsi
mov    -0x20(%rbp),%rax
mov    %rsi,(%rax)
call   1050 <realloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11a8 <cutils_cdar_DynamicArray_char_ptr_format+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <cutils_cdar_DynamicArray_char_ptr_format+0xa2>
jmp    11ad <cutils_cdar_DynamicArray_char_ptr_format+0x7d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <cutils_fmtc_repr@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutils_cdar_DynamicArray_char_ptr_format>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
mov    (%rdi),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r14
mov    (%r15),%rsi
add    $0x3,%rax
mov    0x0(%r13),%rdi
cmp    %rax,%rsi
jae    1183 <cutils_cdar_DynamicArray_char_ptr_format+0x53>
lea    (%r14,%r14,1),%rsi
add    $0x3,%rsi
mov    %rsi,(%r15)
call   1050 <realloc@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
je     1195 <cutils_cdar_DynamicArray_char_ptr_format+0x65>
mov    %rax,%rdi
mov    (%r15),%rsi
mov    (%r12),%rbx
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <cutils_fmtc_repr@plt>
mov    $0x1,%eax
jmp    1197 <cutils_cdar_DynamicArray_char_ptr_format+0x67>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @cutils_cdar_DynamicArray_char_ptr_format(i8** %0, i8** %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca i64
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i64* %2, i64** %7
%9 = load i8**, i8*** %5
%10 = load i8*, i8** %9
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %8
%12 = load i64*, i64** %7
%13 = load i64, i64* %12
%14 = load i64, i64* %8
%15 = add i64 %14, 3
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %3
%18 = load i8**, i8*** %6
%19 = load i8*, i8** %18
%20 = load i64, i64* %8
%21 = mul i64 %20, 2
%22 = add i64 %21, 3
%23 = load i64*, i64** %7
store i64 %22, i64* %23
%24 = call i8* @realloc(i8* %19, i64 %22)
%25 = load i8**, i8*** %6
store i8* %24, i8** %25
%26 = icmp ne i8* %24, null
br i1 %26, label %28, label %27
27: ; preds = %17
store i32 0, i32* %4
br label %38
28: ; preds = %17
br label %29
29: ; preds = %28, %3
%30 = load i8**, i8*** %6
%31 = load i8*, i8** %30
%32 = load i64*, i64** %7
%33 = load i64, i64* %32
%34 = load i8**, i8*** %5
%35 = load i8*, i8** %34
%36 = load i64, i64* %8
%37 = call i32 @cutils_fmtc_repr(i8* %31, i64 %33, i8* %35, i64 %36)
store i32 1, i32* %4
br label %38
38: ; preds = %29, %27
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
define i32 @cutils_cdar_DynamicArray_char_ptr_format(i8** nocapture %0, i8** nocapture %1, i64* nocapture %2) {
%4 = load i8*, i8** %0
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = load i64, i64* %2
%7 = add i64 %5, 3
%8 = icmp ult i64 %6, %7
%9 = load i8*, i8** %1
br i1 %8, label %10, label %18
10: ; preds = %3
%11 = shl i64 %5, 1
%12 = add i64 %11, 3
store i64 %12, i64* %2
%13 = tail call i8* @realloc(i8* %9, i64 %12)
store i8* %13, i8** %1
%14 = icmp eq i8* %13, null
br i1 %14, label %23, label %15
15: ; preds = %10
%16 = load i64, i64* %2
%17 = load i8*, i8** %0
br label %18
18: ; preds = %3, %15
%19 = phi i8* [ %17, %15 ], [ %4, %3 ]
%20 = phi i64 [ %16, %15 ], [ %6, %3 ]
%21 = phi i8* [ %13, %15 ], [ %9, %3 ]
%22 = tail call i32 @cutils_fmtc_repr(i8* %21, i64 %20, i8* %19, i64 %5)
br label %23
23: ; preds = %10, %18
%24 = phi i32 [ 1, %18 ], [ 0, %10 ]
ret i32 %24
}