void macro_new_test() {
  {
    int *foo = (clone_memory(&(int){42}, sizeof(int)));
    assert(*foo == 42);
    free(foo);
  }
  {
    char *c = (clone_memory(&(char){'L'}, sizeof(char)));
    assert(*c == 'L');
    free(c);
  }
  {
    int *foo = (clone_memory(&(int[5]){0, 1, 2, 3, 4}, sizeof(int[5])));
    assert(foo[0] == 0);
    assert(foo[1] == 1);
    assert(foo[2] == 2);
    assert(foo[3] == 3);
    assert(foo[4] == 4);
    free(foo);
  }
  {
    int *foo = (clone_memory(&(int[1000]){1}, sizeof(int[1000])));
    assert(foo[0] == 1);
    for (int i = 1; i < 1000; i++) {
      assert(foo[i] == 0);
    }
    free(foo);
  }
  {
    int *foo = (clone_memory(&(int[1000]){}, sizeof(int[1000])));
    for (int i = 0; i < 1000; i++) {
      assert(foo[i] == 0);
    }
    free(foo);
  }
  {
    struct foo_type {
      int a;
      char b;
      double c;
    };
    struct foo_type *foo = (clone_memory(&(struct foo_type){1, 'd', 3.14},
                                         sizeof(struct foo_type)));
    assert(foo->a == 1);
    assert(foo->b == 'd');
    assert(foo->c == 3.14);
    free(foo);
    foo = (clone_memory(&(struct foo_type){.c = 1.23, .a = 42, .b = 'G'},
                        sizeof(struct foo_type)));
    assert(foo->a == 42);
    assert(foo->b == 'G');
    assert(foo->c == 1.23);
    free(foo);
  }
  {
    struct foo_type {
      int a, b, c;
    };
    struct foo_type *foo =
        (clone_memory(&(struct foo_type){}, sizeof(struct foo_type)));
    assert(foo->a == 0);
    assert(foo->b == 0);
    assert(foo->c == 0);
    free(foo);
  }
}


