#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*/ printf(char *, char *, char *);
int main(void) {
  char *x = NULL, *y = NULL;
  printf("before malloc(): x = %p, y = %p\n", x, y);
  x = malloc(123 * sizeof(char));
  y = malloc(456 * sizeof(char));
  printf("after malloc(): x = %p, y = %p\n", x, y);
  free(x);
  free(y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x7b,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1c8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe93(%rip),%rdi
call   1040 <printf@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
lea    0xec5(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <printf@plt>
mov    $0x7b,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x1c8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xebc(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <printf@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):
@.str = [33 x i8] c"before malloc(): x = %p, y = %p\0A\00"
@.str.1 = [32 x i8] c"after malloc(): x = %p, y = %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
store i8* null, i8** %3
%4 = load i8*, i8** %2
%5 = load i8*, i8** %3
%6 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
%7 = call i8* @malloc(i32 123)
store i8* %7, i8** %2
%8 = call i8* @malloc(i32 456)
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10)
%12 = load i8*, i8** %2
%13 = call i32 @free(i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"before malloc(): x = %p, y = %p\0A\00"
@.str.1 = [32 x i8] c"after malloc(): x = %p, y = %p\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* null, i8* null)
%2 = tail call dereferenceable_or_null(123) i8* @malloc(i32 123)
%3 = tail call dereferenceable_or_null(456) i8* @malloc(i32 456)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3)
%5 = tail call i32 @free(i8* %2)
%6 = tail call i32 @free(i8* %3)
ret i32 0
}