#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 */
void *malloc(int);
void *realloc(void *, int);
int main(void) {
  int i __attribute__((unused));
  int *y __attribute__((unused));
  int **x = malloc(sizeof(int *) * 100);
  int *x2 = malloc(sizeof(int) * 100);
  void *sink __attribute__((unused));
  x[0] = x2;
  x[49] = x2;
  i = *x[0];
  i = *x[49];
  x = realloc(x, sizeof(int *) * 50);
  y = x[0];
  y = x[49];
  y = x[-1];
  y = x[50];
  i = *x[0];
  i = *x[49];
  x = realloc(x, sizeof(int *) * 50);
  y = x[0];
  y = x[49];
  y = x[-1];
  y = x[50];
  i = *x[0];
  i = *x[49];
  x = realloc(x, sizeof(int *) * 100);
  y = x[0];
  y = x[49];
  y = x[50];
  y = x[99];
  y = x[-1];
  y = x[100];
  i = *x[0];
  i = *x[49];
  sink = realloc((void *)0x99, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x320,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x190,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x188(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x190,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x190(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x190,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x190(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x320,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x190(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x318(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x320(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    0x188(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x99,%edi
mov    $0xa,%esi
call   1040 <realloc@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x320,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    $0x190,%edi
call   1030 <malloc@plt>
mov    %rax,(%rbx)
mov    %rax,0x188(%rbx)
mov    %rbx,%rdi
mov    $0x190,%esi
call   1040 <realloc@plt>
mov    %rax,%rdi
mov    $0x190,%esi
call   1040 <realloc@plt>
mov    %rax,%rdi
mov    $0x320,%esi
call   1040 <realloc@plt>
mov    $0x99,%edi
mov    $0xa,%esi
call   1040 <realloc@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32**
%5 = alloca i32*
%6 = alloca i8*
store i32 0, i32* %1
%7 = call i8* @malloc(i32 800)
%8 = bitcast i8* %7 to i32**
store i32** %8, i32*** %4
%9 = call i8* @malloc(i32 400)
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = load i32**, i32*** %4
%13 = getelementptr inbounds i32*, i32** %12, i64 0
store i32* %11, i32** %13
%14 = load i32*, i32** %5
%15 = load i32**, i32*** %4
%16 = getelementptr inbounds i32*, i32** %15, i64 49
store i32* %14, i32** %16
%17 = load i32**, i32*** %4
%18 = getelementptr inbounds i32*, i32** %17, i64 0
%19 = load i32*, i32** %18
%20 = load i32, i32* %19
store i32 %20, i32* %2
%21 = load i32**, i32*** %4
%22 = getelementptr inbounds i32*, i32** %21, i64 49
%23 = load i32*, i32** %22
%24 = load i32, i32* %23
store i32 %24, i32* %2
%25 = load i32**, i32*** %4
%26 = bitcast i32** %25 to i8*
%27 = call i8* @realloc(i8* %26, i32 400)
%28 = bitcast i8* %27 to i32**
store i32** %28, i32*** %4
%29 = load i32**, i32*** %4
%30 = getelementptr inbounds i32*, i32** %29, i64 0
%31 = load i32*, i32** %30
store i32* %31, i32** %3
%32 = load i32**, i32*** %4
%33 = getelementptr inbounds i32*, i32** %32, i64 49
%34 = load i32*, i32** %33
store i32* %34, i32** %3
%35 = load i32**, i32*** %4
%36 = getelementptr inbounds i32*, i32** %35, i64 -1
%37 = load i32*, i32** %36
store i32* %37, i32** %3
%38 = load i32**, i32*** %4
%39 = getelementptr inbounds i32*, i32** %38, i64 50
%40 = load i32*, i32** %39
store i32* %40, i32** %3
%41 = load i32**, i32*** %4
%42 = getelementptr inbounds i32*, i32** %41, i64 0
%43 = load i32*, i32** %42
%44 = load i32, i32* %43
store i32 %44, i32* %2
%45 = load i32**, i32*** %4
%46 = getelementptr inbounds i32*, i32** %45, i64 49
%47 = load i32*, i32** %46
%48 = load i32, i32* %47
store i32 %48, i32* %2
%49 = load i32**, i32*** %4
%50 = bitcast i32** %49 to i8*
%51 = call i8* @realloc(i8* %50, i32 400)
%52 = bitcast i8* %51 to i32**
store i32** %52, i32*** %4
%53 = load i32**, i32*** %4
%54 = getelementptr inbounds i32*, i32** %53, i64 0
%55 = load i32*, i32** %54
store i32* %55, i32** %3
%56 = load i32**, i32*** %4
%57 = getelementptr inbounds i32*, i32** %56, i64 49
%58 = load i32*, i32** %57
store i32* %58, i32** %3
%59 = load i32**, i32*** %4
%60 = getelementptr inbounds i32*, i32** %59, i64 -1
%61 = load i32*, i32** %60
store i32* %61, i32** %3
%62 = load i32**, i32*** %4
%63 = getelementptr inbounds i32*, i32** %62, i64 50
%64 = load i32*, i32** %63
store i32* %64, i32** %3
%65 = load i32**, i32*** %4
%66 = getelementptr inbounds i32*, i32** %65, i64 0
%67 = load i32*, i32** %66
%68 = load i32, i32* %67
store i32 %68, i32* %2
%69 = load i32**, i32*** %4
%70 = getelementptr inbounds i32*, i32** %69, i64 49
%71 = load i32*, i32** %70
%72 = load i32, i32* %71
store i32 %72, i32* %2
%73 = load i32**, i32*** %4
%74 = bitcast i32** %73 to i8*
%75 = call i8* @realloc(i8* %74, i32 800)
%76 = bitcast i8* %75 to i32**
store i32** %76, i32*** %4
%77 = load i32**, i32*** %4
%78 = getelementptr inbounds i32*, i32** %77, i64 0
%79 = load i32*, i32** %78
store i32* %79, i32** %3
%80 = load i32**, i32*** %4
%81 = getelementptr inbounds i32*, i32** %80, i64 49
%82 = load i32*, i32** %81
store i32* %82, i32** %3
%83 = load i32**, i32*** %4
%84 = getelementptr inbounds i32*, i32** %83, i64 50
%85 = load i32*, i32** %84
store i32* %85, i32** %3
%86 = load i32**, i32*** %4
%87 = getelementptr inbounds i32*, i32** %86, i64 99
%88 = load i32*, i32** %87
store i32* %88, i32** %3
%89 = load i32**, i32*** %4
%90 = getelementptr inbounds i32*, i32** %89, i64 -1
%91 = load i32*, i32** %90
store i32* %91, i32** %3
%92 = load i32**, i32*** %4
%93 = getelementptr inbounds i32*, i32** %92, i64 100
%94 = load i32*, i32** %93
store i32* %94, i32** %3
%95 = load i32**, i32*** %4
%96 = getelementptr inbounds i32*, i32** %95, i64 0
%97 = load i32*, i32** %96
%98 = load i32, i32* %97
store i32 %98, i32* %2
%99 = load i32**, i32*** %4
%100 = getelementptr inbounds i32*, i32** %99, i64 49
%101 = load i32*, i32** %100
%102 = load i32, i32* %101
store i32 %102, i32* %2
%103 = call i8* @realloc(i8* inttoptr (i64 153 to i8*), i32 10)
store i8* %103, i8** %6
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(800) i8* @malloc(i32 800)
%2 = bitcast i8* %1 to i32**
%3 = tail call dereferenceable_or_null(400) i8* @malloc(i32 400)
%4 = bitcast i8* %1 to i8**
store i8* %3, i8** %4
%5 = getelementptr inbounds i32*, i32** %2, i64 49
%6 = bitcast i32** %5 to i8**
store i8* %3, i8** %6
%7 = tail call i8* @realloc(i8* %1, i32 400)
%8 = tail call i8* @realloc(i8* %7, i32 400)
%9 = tail call i8* @realloc(i8* %8, i32 800)
%10 = tail call i8* @realloc(i8* inttoptr (i64 153 to i8*), i32 10)
ret i32 0
}