#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(int *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ realloc(int *, int);
int main(void) {
  int i, j;
  int *nums;
  for (i = 1; i < 50; i++) {
    nums = (int *)realloc(nums, (i + 1) * sizeof(int));
    *(nums + ((i - 1) * sizeof(int))) = i;
    printf("\nnums: ");
    for (j = 0; j < i; j++) {
      printf("\n %d %p ", *(nums + (j * sizeof(int))),
             nums + (j * sizeof(int)));
    }
    getchar();
  }
  free(nums);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    1206 <main+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
mov    %edx,(%rax,%rcx,4)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f1 <main+0xb1>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x18(%rbp),%rdx
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a7 <main+0x67>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
@.str = [8 x i8] c"\0Anums: \00"
@.str.1 = [9 x i8] c"\0A %d %p \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %2
br label %5
5: ; preds = %47, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 50
br i1 %7, label %8, label %50
8: ; preds = %5
%9 = load i32*, i32** %4
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 4
%14 = trunc i64 %13 to i32
%15 = call i64 @realloc(i32* %9, i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %4
%17 = load i32, i32* %2
%18 = load i32*, i32** %4
%19 = load i32, i32* %2
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = getelementptr inbounds i32, i32* %18, i64 %22
store i32 %17, i32* %23
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %25
25: ; preds = %42, %8
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = load i32*, i32** %4
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 4
%34 = getelementptr inbounds i32, i32* %30, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %4
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 4
%40 = getelementptr inbounds i32, i32* %36, i64 %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32* %40)
br label %42
42: ; preds = %29
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %25
45: ; preds = %25
%46 = call i32 (...) @getchar()
br label %47
47: ; preds = %45
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %5
50: ; preds = %5
%51 = load i32*, i32** %4
%52 = call i32 @free(i32* %51)
%53 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):