#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 const *, char *);
int /*<<< orphan*/ gzread(int /*<<< orphan*/ *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ message(char *, ...);
float *parse_amp(const char *fname) {
  gzFile *f;
  int count;
  float *values;
  message("amp: %s\n", fname);
  f = gzopen(fname, "r");
  gzread(f, &count, sizeof(int));
  message("count = %d\n", count);
  values = (float *)malloc(sizeof(float) * count);
  gzread(f, values, sizeof(float) * count);
  gzclose(f);
  return values;
}


x86 assembly (clang, -O0):
<parse_amp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <message@plt>
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1070 <gzopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <gzread@plt>
mov    -0x14(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <message@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movslq -0x14(%rbp),%rdx
shl    $0x2,%rdx
mov    $0x0,%al
call   1050 <gzread@plt>
mov    -0x10(%rbp),%rdi
call   1030 <gzclose@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_amp>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <message@plt>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <gzopen@plt>
mov    %rax,%r14
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <gzread@plt>
mov    0x4(%rsp),%esi
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1040 <message@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movslq 0x4(%rsp),%rdx
shl    $0x2,%rdx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <gzread@plt>
mov    %r14,%rdi
call   1030 <gzclose@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"amp: %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"count = %d\0A\00"
define float* @parse_amp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca float*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 (i8*, ...) @message(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %2
%9 = call i32* @gzopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
%10 = load i32*, i32** %3
%11 = call i32 (i32*, ...) @gzread(i32* %10, i32* %4, i64 4)
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = mul i64 4, %15
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to float*
store float* %19, float** %5
%20 = load i32*, i32** %3
%21 = load float*, float** %5
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = mul i64 4, %23
%25 = call i32 (i32*, ...) @gzread(i32* %20, float* %21, i64 %24)
%26 = load i32*, i32** %3
%27 = call i32 @gzclose(i32* %26)
%28 = load float*, float** %5
ret float* %28
}

LLVM IR (-O2):
@.str = [9 x i8] c"amp: %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"count = %d\0A\00"
define float* @parse_amp(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (i8*, ...) @message(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32* @gzopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i32*, ...) @gzread(i32* %5, i32* %2, i64 4)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = shl i32 %9, 2
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to float*
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = shl nsw i64 %14, 2
%16 = call i32 (i32*, ...) @gzread(i32* %5, float* %12, i64 %15)
%17 = call i32 @gzclose(i32* %5)
ret float* %12
}