#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, void *, ...);
int /*<<< orphan*/ scgc_enable_print_gc_info();
void *scgc_new(int);
scalar_t__ strcmp(char *, char *);
int my_main(int argc, char *argv[]) {
  if (argc == 2 && strcmp(argv[1], "-enable_gc_info") == 0) {
    scgc_enable_print_gc_info();
  }
  void **my = scgc_new(100);
  FILE *fp = fopen(".tmp_out", "w");
  fprintf(fp, "my %p %p\n", (void *)my, (void *)&my);
  for (int i = 0; i < 100000; i++) {
    my[0] = scgc_new(32);
    my[1] = scgc_new(32);
    my[2] = scgc_new(32);
    ((void **)my[2])[0] = scgc_new(32);
    ((void **)my[2])[1] = scgc_new(32);
    fprintf(fp, "test1 %p\n", ((void **)my[0])[0]);
    fprintf(fp, "test2 %p\n", ((void **)my[1])[0]);
    fprintf(fp, "test3 %p\n", ((void ***)my[2])[0][0]);
    fprintf(fp, "test4 %p\n", ((void ***)my[2])[1][0]);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<my_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    119e <my_main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <my_main+0x3e>
mov    $0x0,%al
call   1080 <scgc_enable_print_gc_info@plt>
mov    $0x64,%edi
call   1060 <scgc_new@plt>
mov    %rax,-0x18(%rbp)
lea    0xe5d(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x186a0,-0x24(%rbp)
jge    12e8 <my_main+0x188>
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rcx,(%rax)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdx
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdx
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%rdx
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdx
lea    0xd70(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e4 <my_main+0x84>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    118c <my_main+0x2c>
mov    0x8(%rsi),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    118c <my_main+0x2c>
xor    %eax,%eax
call   1080 <scgc_enable_print_gc_info@plt>
mov    $0x64,%edi
call   1060 <scgc_new@plt>
mov    %rax,%r14
mov    %rax,(%rsp)
lea    0xe6c(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe61(%rip),%rsi
mov    %rsp,%rcx
mov    %rax,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x186a0,%ebp
lea    0xe4f(%rip),%r14
lea    0xe52(%rip),%r15
lea    0xe55(%rip),%r12
lea    0xe58(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    (%rsp),%rcx
mov    %rax,(%rcx)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    (%rsp),%rcx
mov    %rax,0x8(%rcx)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    (%rsp),%rcx
mov    %rax,0x10(%rcx)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    (%rsp),%rcx
mov    0x10(%rcx),%rcx
mov    %rax,(%rcx)
mov    $0x20,%edi
call   1060 <scgc_new@plt>
mov    (%rsp),%rcx
mov    0x10(%rcx),%rdx
mov    %rax,0x8(%rdx)
mov    (%rcx),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rsp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rsp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rsp),%rax
mov    0x10(%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0xffffffff,%ebp
jne    11f0 <my_main+0x90>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"-enable_gc_info\00"
@.str.1 = [9 x i8] c".tmp_out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"my %p %p\0A\00"
@.str.4 = [10 x i8] c"test1 %p\0A\00"
@.str.5 = [10 x i8] c"test2 %p\0A\00"
@.str.6 = [10 x i8] c"test3 %p\0A\00"
@.str.7 = [10 x i8] c"test4 %p\0A\00"
define i32 @my_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (...) @scgc_enable_print_gc_info()
br label %18
18: ; preds = %16, %10, %2
%19 = call i8* @scgc_new(i32 100)
%20 = bitcast i8* %19 to i8**
store i8** %20, i8*** %5
%21 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = load i8**, i8*** %5
%24 = bitcast i8** %23 to i8*
%25 = bitcast i8*** %5 to i8*
%26 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %25)
store i32 0, i32* %7
br label %27
27: ; preds = %88, %18
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 100000
br i1 %29, label %30, label %91
30: ; preds = %27
%31 = call i8* @scgc_new(i32 32)
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
store i8* %31, i8** %33
%34 = call i8* @scgc_new(i32 32)
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
store i8* %34, i8** %36
%37 = call i8* @scgc_new(i32 32)
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
store i8* %37, i8** %39
%40 = call i8* @scgc_new(i32 32)
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = bitcast i8* %43 to i8**
%45 = getelementptr inbounds i8*, i8** %44, i64 0
store i8* %40, i8** %45
%46 = call i8* @scgc_new(i32 32)
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = bitcast i8* %49 to i8**
%51 = getelementptr inbounds i8*, i8** %50, i64 1
store i8* %46, i8** %51
%52 = load i32*, i32** %6
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = bitcast i8* %55 to i8**
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = load i32*, i32** %6
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = bitcast i8* %63 to i8**
%65 = getelementptr inbounds i8*, i8** %64, i64 0
%66 = load i8*, i8** %65
%67 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %66)
%68 = load i32*, i32** %6
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 2
%71 = load i8*, i8** %70
%72 = bitcast i8* %71 to i8***
%73 = getelementptr inbounds i8**, i8*** %72, i64 0
%74 = load i8**, i8*** %73
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
%77 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %76)
%78 = load i32*, i32** %6
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 2
%81 = load i8*, i8** %80
%82 = bitcast i8* %81 to i8***
%83 = getelementptr inbounds i8**, i8*** %82, i64 1
%84 = load i8**, i8*** %83
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %86)
br label %88
88: ; preds = %30
%89 = load i32, i32* %7
%90 = add nsw i32 %89, 1
store i32 %90, i32* %7
br label %27
91: ; preds = %27
%92 = load i32*, i32** %6
%93 = call i32 @fclose(i32* %92)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"-enable_gc_info\00"
@.str.1 = [9 x i8] c".tmp_out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"my %p %p\0A\00"
@.str.4 = [10 x i8] c"test1 %p\0A\00"
@.str.5 = [10 x i8] c"test2 %p\0A\00"
@.str.6 = [10 x i8] c"test3 %p\0A\00"
@.str.7 = [10 x i8] c"test4 %p\0A\00"
define i32 @my_main(i32 %0, i8** nocapture %1) {
%3 = alloca i8**
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 (...) @scgc_enable_print_gc_info()
br label %12
12: ; preds = %10, %5, %2
%13 = bitcast i8*** %3 to i8*
%14 = tail call i8* @scgc_new(i32 100)
%15 = bitcast i8*** %3 to i8**
store i8* %14, i8** %15
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %14, i8*** %3)
br label %20
18: ; preds = %20
%19 = call i32 @fclose(i32* %16)
ret i32 0
20: ; preds = %12, %20
%21 = phi i32 [ 0, %12 ], [ %66, %20 ]
%22 = call i8* @scgc_new(i32 32)
%23 = load i8**, i8*** %3
store i8* %22, i8** %23
%24 = call i8* @scgc_new(i32 32)
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i64 1
store i8* %24, i8** %26
%27 = call i8* @scgc_new(i32 32)
%28 = load i8**, i8*** %3
%29 = getelementptr inbounds i8*, i8** %28, i64 2
store i8* %27, i8** %29
%30 = call i8* @scgc_new(i32 32)
%31 = load i8**, i8*** %3
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = bitcast i8** %32 to i8***
%34 = load i8**, i8*** %33
store i8* %30, i8** %34
%35 = call i8* @scgc_new(i32 32)
%36 = load i8**, i8*** %3
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = bitcast i8** %37 to i8***
%39 = load i8**, i8*** %38
%40 = getelementptr inbounds i8*, i8** %39, i64 1
store i8* %35, i8** %40
%41 = bitcast i8** %36 to i8***
%42 = load i8**, i8*** %41
%43 = load i8*, i8** %42
%44 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i8**, i8*** %3
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = bitcast i8** %46 to i8***
%48 = load i8**, i8*** %47
%49 = load i8*, i8** %48
%50 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = load i8**, i8*** %3
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = bitcast i8** %52 to i8****
%54 = load i8***, i8**** %53
%55 = load i8**, i8*** %54
%56 = load i8*, i8** %55
%57 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %56)
%58 = load i8**, i8*** %3
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = bitcast i8** %59 to i8****
%61 = load i8***, i8**** %60
%62 = getelementptr inbounds i8**, i8*** %61, i64 1
%63 = load i8**, i8*** %62
%64 = load i8*, i8** %63
%65 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %64)
%66 = add nuw nsw i32 %21, 1
%67 = icmp eq i32 %66, 100000
br i1 %67, label %18, label %20
}