#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 *);
char *strdup(char *);
int main(void) {
  char *data = calloc(512, sizeof(char));
  char *after_message = calloc(512 / 8, sizeof(char));
  char *msg_1 = strdup("Hey, ");
  char *msg_2 = strdup("Enter your name: ");
  free(msg_2);
  free(msg_1);
  free(after_message);
  free(data);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x40,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe94(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%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    $0x200,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
mov    $0x40,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
lea    0xea0(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,%rbx
lea    0xe97(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Hey, \00"
@.str.1 = [18 x i8] c"Enter your name: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i8* @calloc(i32 512, i32 1)
store i8* %6, i8** %2
%7 = call i8* @calloc(i32 64, i32 1)
store i8* %7, i8** %3
%8 = call i8* @strdup(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
%9 = call i8* @strdup(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @free(i8* %10)
%12 = load i8*, i8** %4
%13 = call i32 @free(i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
%16 = load i8*, i8** %2
%17 = call i32 @free(i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"Hey, \00"
@.str.1 = [18 x i8] c"Enter your name: \00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%2 = tail call dereferenceable_or_null(64) i8* @calloc(i32 64, i32 1)
%3 = tail call dereferenceable_or_null(6) i8* @strdup(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call dereferenceable_or_null(18) i8* @strdup(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @free(i8* %4)
%6 = tail call i32 @free(i8* %3)
%7 = tail call i32 @free(i8* %2)
%8 = tail call i32 @free(i8* %1)
ret i32 0
}