#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*/ assert(char *);
int /*<<< orphan*/ ikmem_destroy();
int /*<<< orphan*/ ikmem_free(char *);
int /*<<< orphan*/ ikmem_init(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
scalar_t__ ikmem_malloc(int);
int ikmem_ptr_size(char *);
char *ikmem_realloc(char *, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  char *ptr;
  ikmem_init(0, 0, 0);
  ptr = (char *)ikmem_malloc(8);
  assert(ptr);
  printf("sizeof(ptr)=%d\n", ikmem_ptr_size(ptr));
  ptr = ikmem_realloc(ptr, 40);
  assert(ptr);
  printf("sizeof(ptr)=%d\n", ikmem_ptr_size(ptr));
  ikmem_free(ptr);
  ikmem_destroy();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1040 <ikmem_init@plt>
mov    $0x8,%edi
call   1030 <ikmem_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <ikmem_ptr_size@plt>
mov    %eax,%esi
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x28,%esi
call   10a0 <ikmem_realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <ikmem_ptr_size@plt>
mov    %eax,%esi
lea    0xe0b(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <ikmem_free@plt>
mov    $0x0,%al
call   1090 <ikmem_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <ikmem_init@plt>
mov    $0x8,%edi
call   1030 <ikmem_malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1050 <ikmem_ptr_size@plt>
lea    0xe4d(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
call   10a0 <ikmem_realloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1050 <ikmem_ptr_size@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <ikmem_free@plt>
xor    %eax,%eax
call   1090 <ikmem_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"sizeof(ptr)=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 @ikmem_init(i32 0, i32 0, i32 0)
%4 = call i64 @ikmem_malloc(i32 8)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @assert(i8* %6)
%8 = load i8*, i8** %2
%9 = call i32 @ikmem_ptr_size(i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %2
%12 = call i8* @ikmem_realloc(i8* %11, i32 40)
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @assert(i8* %13)
%15 = load i8*, i8** %2
%16 = call i32 @ikmem_ptr_size(i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i8*, i8** %2
%19 = call i32 @ikmem_free(i8* %18)
%20 = call i32 (...) @ikmem_destroy()
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"sizeof(ptr)=%d\0A\00"
define i32 @main() {
%1 = tail call i32 @ikmem_init(i32 0, i32 0, i32 0)
%2 = tail call i64 @ikmem_malloc(i32 8)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @assert(i8* %3)
%5 = tail call i32 @ikmem_ptr_size(i8* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i8* @ikmem_realloc(i8* %3, i32 40)
%8 = tail call i32 @assert(i8* %7)
%9 = tail call i32 @ikmem_ptr_size(i8* %7)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @ikmem_free(i8* %7)
%12 = tail call i32 (...) @ikmem_destroy()
ret i32 0
}