#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 *apply_memory(size_t);
int get(int *, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ recover_memory(int *);
int /*<<< orphan*/ set(int *, int);
int main(int argc, char **argv) {
  printf("size_t length: %lu, int length: %lu\n", sizeof(size_t), sizeof(int));
  size_t space = 1000000000;
  int *block = apply_memory(space);
  set(block, 35);
  printf("%d\n", get(block, 35));
  printf("%d\n", get(block, 37));
  recover_memory(block);
  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)
lea    0xe93(%rip),%rdi
mov    $0x8,%esi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x3b9aca00,-0x18(%rbp)
3b
mov    -0x18(%rbp),%rdi
call   1050 <apply_memory@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x23,%esi
call   1070 <set@plt>
mov    -0x20(%rbp),%rdi
mov    $0x23,%esi
call   1060 <get@plt>
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    $0x25,%esi
call   1060 <get@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <recover_memory@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
mov    $0x4,%edx
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3b9aca00,%edi
call   1050 <apply_memory@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x23,%esi
call   1070 <set@plt>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1060 <get@plt>
lea    0xe8b(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x25,%esi
call   1060 <get@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <recover_memory@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"size_t length: %lu, int length: %lu\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 8, i64 4)
store i64 1000000000, i64* %6
%9 = load i64, i64* %6
%10 = call i32* @apply_memory(i64 %9)
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = call i32 @set(i32* %11, i32 35)
%13 = load i32*, i32** %7
%14 = call i32 @get(i32* %13, i32 35)
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %7
%17 = call i32 @get(i32* %16, i32 37)
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %7
%20 = call i32 @recover_memory(i32* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"size_t length: %lu, int length: %lu\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 8, i64 4)
%4 = tail call i32* @apply_memory(i64 1000000000)
%5 = tail call i32 @set(i32* %4, i32 35)
%6 = tail call i32 @get(i32* %4, i32 35)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 @get(i32* %4, i32 37)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @recover_memory(i32* %4)
ret i32 0
}