#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*/ BinFormat(char, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  char *text = malloc(9);
  BinFormat('A', text);
  printf("%s\n", text);
  BinFormat('B', text);
  printf("%s\n", text);
  BinFormat('C', text);
  printf("%s\n", text);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x9,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x41,%edi
call   1050 <BinFormat@plt>
mov    -0x8(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x42,%edi
call   1050 <BinFormat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x43,%edi
call   1050 <BinFormat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x9,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    $0x41,%edi
mov    %rax,%rsi
call   1050 <BinFormat@plt>
lea    0xeab(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x42,%edi
mov    %rbx,%rsi
call   1050 <BinFormat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x43,%edi
mov    %rbx,%rsi
call   1050 <BinFormat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = call i8* @malloc(i32 9)
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = call i32 @BinFormat(i8 signext 65, i8* %3)
%5 = load i8*, i8** %1
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %1
%8 = call i32 @BinFormat(i8 signext 66, i8* %7)
%9 = load i8*, i8** %1
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %1
%12 = call i32 @BinFormat(i8 signext 67, i8* %11)
%13 = load i8*, i8** %1
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%2 = tail call i32 @BinFormat(i8 signext 65, i8* %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = tail call i32 @BinFormat(i8 signext 66, i8* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = tail call i32 @BinFormat(i8 signext 67, i8* %1)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
ret i32 0
}