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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fm_play_sample(float);
int lseek(int, long, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, char);
int /*<<< orphan*/ read(int, short *, int);
void playWav(char *filename) {
  int fp = open(filename, 'r');
  int sz = lseek(fp, 0L, SEEK_END);
  int j;
  lseek(fp, 0L, SEEK_SET);
  short *data = (short *)malloc(sz);
  read(fp, data, sz);
  for (j = 22; j < sz / 2; j++)
    fm_play_sample((float)(data[j]) / 65536.0);
}


x86 assembly (clang, -O0):
<playWav>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x72,%esi
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <lseek@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <lseek@plt>
mov    -0x10(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <read@plt>
movl   $0x16,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    1211 <playWav+0xc1>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <fm_play_sample@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <playWav+0x6c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<playWav>:
push   %rbp
push   %r14
push   %rbx
mov    $0x72,%esi
call   1060 <open@plt>
mov    %eax,%ebp
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <lseek@plt>
mov    %eax,%r14d
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <lseek@plt>
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    %r14d,%edx
call   1040 <read@plt>
cmp    $0x2e,%r14d
jl     11d5 <playWav+0x85>
shr    %r14d
mov    $0x16,%ebp
nopl   (%rax)
movswl (%rbx,%rbp,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe3d(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <fm_play_sample@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11b0 <playWav+0x60>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define void @playWav(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i16*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @open(i8* %7, i8 signext 114)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = load i32, i32* @SEEK_END
%11 = call i32 @lseek(i32 %9, i64 0, i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %3
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @lseek(i32 %12, i64 0, i32 %13)
%15 = load i32, i32* %4
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i16*
store i16* %17, i16** %6
%18 = load i32, i32* %3
%19 = load i16*, i16** %6
%20 = load i32, i32* %4
%21 = call i32 @read(i32 %18, i16* %19, i32 %20)
store i32 22, i32* %5
br label %22
22: ; preds = %38, %1
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = sdiv i32 %24, 2
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %41
27: ; preds = %22
%28 = load i16*, i16** %6
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i16, i16* %28, i64 %30
%32 = load i16, i16* %31
%33 = sitofp i16 %32 to float
%34 = fpext float %33 to double
%35 = fdiv double %34, 6.553600e+04
%36 = fptrunc double %35 to float
%37 = call i32 @fm_play_sample(float %36)
br label %38
38: ; preds = %27
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %22
41: ; preds = %22
ret void
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define void @playWav(i8* nocapture %0) {
%2 = tail call i32 @open(i8* %0, i8 signext 114)
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @lseek(i32 %2, i64 0, i32 %3)
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @lseek(i32 %2, i64 0, i32 %5)
%7 = tail call i64 @malloc(i32 %4)
%8 = inttoptr i64 %7 to i16*
%9 = tail call i32 @read(i32 %2, i16* %8, i32 %4)
%10 = icmp sgt i32 %4, 45
br i1 %10, label %11, label %24
11: ; preds = %1
%12 = lshr i32 %4, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 22, %11 ], [ %22, %14 ]
%16 = getelementptr inbounds i16, i16* %8, i64 %15
%17 = load i16, i16* %16
%18 = sitofp i16 %17 to double
%19 = fmul double %18, 0x3EF0000000000000
%20 = fptrunc double %19 to float
%21 = tail call i32 @fm_play_sample(float %20)
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %13
br i1 %23, label %24, label %14
24: ; preds = %14, %1
ret void
}