int main() {
  double *x = malloc(10);
  double *y = malloc(100);
  double *z = malloc(1000);
  {
    void *stopper_for_apply = (int[]){0};
    void **list_for_apply = (void *[]){x, y, z, stopper_for_apply};
    for (int i = 0; list_for_apply[i] != stopper_for_apply; i++)
      free(list_for_apply[i]);
  };
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x64,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x3e8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x2c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x58(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x28(%rbp),%rax
je     11cc <main+0xac>
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1197 <main+0x77>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    $0x64,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0x3e8,%edi
call   1040 <malloc@plt>
movl   $0x0,0xc(%rsp)
mov    %r15,0x10(%rsp)
lea    0x18(%rsp),%rbx
mov    %r14,0x18(%rsp)
mov    %rax,0x20(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,0x28(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <free@plt>
mov    (%rbx),%r15
add    $0x8,%rbx
cmp    %r14,%r15
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca double*
%4 = alloca double*
%5 = alloca i8*
%6 = alloca [1 x i32]
%7 = alloca i8**
%8 = alloca [4 x i8*]
%9 = alloca i32
store i32 0, i32* %1
%10 = call i8* @malloc(i64 10)
%11 = bitcast i8* %10 to double*
store double* %11, double** %2
%12 = call i8* @malloc(i64 100)
%13 = bitcast i8* %12 to double*
store double* %13, double** %3
%14 = call i8* @malloc(i64 1000)
%15 = bitcast i8* %14 to double*
store double* %15, double** %4
%16 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
store i32 0, i32* %16
%17 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%18 = bitcast i32* %17 to i8*
store i8* %18, i8** %5
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 0
%20 = load double*, double** %2
%21 = bitcast double* %20 to i8*
store i8* %21, i8** %19
%22 = getelementptr inbounds i8*, i8** %19, i64 1
%23 = load double*, double** %3
%24 = bitcast double* %23 to i8*
store i8* %24, i8** %22
%25 = getelementptr inbounds i8*, i8** %22, i64 1
%26 = load double*, double** %4
%27 = bitcast double* %26 to i8*
store i8* %27, i8** %25
%28 = getelementptr inbounds i8*, i8** %25, i64 1
%29 = load i8*, i8** %5
store i8* %29, i8** %28
%30 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 0
store i8** %30, i8*** %7
store i32 0, i32* %9
br label %31
31: ; preds = %45, %0
%32 = load i8**, i8*** %7
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = load i8*, i8** %5
%38 = icmp ne i8* %36, %37
br i1 %38, label %39, label %48
39: ; preds = %31
%40 = load i8**, i8*** %7
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
br label %45
45: ; preds = %39
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %31
48: ; preds = %31
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [1 x i32]
%2 = alloca [4 x i8*]
%3 = tail call dereferenceable_or_null(10) i8* @malloc(i64 10)
%4 = tail call dereferenceable_or_null(100) i8* @malloc(i64 100)
%5 = tail call dereferenceable_or_null(1000) i8* @malloc(i64 1000)
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
store i32 0, i32* %6
%7 = bitcast [1 x i32]* %1 to i8*
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
store i8* %3, i8** %8
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
store i8* %4, i8** %9
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %5, i8** %10
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%12 = bitcast i8** %11 to [1 x i32]**
store [1 x i32]* %1, [1 x i32]** %12
br label %14
13: ; preds = %14
ret i32 0
14: ; preds = %14, %0
%15 = phi i64 [ 0, %0 ], [ %17, %14 ]
%16 = phi i8* [ %3, %0 ], [ %19, %14 ]
%17 = add nuw nsw i64 %15, 1
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, %7
br i1 %20, label %13, label %14
}