#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  char *x = malloc(10);
  write(1, "A\n", 2);
  x[00] = 'A';
  x[01] = 'B';
  x[10] = 'W';
  x[11] = 'X';
  x[12] = 'Y';
  x[13] = 'Z';
  write(1, "B\n", 2);
  free(x);
  write(1, "C\n", 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
lea    0xea7(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    -0x10(%rbp),%rax
movb   $0x41,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x42,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x57,0xa(%rax)
mov    -0x10(%rbp),%rax
movb   $0x58,0xb(%rax)
mov    -0x10(%rbp),%rax
movb   $0x59,0xc(%rax)
mov    -0x10(%rbp),%rax
movb   $0x5a,0xd(%rax)
mov    $0x1,%edi
lea    0xe65(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
lea    0xe49(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xa,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xebb(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1040 <write@plt>
movw   $0x4241,(%rbx)
movl   $0x5a595857,0xa(%rbx)
lea    0xe9c(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1040 <write@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe81(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1040 <write@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"A\0A\00"
@.str.1 = [3 x i8] c"B\0A\00"
@.str.2 = [3 x i8] c"C\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i8* @malloc(i32 10)
store i8* %3, i8** %2
%4 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
store i8 65, i8* %6
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8 66, i8* %8
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 10
store i8 87, i8* %10
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 11
store i8 88, i8* %12
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 12
store i8 89, i8* %14
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 13
store i8 90, i8* %16
%17 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%18 = load i8*, i8** %2
%19 = call i32 @free(i8* %18)
%20 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"A\0A\00"
@.str.1 = [3 x i8] c"B\0A\00"
@.str.2 = [3 x i8] c"C\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%2 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
store i8 65, i8* %1
%3 = getelementptr inbounds i8, i8* %1, i64 1
store i8 66, i8* %3
%4 = getelementptr inbounds i8, i8* %1, i64 10
store i8 87, i8* %4
%5 = getelementptr inbounds i8, i8* %1, i64 11
store i8 88, i8* %5
%6 = getelementptr inbounds i8, i8* %1, i64 12
store i8 89, i8* %6
%7 = getelementptr inbounds i8, i8* %1, i64 13
store i8 90, i8* %7
%8 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%9 = tail call i32 @free(i8* %1)
%10 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
ret i32 0
}