#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 *, size_t);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *malloc(size_t);
size_t snprintf(int /*<<< orphan*/ *, int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stdout;
void cutils_cout_char_ptr_print(char *string) {
  size_t string_size = snprintf(NULL, 0, "%s", string);
  size_t buffer_size = string_size * 2;
  char *buffer = malloc(buffer_size);
  cutils_fmtc_repr(buffer, buffer_size, string, string_size);
  fprintf(stdout, "%s\n", buffer);
}


x86 assembly (clang, -O0):
<cutils_cout_char_ptr_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xea3(%rip),%rdx
call   1040 <snprintf@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1030 <cutils_fmtc_repr@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe5b(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutils_cout_char_ptr_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeae(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rax,%r15
lea    (%rax,%rax,1),%rbx
mov    %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <cutils_fmtc_repr@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
mov    %r12,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define void @cutils_cout_char_ptr_print(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @snprintf(i32* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = mul i64 %8, 2
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = load i64, i64* %4
%14 = load i8*, i8** %2
%15 = load i64, i64* %3
%16 = call i32 @cutils_fmtc_repr(i8* %12, i64 %13, i8* %14, i64 %15)
%17 = load i32, i32* @stdout
%18 = load i8*, i8** %5
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define void @cutils_cout_char_ptr_print(i8* %0) {
%2 = tail call i64 @snprintf(i32* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = shl i64 %2, 1
%4 = tail call i8* @malloc(i64 %3)
%5 = tail call i32 @cutils_fmtc_repr(i8* %4, i64 %3, i8* %0, i64 %2)
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret void
}