#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*/ cmalloc_free(int *);
scalar_t__ cmalloc_malloc(int);
int /*<<< orphan*/ printf(char *, int *, ...);
int main(int argc, char *argv[]) {
  int *ptr1, *ptr2;
  ptr1 = (int *)cmalloc_malloc(1);
  ptr2 = (int *)cmalloc_malloc(1);
  printf("%p - %p\n", ptr1, ptr2);
  cmalloc_free(ptr1);
  cmalloc_free(ptr2);
  printf("%p - ", cmalloc_malloc(1));
  printf("%p\n", cmalloc_malloc(1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <cmalloc_free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <cmalloc_free@plt>
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
mov    %rax,%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
mov    %rax,%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
mov    %rax,%r14
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
call   1050 <cmalloc_free@plt>
mov    %rbx,%rdi
call   1050 <cmalloc_free@plt>
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <cmalloc_malloc@plt>
lea    0xe67(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%p - %p\0A\00"
@.str.1 = [6 x i8] c"%p - \00"
@.str.2 = [4 x i8] c"%p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @cmalloc_malloc(i32 1)
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %6
%10 = call i64 @cmalloc_malloc(i32 1)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %7
%12 = load i32*, i32** %6
%13 = load i32*, i32** %7
%14 = call i32 (i8*, i32*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %12, i32* %13)
%15 = load i32*, i32** %6
%16 = call i32 @cmalloc_free(i32* %15)
%17 = load i32*, i32** %7
%18 = call i32 @cmalloc_free(i32* %17)
%19 = call i64 @cmalloc_malloc(i32 1)
%20 = inttoptr i64 %19 to i32*
%21 = call i32 (i8*, i32*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = call i64 @cmalloc_malloc(i32 1)
%23 = inttoptr i64 %22 to i32*
%24 = call i32 (i8*, i32*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%p - %p\0A\00"
@.str.1 = [6 x i8] c"%p - \00"
@.str.2 = [4 x i8] c"%p\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @cmalloc_malloc(i32 1)
%4 = inttoptr i64 %3 to i32*
%5 = tail call i64 @cmalloc_malloc(i32 1)
%6 = inttoptr i64 %5 to i32*
%7 = tail call i32 (i8*, i32*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %6)
%8 = tail call i32 @cmalloc_free(i32* %4)
%9 = tail call i32 @cmalloc_free(i32* %6)
%10 = tail call i64 @cmalloc_malloc(i32 1)
%11 = inttoptr i64 %10 to i32*
%12 = tail call i32 (i8*, i32*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%13 = tail call i64 @cmalloc_malloc(i32 1)
%14 = inttoptr i64 %13 to i32*
%15 = tail call i32 (i8*, i32*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %14)
ret i32 0
}