#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(void *);
int /*<<< orphan*/ printf(char *, size_t, int, ...);
int **realloc(void *, int);
int main() {
  int **l = NULL;
  int a = 1, b = 2;
  do {
    size_t list_type_len10 = (l ? ((size_t *)l)[-1] : 0);
    l = realloc(l ? ((void *)l) - sizeof(size_t) : NULL,
                sizeof(void *) * (list_type_len10 + 1) + sizeof(size_t)) +
        sizeof(size_t);
    ((size_t *)l)[-1] = list_type_len10 + 1;
    l[((size_t *)l)[-1] - 1] = &a;
  } while (0);
  printf("%zu %d\n", (l ? ((size_t *)l)[-1] : 0), *l[0]);
  do {
    size_t list_type_len12 = (l ? ((size_t *)l)[-1] : 0);
    l = realloc(l ? ((void *)l) - sizeof(size_t) : NULL,
                sizeof(void *) * (list_type_len12 + 1) + sizeof(size_t)) +
        sizeof(size_t);
    ((size_t *)l)[-1] = list_type_len12 + 1;
    l[((size_t *)l)[-1] - 1] = &b;
  } while (0);
  printf("%zu %d %d\n", (l ? ((size_t *)l)[-1] : 0), *l[0], *l[1]);
  free(l ? (void *)l - sizeof(size_t) : NULL);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    117c <main+0x4c>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    117c <main+0x4c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a0 <main+0x70>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x38(%rbp)
jmp    11ab <main+0x7b>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    11ab <main+0x7b>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rax
add    $0x1,%rax
shl    $0x3,%rax
add    $0x8,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
add    $0x40,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x8(%rcx),%rcx
sub    $0x1,%rcx
lea    -0x14(%rbp),%rdx
mov    %rdx,(%rax,%rcx,8)
cmpq   $0x0,-0x10(%rbp)
je     1212 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    121d <main+0xed>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
jmp    121d <main+0xed>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edx
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1254 <main+0x124>
mov    -0x10(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    125f <main+0x12f>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    125f <main+0x12f>
mov    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1283 <main+0x153>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x50(%rbp)
jmp    128e <main+0x15e>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    128e <main+0x15e>
mov    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rax
add    $0x1,%rax
shl    $0x3,%rax
add    $0x8,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
add    $0x40,%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x8(%rcx),%rcx
sub    $0x1,%rcx
lea    -0x18(%rbp),%rdx
mov    %rdx,(%rax,%rcx,8)
cmpq   $0x0,-0x10(%rbp)
je     12f5 <main+0x1c5>
mov    -0x10(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1300 <main+0x1d0>
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
jmp    1300 <main+0x1d0>
mov    -0x58(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%ecx
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1341 <main+0x211>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x60(%rbp)
jmp    134c <main+0x21c>
xor    %eax,%eax
mov    %rax,-0x60(%rbp)
jmp    134c <main+0x21c>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
movl   $0x2,0x8(%rsp)
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <realloc@plt>
mov    %rax,%rbx
lea    0x38(%rax),%r14
movq   $0x1,0x38(%rax)
lea    0xc(%rsp),%rax
mov    %rax,0x40(%rbx)
lea    0xe8c(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rbx),%r15
lea    0x1(%r15),%rbx
lea    0x8(,%rbx,8),%esi
mov    %r14,%rdi
call   1050 <realloc@plt>
lea    0x38(%rax),%r14
mov    %rbx,0x38(%rax)
lea    0x8(%rsp),%rcx
mov    %rcx,0x40(%rax,%r15,8)
mov    0x40(%rax),%rcx
mov    0x48(%rax),%rax
mov    (%rcx),%edx
mov    (%rax),%ecx
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%zu %d\0A\00"
@.str.1 = [11 x i8] c"%zu %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i32** null, i32*** %2
store i32 1, i32* %3
store i32 2, i32* %4
br label %7
7: ; preds = %0
%8 = load i32**, i32*** %2
%9 = icmp ne i32** %8, null
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i32**, i32*** %2
%12 = bitcast i32** %11 to i64*
%13 = getelementptr inbounds i64, i64* %12, i64 -1
%14 = load i64, i64* %13
br label %16
15: ; preds = %7
br label %16
16: ; preds = %15, %10
%17 = phi i64 [ %14, %10 ], [ 0, %15 ]
store i64 %17, i64* %5
%18 = load i32**, i32*** %2
%19 = icmp ne i32** %18, null
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32**, i32*** %2
%22 = bitcast i32** %21 to i8*
%23 = getelementptr i8, i8* %22, i64 -8
br label %25
24: ; preds = %16
br label %25
25: ; preds = %24, %20
%26 = phi i8* [ %23, %20 ], [ null, %24 ]
%27 = load i64, i64* %5
%28 = add i64 %27, 1
%29 = mul i64 8, %28
%30 = add i64 %29, 8
%31 = trunc i64 %30 to i32
%32 = call i32** @realloc(i8* %26, i32 %31)
%33 = getelementptr inbounds i32*, i32** %32, i64 8
store i32** %33, i32*** %2
%34 = load i64, i64* %5
%35 = add i64 %34, 1
%36 = load i32**, i32*** %2
%37 = bitcast i32** %36 to i64*
%38 = getelementptr inbounds i64, i64* %37, i64 -1
store i64 %35, i64* %38
%39 = load i32**, i32*** %2
%40 = load i32**, i32*** %2
%41 = bitcast i32** %40 to i64*
%42 = getelementptr inbounds i64, i64* %41, i64 -1
%43 = load i64, i64* %42
%44 = sub i64 %43, 1
%45 = getelementptr inbounds i32*, i32** %39, i64 %44
store i32* %3, i32** %45
br label %46
46: ; preds = %25
%47 = load i32**, i32*** %2
%48 = icmp ne i32** %47, null
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32**, i32*** %2
%51 = bitcast i32** %50 to i64*
%52 = getelementptr inbounds i64, i64* %51, i64 -1
%53 = load i64, i64* %52
br label %55
54: ; preds = %46
br label %55
55: ; preds = %54, %49
%56 = phi i64 [ %53, %49 ], [ 0, %54 ]
%57 = load i32**, i32*** %2
%58 = getelementptr inbounds i32*, i32** %57, i64 0
%59 = load i32*, i32** %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, i64, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %56, i32 %60)
br label %62
62: ; preds = %55
%63 = load i32**, i32*** %2
%64 = icmp ne i32** %63, null
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = load i32**, i32*** %2
%67 = bitcast i32** %66 to i64*
%68 = getelementptr inbounds i64, i64* %67, i64 -1
%69 = load i64, i64* %68
br label %71
70: ; preds = %62
br label %71
71: ; preds = %70, %65
%72 = phi i64 [ %69, %65 ], [ 0, %70 ]
store i64 %72, i64* %6
%73 = load i32**, i32*** %2
%74 = icmp ne i32** %73, null
br i1 %74, label %75, label %79
75: ; preds = %71
%76 = load i32**, i32*** %2
%77 = bitcast i32** %76 to i8*
%78 = getelementptr i8, i8* %77, i64 -8
br label %80
79: ; preds = %71
br label %80
80: ; preds = %79, %75
%81 = phi i8* [ %78, %75 ], [ null, %79 ]
%82 = load i64, i64* %6
%83 = add i64 %82, 1
%84 = mul i64 8, %83
%85 = add i64 %84, 8
%86 = trunc i64 %85 to i32
%87 = call i32** @realloc(i8* %81, i32 %86)
%88 = getelementptr inbounds i32*, i32** %87, i64 8
store i32** %88, i32*** %2
%89 = load i64, i64* %6
%90 = add i64 %89, 1
%91 = load i32**, i32*** %2
%92 = bitcast i32** %91 to i64*
%93 = getelementptr inbounds i64, i64* %92, i64 -1
store i64 %90, i64* %93
%94 = load i32**, i32*** %2
%95 = load i32**, i32*** %2
%96 = bitcast i32** %95 to i64*
%97 = getelementptr inbounds i64, i64* %96, i64 -1
%98 = load i64, i64* %97
%99 = sub i64 %98, 1
%100 = getelementptr inbounds i32*, i32** %94, i64 %99
store i32* %4, i32** %100
br label %101
101: ; preds = %80
%102 = load i32**, i32*** %2
%103 = icmp ne i32** %102, null
br i1 %103, label %104, label %109
104: ; preds = %101
%105 = load i32**, i32*** %2
%106 = bitcast i32** %105 to i64*
%107 = getelementptr inbounds i64, i64* %106, i64 -1
%108 = load i64, i64* %107
br label %110
109: ; preds = %101
br label %110
110: ; preds = %109, %104
%111 = phi i64 [ %108, %104 ], [ 0, %109 ]
%112 = load i32**, i32*** %2
%113 = getelementptr inbounds i32*, i32** %112, i64 0
%114 = load i32*, i32** %113
%115 = load i32, i32* %114
%116 = load i32**, i32*** %2
%117 = getelementptr inbounds i32*, i32** %116, i64 1
%118 = load i32*, i32** %117
%119 = load i32, i32* %118
%120 = call i32 (i8*, i64, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %111, i32 %115, i32 %119)
%121 = load i32**, i32*** %2
%122 = icmp ne i32** %121, null
br i1 %122, label %123, label %127
123: ; preds = %110
%124 = load i32**, i32*** %2
%125 = bitcast i32** %124 to i8*
%126 = getelementptr i8, i8* %125, i64 -8
br label %128
127: ; preds = %110
br label %128
128: ; preds = %127, %123
%129 = phi i8* [ %126, %123 ], [ null, %127 ]
%130 = call i32 @free(i8* %129)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%zu %d\0A\00"
@.str.1 = [11 x i8] c"%zu %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 2, i32* %2
%5 = tail call i32** @realloc(i8* null, i32 16)
%6 = getelementptr inbounds i32*, i32** %5, i64 8
%7 = getelementptr inbounds i32*, i32** %5, i64 7
%8 = bitcast i32** %7 to i64*
store i64 1, i64* %8
store i32* %1, i32** %6
%9 = call i32 (i8*, i64, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 1, i32 1)
%10 = load i64, i64* %8
%11 = bitcast i32** %7 to i8*
%12 = add i64 %10, 1
%13 = trunc i64 %12 to i32
%14 = shl i32 %13, 3
%15 = add i32 %14, 8
%16 = call i32** @realloc(i8* %11, i32 %15)
%17 = getelementptr inbounds i32*, i32** %16, i64 8
%18 = getelementptr inbounds i32*, i32** %16, i64 7
%19 = bitcast i32** %18 to i64*
store i64 %12, i64* %19
%20 = getelementptr inbounds i32*, i32** %17, i64 %10
store i32* %2, i32** %20
%21 = load i32*, i32** %17
%22 = load i32, i32* %21
%23 = getelementptr inbounds i32*, i32** %16, i64 9
%24 = load i32*, i32** %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, i64, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %12, i32 %22, i32 %25)
%27 = bitcast i32** %18 to i8*
%28 = call i32 @free(i8* %27)
ret i32 0
}