x86 assembly (clang, -O0):
<macro_new_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1fe0,%rsp
movl   $0x2a,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x2a,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
movb   $0x4c,-0x19(%rbp)
lea    -0x19(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4c,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e76(%rip),%rax
mov    %rax,-0x3c(%rbp)
mov    0x2e73(%rip),%rax
mov    %rax,-0x34(%rbp)
mov    0x2e71(%rip),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x3c(%rbp),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x1,0x4(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x2,0x8(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x3,0xc(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x4,0x10(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
lea    -0xfe8(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
movl   $0x1,-0xfe8(%rbp)
lea    -0xfe8(%rbp),%rdi
mov    $0xfa0,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
movl   $0x1,-0xfec(%rbp)
cmpl   $0x3e8,-0xfec(%rbp)
jge    130b <macro_new_test+0x1cb>
mov    -0x48(%rbp),%rax
movslq -0xfec(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0xfec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfec(%rbp)
jmp    12c9 <macro_new_test+0x189>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
lea    -0x1f98(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
lea    -0x1f98(%rbp),%rdi
mov    $0xfa0,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0xff8(%rbp)
movl   $0x0,-0x1f9c(%rbp)
cmpl   $0x3e8,-0x1f9c(%rbp)
jge    1392 <macro_new_test+0x252>
mov    -0xff8(%rbp),%rax
movslq -0x1f9c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1f9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f9c(%rbp)
jmp    134d <macro_new_test+0x20d>
mov    -0xff8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x1fb8(%rbp)
movb   $0x64,-0x1fb4(%rbp)
movsd  0xc51(%rip),%xmm0
movsd  %xmm0,-0x1fb0(%rbp)
ff
lea    -0x1fb8(%rbp),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x1fa8(%rbp)
mov    -0x1fa8(%rbp),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fa8(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x64,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fa8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xbe3(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fa8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x2a,-0x1fc8(%rbp)
movb   $0x47,-0x1fc4(%rbp)
movsd  0xb9e(%rip),%xmm0
movsd  %xmm0,-0x1fc0(%rbp)
ff
lea    -0x1fc8(%rbp),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x1fa8(%rbp)
mov    -0x1fa8(%rbp),%rax
cmpl   $0x2a,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fa8(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x47,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fa8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xb30(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fa8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x1fe0(%rbp)
movl   $0x0,-0x1fdc(%rbp)
movl   $0x0,-0x1fd8(%rbp)
lea    -0x1fe0(%rbp),%rdi
mov    $0xc,%esi
mov    $0x0,%al
call   1060 <clone_memory@plt>
cltq
mov    %rax,-0x1fd0(%rbp)
mov    -0x1fd0(%rbp),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fd0(%rbp),%rax
cmpl   $0x0,0x4(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fd0(%rbp),%rax
cmpl   $0x0,0x8(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x1fd0(%rbp),%rdi
call   1030 <free@plt>
add    $0x1fe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<macro_new_test>:
push   %r14
push   %rbx
sub    $0x1f98,%rsp
movl   $0x2a,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%rbx
xor    %edi,%edi
cmpl   $0x2a,(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movb   $0x4c,0xb(%rsp)
lea    0xb(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%r14
xor    %edi,%edi
cmpb   $0x4c,(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0xe65(%rip),%eax
mov    %eax,0x50(%rsp)
movups 0xe4a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%r14
xor    %edi,%edi
cmpl   $0x0,(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,0x4(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,0x8(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x3,0xc(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x4,0x10(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0x5c(%rsp),%rdi
mov    $0xf9c,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x1,0x58(%rsp)
lea    0x58(%rsp),%rdi
mov    $0xfa0,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%r14
xor    %edi,%edi
cmpl   $0x1,(%r14)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xchg   %ax,%ax
xor    %edi,%edi
cmpl   $0x0,(%r14,%rbx,4)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1280 <macro_new_test+0x140>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xff8(%rsp),%rbx
mov    $0xfa0,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    $0xfa0,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edi,%edi
cmpl   $0x0,(%r14,%rbx,4)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    12e0 <macro_new_test+0x1a0>
mov    %r14,%rdi
call   1030 <free@plt>
movl   $0x1,0x30(%rsp)
movb   $0x64,0x34(%rsp)
movabs $0x40091eb851eb851f,%rax
1e 09 40
mov    %rax,0x38(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%rbx
xor    %edi,%edi
cmpl   $0x1,(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpb   $0x64,0x4(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
movsd  0xca0(%rip),%xmm0
cmpeqsd 0x8(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movl   $0x2a,0x20(%rsp)
movb   $0x47,0x24(%rsp)
movabs $0x3ff3ae147ae147ae,%rax
ae f3 3f
mov    %rax,0x28(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%rbx
xor    %edi,%edi
cmpl   $0x2a,(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpb   $0x47,0x4(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
movsd  0xc32(%rip),%xmm0
cmpeqsd 0x8(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
lea    0x10(%rsp),%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1060 <clone_memory@plt>
movslq %eax,%rbx
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x4(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x8(%rbx)
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1f98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.foo_type = type { i32, i8, double }
%struct.foo_type.0 = type { i32, i32, i32 }
@constinit = private global [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
define void @macro_new_test() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32*
%6 = alloca [5 x i32]
%7 = alloca i32*
%8 = alloca [1000 x i32]
%9 = alloca i32
%10 = alloca i32*
%11 = alloca [1000 x i32]
%12 = alloca i32
%13 = alloca %struct.foo_type*
%14 = alloca %struct.foo_type
%15 = alloca %struct.foo_type
%16 = alloca %struct.foo_type.0*
%17 = alloca %struct.foo_type.0
store i32 42, i32* %2
%18 = call i32 (i32*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (i32*, i64, ...)*)(i32* %2, i64 4)
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %1
%21 = load i32*, i32** %1
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 42
%24 = zext i1 %23 to i32
%25 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %24)
%26 = load i32*, i32** %1
%27 = bitcast i32* %26 to i8*
store i8 76, i8* %4
%28 = call i32 (i8*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (i8*, i64, ...)*)(i8* %4, i64 1)
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %3
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 76
%35 = zext i1 %34 to i32
%36 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %35)
%37 = load i8*, i8** %3
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%39 = bitcast [5 x i32]* %6 to i8*
%40 = call i32 ([5 x i32]*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 ([5 x i32]*, i64, ...)*)([5 x i32]* %6, i64 20)
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i32*
store i32* %42, i32** %5
%43 = load i32*, i32** %5
%44 = getelementptr inbounds i32, i32* %43, i64 0
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 0
%47 = zext i1 %46 to i32
%48 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %47)
%49 = load i32*, i32** %5
%50 = getelementptr inbounds i32, i32* %49, i64 1
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 1
%53 = zext i1 %52 to i32
%54 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %53)
%55 = load i32*, i32** %5
%56 = getelementptr inbounds i32, i32* %55, i64 2
%57 = load i32, i32* %56
%58 = icmp eq i32 %57, 2
%59 = zext i1 %58 to i32
%60 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %59)
%61 = load i32*, i32** %5
%62 = getelementptr inbounds i32, i32* %61, i64 3
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, 3
%65 = zext i1 %64 to i32
%66 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %65)
%67 = load i32*, i32** %5
%68 = getelementptr inbounds i32, i32* %67, i64 4
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, 4
%71 = zext i1 %70 to i32
%72 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %71)
%73 = load i32*, i32** %5
%74 = bitcast i32* %73 to i8*
%75 = bitcast [1000 x i32]* %8 to i8*
%76 = getelementptr inbounds [1000 x i32], [1000 x i32]* %8, i64 0, i64 0
store i32 1, i32* %76
%77 = call i32 ([1000 x i32]*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 ([1000 x i32]*, i64, ...)*)([1000 x i32]* %8, i64 4000)
%78 = sext i32 %77 to i64
%79 = inttoptr i64 %78 to i32*
store i32* %79, i32** %7
%80 = load i32*, i32** %7
%81 = getelementptr inbounds i32, i32* %80, i64 0
%82 = load i32, i32* %81
%83 = icmp eq i32 %82, 1
%84 = zext i1 %83 to i32
%85 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %84)
store i32 1, i32* %9
br label %86
86: ; preds = %98, %0
%87 = load i32, i32* %9
%88 = icmp slt i32 %87, 1000
br i1 %88, label %89, label %101
89: ; preds = %86
%90 = load i32*, i32** %7
%91 = load i32, i32* %9
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %90, i64 %92
%94 = load i32, i32* %93
%95 = icmp eq i32 %94, 0
%96 = zext i1 %95 to i32
%97 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %96)
br label %98
98: ; preds = %89
%99 = load i32, i32* %9
%100 = add nsw i32 %99, 1
store i32 %100, i32* %9
br label %86
101: ; preds = %86
%102 = load i32*, i32** %7
%103 = bitcast i32* %102 to i8*
%104 = bitcast [1000 x i32]* %11 to i8*
%105 = getelementptr inbounds [1000 x i32], [1000 x i32]* %11, i64 0, i64 0
%106 = call i32 ([1000 x i32]*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 ([1000 x i32]*, i64, ...)*)([1000 x i32]* %11, i64 4000)
%107 = sext i32 %106 to i64
%108 = inttoptr i64 %107 to i32*
store i32* %108, i32** %10
store i32 0, i32* %12
br label %109
109: ; preds = %121, %101
%110 = load i32, i32* %12
%111 = icmp slt i32 %110, 1000
br i1 %111, label %112, label %124
112: ; preds = %109
%113 = load i32*, i32** %10
%114 = load i32, i32* %12
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %113, i64 %115
%117 = load i32, i32* %116
%118 = icmp eq i32 %117, 0
%119 = zext i1 %118 to i32
%120 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %119)
br label %121
121: ; preds = %112
%122 = load i32, i32* %12
%123 = add nsw i32 %122, 1
store i32 %123, i32* %12
br label %109
124: ; preds = %109
%125 = load i32*, i32** %10
%126 = bitcast i32* %125 to i8*
%127 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %14, i32 0, i32 0
store i32 1, i32* %127
%128 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %14, i32 0, i32 1
store i8 100, i8* %128
%129 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %14, i32 0, i32 2
store double 3.140000e+00, double* %129
%130 = call i32 (%struct.foo_type*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (%struct.foo_type*, i64, ...)*)(%struct.foo_type* %14, i64 16)
%131 = sext i32 %130 to i64
%132 = inttoptr i64 %131 to %struct.foo_type*
store %struct.foo_type* %132, %struct.foo_type** %13
%133 = load %struct.foo_type*, %struct.foo_type** %13
%134 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %133, i32 0, i32 0
%135 = load i32, i32* %134
%136 = icmp eq i32 %135, 1
%137 = zext i1 %136 to i32
%138 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %137)
%139 = load %struct.foo_type*, %struct.foo_type** %13
%140 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %139, i32 0, i32 1
%141 = load i8, i8* %140
%142 = sext i8 %141 to i32
%143 = icmp eq i32 %142, 100
%144 = zext i1 %143 to i32
%145 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %144)
%146 = load %struct.foo_type*, %struct.foo_type** %13
%147 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %146, i32 0, i32 2
%148 = load double, double* %147
%149 = fcmp oeq double %148, 3.140000e+00
%150 = zext i1 %149 to i32
%151 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %150)
%152 = load %struct.foo_type*, %struct.foo_type** %13
%153 = bitcast %struct.foo_type* %152 to i8*
%154 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %15, i32 0, i32 0
store i32 42, i32* %154
%155 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %15, i32 0, i32 1
store i8 71, i8* %155
%156 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %15, i32 0, i32 2
store double 1.230000e+00, double* %156
%157 = call i32 (%struct.foo_type*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (%struct.foo_type*, i64, ...)*)(%struct.foo_type* %15, i64 16)
%158 = sext i32 %157 to i64
%159 = inttoptr i64 %158 to %struct.foo_type*
store %struct.foo_type* %159, %struct.foo_type** %13
%160 = load %struct.foo_type*, %struct.foo_type** %13
%161 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %160, i32 0, i32 0
%162 = load i32, i32* %161
%163 = icmp eq i32 %162, 42
%164 = zext i1 %163 to i32
%165 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %164)
%166 = load %struct.foo_type*, %struct.foo_type** %13
%167 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %166, i32 0, i32 1
%168 = load i8, i8* %167
%169 = sext i8 %168 to i32
%170 = icmp eq i32 %169, 71
%171 = zext i1 %170 to i32
%172 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %171)
%173 = load %struct.foo_type*, %struct.foo_type** %13
%174 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %173, i32 0, i32 2
%175 = load double, double* %174
%176 = fcmp oeq double %175, 1.230000e+00
%177 = zext i1 %176 to i32
%178 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %177)
%179 = load %struct.foo_type*, %struct.foo_type** %13
%180 = bitcast %struct.foo_type* %179 to i8*
%181 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %17, i32 0, i32 0
store i32 0, i32* %181
%182 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %17, i32 0, i32 1
store i32 0, i32* %182
%183 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %17, i32 0, i32 2
store i32 0, i32* %183
%184 = call i32 (%struct.foo_type.0*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (%struct.foo_type.0*, i64, ...)*)(%struct.foo_type.0* %17, i64 12)
%185 = sext i32 %184 to i64
%186 = inttoptr i64 %185 to %struct.foo_type.0*
store %struct.foo_type.0* %186, %struct.foo_type.0** %16
%187 = load %struct.foo_type.0*, %struct.foo_type.0** %16
%188 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %187, i32 0, i32 0
%189 = load i32, i32* %188
%190 = icmp eq i32 %189, 0
%191 = zext i1 %190 to i32
%192 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %191)
%193 = load %struct.foo_type.0*, %struct.foo_type.0** %16
%194 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %193, i32 0, i32 1
%195 = load i32, i32* %194
%196 = icmp eq i32 %195, 0
%197 = zext i1 %196 to i32
%198 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %197)
%199 = load %struct.foo_type.0*, %struct.foo_type.0** %16
%200 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %199, i32 0, i32 2
%201 = load i32, i32* %200
%202 = icmp eq i32 %201, 0
%203 = zext i1 %202 to i32
%204 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %203)
%205 = load %struct.foo_type.0*, %struct.foo_type.0** %16
%206 = bitcast %struct.foo_type.0* %205 to i8*
ret void
}

LLVM IR (-O2):
%struct.foo_type = type { i32, i8, double }
%struct.foo_type.0 = type { i32, i32, i32 }
@constinit = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
define void @macro_new_test() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [5 x i32]
%4 = alloca [1000 x i32]
%5 = alloca [1000 x i32]
%6 = alloca %struct.foo_type
%7 = alloca %struct.foo_type
%8 = alloca %struct.foo_type.0
store i32 42, i32* %1
%9 = call i32 (i32*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (i32*, i64, ...)*)(i32* %1, i64 4)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 42
%14 = zext i1 %13 to i32
%15 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %14)
%16 = inttoptr i64 %10 to i8*
store i8 76, i8* %2
%17 = call i32 (i8*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (i8*, i64, ...)*)(i8* %2, i64 1)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 76
%22 = zext i1 %21 to i32
%23 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %22)
%24 = bitcast [5 x i32]* %3 to i8*
%25 = call i32 ([5 x i32]*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 ([5 x i32]*, i64, ...)*)([5 x i32]* %3, i64 20)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %30)
%32 = getelementptr inbounds i32, i32* %27, i64 1
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
%36 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %35)
%37 = getelementptr inbounds i32, i32* %27, i64 2
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 2
%40 = zext i1 %39 to i32
%41 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %40)
%42 = getelementptr inbounds i32, i32* %27, i64 3
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 3
%45 = zext i1 %44 to i32
%46 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %45)
%47 = getelementptr inbounds i32, i32* %27, i64 4
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 4
%50 = zext i1 %49 to i32
%51 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %50)
%52 = inttoptr i64 %26 to i8*
%53 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 1
%54 = bitcast i32* %53 to i8*
%55 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 0
store i32 1, i32* %55
%56 = call i32 ([1000 x i32]*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 ([1000 x i32]*, i64, ...)*)([1000 x i32]* %4, i64 4000)
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i32*
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, 1
%61 = zext i1 %60 to i32
%62 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %61)
br label %69
63: ; preds = %69
%64 = inttoptr i64 %57 to i8*
%65 = bitcast [1000 x i32]* %5 to i8*
%66 = call i32 ([1000 x i32]*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 ([1000 x i32]*, i64, ...)*)([1000 x i32]* %5, i64 4000)
%67 = sext i32 %66 to i64
%68 = inttoptr i64 %67 to i32*
br label %146
69: ; preds = %0, %69
%70 = phi i64 [ 1, %0 ], [ %76, %69 ]
%71 = getelementptr inbounds i32, i32* %58, i64 %70
%72 = load i32, i32* %71
%73 = icmp eq i32 %72, 0
%74 = zext i1 %73 to i32
%75 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %74)
%76 = add nuw nsw i64 %70, 1
%77 = icmp eq i64 %76, 1000
br i1 %77, label %63, label %69
78: ; preds = %146
%79 = inttoptr i64 %67 to i8*
%80 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %6, i64 0, i32 0
store i32 1, i32* %80
%81 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %6, i64 0, i32 1
store i8 100, i8* %81
%82 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %6, i64 0, i32 2
store double 3.140000e+00, double* %82
%83 = call i32 (%struct.foo_type*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (%struct.foo_type*, i64, ...)*)(%struct.foo_type* %6, i64 16)
%84 = sext i32 %83 to i64
%85 = inttoptr i64 %84 to %struct.foo_type*
%86 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %85, i64 0, i32 0
%87 = load i32, i32* %86
%88 = icmp eq i32 %87, 1
%89 = zext i1 %88 to i32
%90 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %89)
%91 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %85, i64 0, i32 1
%92 = load i8, i8* %91
%93 = icmp eq i8 %92, 100
%94 = zext i1 %93 to i32
%95 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %94)
%96 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %85, i64 0, i32 2
%97 = load double, double* %96
%98 = fcmp oeq double %97, 3.140000e+00
%99 = zext i1 %98 to i32
%100 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %99)
%101 = inttoptr i64 %84 to i8*
%102 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %7, i64 0, i32 0
store i32 42, i32* %102
%103 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %7, i64 0, i32 1
store i8 71, i8* %103
%104 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %7, i64 0, i32 2
store double 1.230000e+00, double* %104
%105 = call i32 (%struct.foo_type*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (%struct.foo_type*, i64, ...)*)(%struct.foo_type* %7, i64 16)
%106 = sext i32 %105 to i64
%107 = inttoptr i64 %106 to %struct.foo_type*
%108 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %107, i64 0, i32 0
%109 = load i32, i32* %108
%110 = icmp eq i32 %109, 42
%111 = zext i1 %110 to i32
%112 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %111)
%113 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %107, i64 0, i32 1
%114 = load i8, i8* %113
%115 = icmp eq i8 %114, 71
%116 = zext i1 %115 to i32
%117 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %116)
%118 = getelementptr inbounds %struct.foo_type, %struct.foo_type* %107, i64 0, i32 2
%119 = load double, double* %118
%120 = fcmp oeq double %119, 1.230000e+00
%121 = zext i1 %120 to i32
%122 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %121)
%123 = inttoptr i64 %106 to i8*
%124 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %8, i64 0, i32 0
store i32 0, i32* %124
%125 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %8, i64 0, i32 1
store i32 0, i32* %125
%126 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %8, i64 0, i32 2
store i32 0, i32* %126
%127 = call i32 (%struct.foo_type.0*, i64, ...) bitcast (i32 (...)* @clone_memory to i32 (%struct.foo_type.0*, i64, ...)*)(%struct.foo_type.0* %8, i64 12)
%128 = sext i32 %127 to i64
%129 = inttoptr i64 %128 to %struct.foo_type.0*
%130 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %129, i64 0, i32 0
%131 = load i32, i32* %130
%132 = icmp eq i32 %131, 0
%133 = zext i1 %132 to i32
%134 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %133)
%135 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %129, i64 0, i32 1
%136 = load i32, i32* %135
%137 = icmp eq i32 %136, 0
%138 = zext i1 %137 to i32
%139 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %138)
%140 = getelementptr inbounds %struct.foo_type.0, %struct.foo_type.0* %129, i64 0, i32 2
%141 = load i32, i32* %140
%142 = icmp eq i32 %141, 0
%143 = zext i1 %142 to i32
%144 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %143)
%145 = inttoptr i64 %128 to i8*
ret void
146: ; preds = %63, %146
%147 = phi i64 [ 0, %63 ], [ %153, %146 ]
%148 = getelementptr inbounds i32, i32* %68, i64 %147
%149 = load i32, i32* %148
%150 = icmp eq i32 %149, 0
%151 = zext i1 %150 to i32
%152 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %151)
%153 = add nuw nsw i64 %147, 1
%154 = icmp eq i64 %153, 1000
br i1 %154, label %78, label %146
}