#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, long long);
int main() {
  long long ram = 0;
  int src = 1;
  long long i;
  long long *dest;
  printf("Source = %d\n", src);
  for (i = 0; i > -1; i++) {
    dest = (int *)malloc(1000);
    *dest = 1111;
    ram++;
    printf("RAM used up to this point: %d\n", ram);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movslq -0x14(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jle    11a7 <main+0x87>
mov    $0x3e8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x457,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1156 <main+0x36>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0xecc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x3e8,%edi
call   1040 <malloc@plt>
movq   $0x457,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x1,%rbx
jmp    1150 <main+0x30>

LLVM IR (-O0):
@.str = [13 x i8] c"Source = %d\0A\00"
@.str.1 = [31 x i8] c"RAM used up to this point: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64*
store i32 0, i32* %1
store i64 0, i64* %2
store i32 1, i32* %3
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %7)
store i64 0, i64* %4
br label %9
9: ; preds = %21, %0
%10 = load i64, i64* %4
%11 = icmp sgt i64 %10, -1
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = call i64 @malloc(i32 1000)
%14 = inttoptr i64 %13 to i32*
%15 = bitcast i32* %14 to i64*
store i64* %15, i64** %5
%16 = load i64*, i64** %5
store i64 1111, i64* %16
%17 = load i64, i64* %2
%18 = add nsw i64 %17, 1
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 %19)
br label %21
21: ; preds = %12
%22 = load i64, i64* %4
%23 = add nsw i64 %22, 1
store i64 %23, i64* %4
br label %9
24: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Source = %d\0A\00"
@.str.1 = [31 x i8] c"RAM used up to this point: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 1)
br label %2
2: ; preds = %2, %0
%3 = phi i64 [ 0, %0 ], [ %6, %2 ]
%4 = tail call i64 @malloc(i32 1000)
%5 = inttoptr i64 %4 to i64*
store i64 1111, i64* %5
%6 = add nuw nsw i64 %3, 1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 %6)
br label %2
}