#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 */
char *calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ print_str(char *);
int main() {
  char *buf = calloc(6, 1);
  char *buf2 = calloc(6, 1);
  buf[0] = 'h';
  buf[1] = 'e';
  buf[2] = 'l';
  buf[3] = 'l';
  buf[4] = 'o';
  buf[5] = 0;
  buf2[0] = 'w';
  buf2[1] = 'o';
  buf2[2] = 'r';
  buf2[3] = 'l';
  buf2[4] = 'd';
  buf2[5] = 0;
  print_str(buf);
  print_str(buf2);
  free(buf);
  free(buf2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x6,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x6,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x68,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x65,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x6c,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0x6c,0x3(%rax)
mov    -0x10(%rbp),%rax
movb   $0x6f,0x4(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x18(%rbp),%rax
movb   $0x77,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x6f,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x72,0x2(%rax)
mov    -0x18(%rbp),%rax
movb   $0x6c,0x3(%rax)
mov    -0x18(%rbp),%rax
movb   $0x64,0x4(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <print_str@plt>
mov    -0x18(%rbp),%rdi
call   1040 <print_str@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x6,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    $0x6,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
movl   $0x6c6c6568,(%r14)
movb   $0x6f,0x4(%r14)
movl   $0x6c726f77,(%rax)
movb   $0x64,0x4(%rax)
mov    %r14,%rdi
call   1040 <print_str@plt>
mov    %rbx,%rdi
call   1040 <print_str@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i8* @calloc(i32 6, i32 1)
store i8* %4, i8** %2
%5 = call i8* @calloc(i32 6, i32 1)
store i8* %5, i8** %3
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
store i8 104, i8* %7
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8 101, i8* %9
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 2
store i8 108, i8* %11
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 3
store i8 108, i8* %13
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 4
store i8 111, i8* %15
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 5
store i8 0, i8* %17
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 119, i8* %19
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8 111, i8* %21
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8 114, i8* %23
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 3
store i8 108, i8* %25
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 4
store i8 100, i8* %27
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 5
store i8 0, i8* %29
%30 = load i8*, i8** %2
%31 = call i32 @print_str(i8* %30)
%32 = load i8*, i8** %3
%33 = call i32 @print_str(i8* %32)
%34 = load i8*, i8** %2
%35 = call i32 @free(i8* %34)
%36 = load i8*, i8** %3
%37 = call i32 @free(i8* %36)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(6) i8* @calloc(i32 6, i32 1)
%2 = tail call dereferenceable_or_null(6) i8* @calloc(i32 6, i32 1)
store i8 104, i8* %1
%3 = getelementptr inbounds i8, i8* %1, i64 1
store i8 101, i8* %3
%4 = getelementptr inbounds i8, i8* %1, i64 2
store i8 108, i8* %4
%5 = getelementptr inbounds i8, i8* %1, i64 3
store i8 108, i8* %5
%6 = getelementptr inbounds i8, i8* %1, i64 4
store i8 111, i8* %6
store i8 119, i8* %2
%7 = getelementptr inbounds i8, i8* %2, i64 1
store i8 111, i8* %7
%8 = getelementptr inbounds i8, i8* %2, i64 2
store i8 114, i8* %8
%9 = getelementptr inbounds i8, i8* %2, i64 3
store i8 108, i8* %9
%10 = getelementptr inbounds i8, i8* %2, i64 4
store i8 100, i8* %10
%11 = tail call i32 @print_str(i8* %1)
%12 = tail call i32 @print_str(i8* %2)
%13 = tail call i32 @free(i8* %1)
%14 = tail call i32 @free(i8* %2)
ret i32 0
}