#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*/ gzFile;

/* Variables and functions */
int /*<<< orphan*/ gzclose(int /*<<< orphan*/);
int /*<<< orphan*/ gzopen(char *, char *);
int /*<<< orphan*/ gzread(int /*<<< orphan*/, int *, int const);
int /*<<< orphan*/ gzwrite(int /*<<< orphan*/, int *, int const);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  const int N = 10;
  int arr[N];
  for (int i = 0; i < N; i++) {
    const int mul = 9;
    arr[i] = mul * i;
  }
  gzFile file = gzopen("mem.dump.gz", "wb9");
  gzwrite(file, arr, N * sizeof(int));
  gzclose(file);
  for (int i = 0; i < N; i++) {
    arr[i] = 0;
  }
  file = gzopen("mem.dump.gz", "rb");
  gzread(file, arr, N * sizeof(int));
  gzclose(file);
  for (int i = 0; i < N; i++) {
    printf("arr[%d] = %d\n", i, arr[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    119f <main+0x4f>
movl   $0x9,-0x18(%rbp)
imul   $0x9,-0x14(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x24>
lea    0xe5a(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1070 <gzopen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x28,%edx
call   1060 <gzwrite@plt>
mov    -0x1c(%rbp),%edi
call   1030 <gzclose@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0xa,-0x20(%rbp)
jge    11f9 <main+0xa9>
movslq -0x20(%rbp),%rax
movl   $0x0,-0x50(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d5 <main+0x85>
lea    0xe00(%rip),%rdi
lea    0xe09(%rip),%rsi
call   1070 <gzopen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x28,%edx
call   1050 <gzread@plt>
mov    -0x1c(%rbp),%edi
call   1030 <gzclose@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    125e <main+0x10e>
mov    -0x24(%rbp),%esi
movslq -0x24(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xdc8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    122f <main+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xea1(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x5100000048,%rax
mov    %rax,0x20(%rsp)
lea    0xe9b(%rip),%r14
lea    0xea0(%rip),%rsi
mov    %r14,%rdi
call   1070 <gzopen@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x28,%edx
call   1060 <gzwrite@plt>
mov    %ebp,%edi
call   1030 <gzclose@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe65(%rip),%rsi
mov    %r14,%rdi
call   1070 <gzopen@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x28,%edx
call   1050 <gzread@plt>
mov    %ebp,%edi
call   1030 <gzclose@plt>
mov    (%rsp),%edx
lea    0xe3e(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <printf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"mem.dump.gz\00"
@.str.1 = [4 x i8] c"wb9\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [14 x i8] c"arr[%d] = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i32, i64 10
store i32 0, i32* %4
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %23
14: ; preds = %11
store i32 9, i32* %5
%15 = load i32, i32* %4
%16 = mul nsw i32 9, %15
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %10, i64 %18
store i32 %16, i32* %19
br label %20
20: ; preds = %14
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %11
23: ; preds = %11
%24 = call i32 @gzopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = call i32 @gzwrite(i32 %25, i32* %10, i32 40)
%27 = load i32, i32* %6
%28 = call i32 @gzclose(i32 %27)
store i32 0, i32* %7
br label %29
29: ; preds = %36, %23
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 10
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %10, i64 %34
store i32 0, i32* %35
br label %36
36: ; preds = %32
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %29
39: ; preds = %29
%40 = call i32 @gzopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = call i32 @gzread(i32 %41, i32* %10, i32 40)
%43 = load i32, i32* %6
%44 = call i32 @gzclose(i32 %43)
store i32 0, i32* %8
br label %45
45: ; preds = %55, %39
%46 = load i32, i32* %8
%47 = icmp slt i32 %46, 10
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i32, i32* %8
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %10, i64 %51
%53 = load i32, i32* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %53)
br label %55
55: ; preds = %48
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %45
58: ; preds = %45
store i32 0, i32* %1
%59 = load i8*, i8** %3
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [12 x i8] c"mem.dump.gz\00"
@.str.1 = [4 x i8] c"wb9\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [14 x i8] c"arr[%d] = %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%7 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 9, i32 18, i32 27>, <4 x i32>* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%12 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 36, i32 45, i32 54, i32 63>, <4 x i32>* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 72, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 81, i32* %14
%15 = tail call i32 @gzopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @gzwrite(i32 %15, i32* %3, i32 40)
%17 = call i32 @gzclose(i32 %15)
%18 = call i32 @gzopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @gzread(i32 %18, i32* %3, i32 40)
%20 = call i32 @gzclose(i32 %18)
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %23)
%25 = load i32, i32* %5
%26 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %27)
%29 = load i32, i32* %8
%30 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %29)
%31 = load i32, i32* %9
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %31)
%33 = load i32, i32* %10
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %33)
%35 = load i32, i32* %11
%36 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %35)
%37 = load i32, i32* %13
%38 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 8, i32 %37)
%39 = load i32, i32* %14
%40 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 9, i32 %39)
ret i32 0
}