#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*/ memset(char *, char, int);
int main(int argc, const char *argv[]) {
  char *p = malloc(1024 - 8);
  char *p2 = malloc(1024 - 8);
  char *p3 = malloc(1024 - 8);
  memset(p, 'A', 1024 - 8);
  memset(p2, 'B', 1024 - 8);
  memset(p3, 'C', 1024 - 8);
  p2[1024 - 8] = '\0';
  free(p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3f8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x3f8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x3f8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x41,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    $0x42,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    $0x43,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x3f8(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x3f8,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x3f8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x3f8,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x41,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x42,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    $0x43,%esi
mov    $0x3f8,%edx
call   1040 <memset@plt>
movb   $0x0,0x3f8(%rbx)
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = call i8* @malloc(i32 1016)
store i8* %8, i8** %5
%9 = call i8* @malloc(i32 1016)
store i8* %9, i8** %6
%10 = call i8* @malloc(i32 1016)
store i8* %10, i8** %7
%11 = load i8*, i8** %5
%12 = call i32 @memset(i8* %11, i8 signext 65, i32 1016)
%13 = load i8*, i8** %6
%14 = call i32 @memset(i8* %13, i8 signext 66, i32 1016)
%15 = load i8*, i8** %7
%16 = call i32 @memset(i8* %15, i8 signext 67, i32 1016)
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 1016
store i8 0, i8* %18
%19 = load i8*, i8** %5
%20 = call i32 @free(i8* %19)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(1016) i8* @malloc(i32 1016)
%4 = tail call dereferenceable_or_null(1016) i8* @malloc(i32 1016)
%5 = tail call dereferenceable_or_null(1016) i8* @malloc(i32 1016)
%6 = tail call i32 @memset(i8* %3, i8 signext 65, i32 1016)
%7 = tail call i32 @memset(i8* %4, i8 signext 66, i32 1016)
%8 = tail call i32 @memset(i8* %5, i8 signext 67, i32 1016)
%9 = getelementptr inbounds i8, i8* %4, i64 1016
store i8 0, i8* %9
%10 = tail call i32 @free(i8* %3)
ret i32 0
}