; LLVM IR from jingweizhanghuai/Morn :: src/wave (morn_WAV_file)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.MWAVHeader = type { i16, i16, i32, i32, i16, i16 }
%struct.MWave = type { i32, i32, [32 x ptr] }

@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [10 x i8], align 1
@__FUNCTION__.WAVSave = external hidden unnamed_addr constant [8 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare ptr @m_Malloc(i32 noundef) #1

declare void @m_Free(ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @WAVSave(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.MWAVHeader, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %25, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = ptrtoint ptr %22 to i64
  %24 = icmp eq i64 %23, -1
  br i1 %24, label %25, label %26

25:                                               ; preds = %21, %18
  br label %50

26:                                               ; preds = %21
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.MWave, ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds [32 x ptr], ptr %28, i64 0, i64 0
  %30 = icmp eq ptr %29, null
  br i1 %30, label %47, label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.MWave, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds [32 x ptr], ptr %33, i64 0, i64 0
  %35 = ptrtoint ptr %34 to i64
  %36 = icmp eq i64 %35, -1
  br i1 %36, label %47, label %37

37:                                               ; preds = %31
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MWave, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !9
  %41 = icmp sle i32 %40, 0
  br i1 %41, label %47, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.MWave, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !12
  %46 = icmp sle i32 %45, 0
  br label %47

47:                                               ; preds = %42, %37, %31, %26
  %48 = phi i1 [ true, %37 ], [ true, %31 ], [ true, %26 ], [ %46, %42 ]
  %49 = zext i1 %48 to i32
  br label %50

50:                                               ; preds = %47, %25
  %51 = phi i32 [ 1, %25 ], [ %49, %47 ]
  store i32 %51, ptr %5, align 4, !tbaa !13
  %52 = load i32, ptr %5, align 4, !tbaa !13
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %50
  %55 = load i32, ptr %5, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %55, i32 noundef -1, ptr noundef @.str, i32 noundef 143, ptr noundef @__FUNCTION__.WAVSave, ptr noundef @.str.10)
  br label %56

56:                                               ; preds = %54, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.MWave, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !9
  %62 = icmp sgt i32 %61, 2
  %63 = zext i1 %62 to i32
  store i32 %63, ptr %6, align 4, !tbaa !13
  %64 = load i32, ptr %6, align 4, !tbaa !13
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %68

66:                                               ; preds = %58
  %67 = load i32, ptr %6, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %67, i32 noundef -1, ptr noundef @.str, i32 noundef 144, ptr noundef @__FUNCTION__.WAVSave, ptr noundef @.str.10)
  br label %68

68:                                               ; preds = %66, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call noalias ptr @fopen(ptr noundef %70, ptr noundef @.str.11)
  store ptr %71, ptr %7, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = icmp eq ptr %73, null
  %75 = zext i1 %74 to i32
  store i32 %75, ptr %8, align 4, !tbaa !13
  %76 = load i32, ptr %8, align 4, !tbaa !13
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %80

78:                                               ; preds = %72
  %79 = load i32, ptr %8, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %79, i32 noundef -1, ptr noundef @.str, i32 noundef 147, ptr noundef @__FUNCTION__.WAVSave, ptr noundef @.str.12)
  br label %80

80:                                               ; preds = %78, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.MWave, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !12
  %86 = sext i32 %85 to i64
  %87 = mul i64 %86, 2
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.MWave, ptr %88, i32 0, i32 0
  %90 = load i32, ptr %89, align 8, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = mul i64 %87, %91
  %93 = trunc i64 %92 to i32
  store i32 %93, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = call ptr @m_PropertyRead(ptr noundef %94, ptr noundef @.str.13, ptr noundef %10, ptr noundef null)
  br label %96

96:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %97 = load float, ptr %10, align 4, !tbaa !14
  %98 = call i1 @llvm.is.fpclass.f32(float %97, i32 3)
  %99 = zext i1 %98 to i32
  store i32 %99, ptr %11, align 4, !tbaa !13
  %100 = load i32, ptr %11, align 4, !tbaa !13
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %104

102:                                              ; preds = %96
  %103 = load i32, ptr %11, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %103, i32 noundef -1, ptr noundef @.str, i32 noundef 151, ptr noundef @__FUNCTION__.WAVSave, ptr noundef @.str.14)
  br label %104

104:                                              ; preds = %102, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %105

105:                                              ; preds = %104
  br label %106

106:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %107 = getelementptr inbounds %struct.MWAVHeader, ptr %12, i32 0, i32 0
  store i16 1, ptr %107, align 4, !tbaa !16
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.MWave, ptr %108, i32 0, i32 0
  %110 = load i32, ptr %109, align 8, !tbaa !9
  %111 = trunc i32 %110 to i16
  %112 = getelementptr inbounds %struct.MWAVHeader, ptr %12, i32 0, i32 1
  store i16 %111, ptr %112, align 2, !tbaa !19
  %113 = load float, ptr %10, align 4, !tbaa !14
  %114 = fptosi float %113 to i32
  %115 = getelementptr inbounds %struct.MWAVHeader, ptr %12, i32 0, i32 2
  store i32 %114, ptr %115, align 4, !tbaa !20
  %116 = load float, ptr %10, align 4, !tbaa !14
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.MWave, ptr %117, i32 0, i32 0
  %119 = load i32, ptr %118, align 8, !tbaa !9
  %120 = shl i32 %119, 1
  %121 = sitofp i32 %120 to float
  %122 = fmul float %116, %121
  %123 = fptosi float %122 to i32
  %124 = getelementptr inbounds %struct.MWAVHeader, ptr %12, i32 0, i32 3
  store i32 %123, ptr %124, align 4, !tbaa !21
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.MWave, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 8, !tbaa !9
  %128 = shl i32 %127, 1
  %129 = trunc i32 %128 to i16
  %130 = getelementptr inbounds %struct.MWAVHeader, ptr %12, i32 0, i32 4
  store i16 %129, ptr %130, align 4, !tbaa !22
  %131 = getelementptr inbounds %struct.MWAVHeader, ptr %12, i32 0, i32 5
  store i16 16, ptr %131, align 2, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = call i64 @fwrite(ptr noundef @.str.2, i64 noundef 1, i64 noundef 4, ptr noundef %132)
  %134 = load i32, ptr %9, align 4, !tbaa !13
  %135 = add nsw i32 %134, 36
  store i32 %135, ptr %13, align 4, !tbaa !13
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = call i64 @fwrite(ptr noundef %13, i64 noundef 4, i64 noundef 1, ptr noundef %136)
  %138 = load ptr, ptr %7, align 8, !tbaa !5
  %139 = call i64 @fwrite(ptr noundef @.str.4, i64 noundef 1, i64 noundef 4, ptr noundef %138)
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = call i64 @fwrite(ptr noundef @.str.7, i64 noundef 1, i64 noundef 4, ptr noundef %140)
  store i32 16, ptr %13, align 4, !tbaa !13
  %142 = load ptr, ptr %7, align 8, !tbaa !5
  %143 = call i64 @fwrite(ptr noundef %13, i64 noundef 4, i64 noundef 1, ptr noundef %142)
  %144 = load ptr, ptr %7, align 8, !tbaa !5
  %145 = call i64 @fwrite(ptr noundef %12, i64 noundef 16, i64 noundef 1, ptr noundef %144)
  %146 = load ptr, ptr %7, align 8, !tbaa !5
  %147 = call i64 @fwrite(ptr noundef @.str.9, i64 noundef 1, i64 noundef 4, ptr noundef %146)
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = call i64 @fwrite(ptr noundef %9, i64 noundef 4, i64 noundef 1, ptr noundef %148)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %150 = load i32, ptr %9, align 4, !tbaa !13
  %151 = call ptr @m_Malloc(i32 noundef %150)
  store ptr %151, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %15, align 4, !tbaa !13
  store i32 0, ptr %16, align 4, !tbaa !13
  br label %152

152:                                              ; preds = %229, %106
  %153 = load i32, ptr %15, align 4, !tbaa !13
  %154 = load ptr, ptr %3, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.MWave, ptr %154, i32 0, i32 1
  %156 = load i32, ptr %155, align 4, !tbaa !12
  %157 = icmp slt i32 %153, %156
  br i1 %157, label %158, label %237

158:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !13
  br label %159

159:                                              ; preds = %225, %158
  %160 = load i32, ptr %17, align 4, !tbaa !13
  %161 = load ptr, ptr %3, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.MWave, ptr %161, i32 0, i32 0
  %163 = load i32, ptr %162, align 8, !tbaa !9
  %164 = icmp slt i32 %160, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %228

166:                                              ; preds = %159
  %167 = load ptr, ptr %3, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.MWave, ptr %167, i32 0, i32 2
  %169 = load i32, ptr %17, align 4, !tbaa !13
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [32 x ptr], ptr %168, i64 0, i64 %170
  %172 = load ptr, ptr %171, align 8, !tbaa !5
  %173 = load i32, ptr %15, align 4, !tbaa !13
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds float, ptr %172, i64 %174
  %176 = load float, ptr %175, align 4, !tbaa !14
  %177 = fcmp oge float %176, 1.000000e+00
  br i1 %177, label %178, label %185

178:                                              ; preds = %166
  %179 = load ptr, ptr %14, align 8, !tbaa !5
  %180 = load i32, ptr %16, align 4, !tbaa !13
  %181 = load i32, ptr %17, align 4, !tbaa !13
  %182 = add nsw i32 %180, %181
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds i16, ptr %179, i64 %183
  store i16 32767, ptr %184, align 2, !tbaa !24
  br label %224

185:                                              ; preds = %166
  %186 = load ptr, ptr %3, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.MWave, ptr %186, i32 0, i32 2
  %188 = load i32, ptr %17, align 4, !tbaa !13
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [32 x ptr], ptr %187, i64 0, i64 %189
  %191 = load ptr, ptr %190, align 8, !tbaa !5
  %192 = load i32, ptr %15, align 4, !tbaa !13
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds float, ptr %191, i64 %193
  %195 = load float, ptr %194, align 4, !tbaa !14
  %196 = fcmp ole float %195, -1.000000e+00
  br i1 %196, label %197, label %204

197:                                              ; preds = %185
  %198 = load ptr, ptr %14, align 8, !tbaa !5
  %199 = load i32, ptr %16, align 4, !tbaa !13
  %200 = load i32, ptr %17, align 4, !tbaa !13
  %201 = add nsw i32 %199, %200
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds i16, ptr %198, i64 %202
  store i16 -32768, ptr %203, align 2, !tbaa !24
  br label %223

204:                                              ; preds = %185
  %205 = load ptr, ptr %3, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.MWave, ptr %205, i32 0, i32 2
  %207 = load i32, ptr %17, align 4, !tbaa !13
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [32 x ptr], ptr %206, i64 0, i64 %208
  %210 = load ptr, ptr %209, align 8, !tbaa !5
  %211 = load i32, ptr %15, align 4, !tbaa !13
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds float, ptr %210, i64 %212
  %214 = load float, ptr %213, align 4, !tbaa !14
  %215 = fmul float %214, 3.276800e+04
  %216 = fptosi float %215 to i16
  %217 = load ptr, ptr %14, align 8, !tbaa !5
  %218 = load i32, ptr %16, align 4, !tbaa !13
  %219 = load i32, ptr %17, align 4, !tbaa !13
  %220 = add nsw i32 %218, %219
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds i16, ptr %217, i64 %221
  store i16 %216, ptr %222, align 2, !tbaa !24
  br label %223

223:                                              ; preds = %204, %197
  br label %224

224:                                              ; preds = %223, %178
  br label %225

225:                                              ; preds = %224
  %226 = load i32, ptr %17, align 4, !tbaa !13
  %227 = add nsw i32 %226, 1
  store i32 %227, ptr %17, align 4, !tbaa !13
  br label %159, !llvm.loop !25

228:                                              ; preds = %165
  br label %229

229:                                              ; preds = %228
  %230 = load i32, ptr %15, align 4, !tbaa !13
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %15, align 4, !tbaa !13
  %232 = load i32, ptr %16, align 4, !tbaa !13
  %233 = load ptr, ptr %3, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.MWave, ptr %233, i32 0, i32 0
  %235 = load i32, ptr %234, align 8, !tbaa !9
  %236 = add nsw i32 %232, %235
  store i32 %236, ptr %16, align 4, !tbaa !13
  br label %152, !llvm.loop !27

237:                                              ; preds = %152
  %238 = load ptr, ptr %14, align 8, !tbaa !5
  %239 = load i32, ptr %9, align 4, !tbaa !13
  %240 = sext i32 %239 to i64
  %241 = load ptr, ptr %7, align 8, !tbaa !5
  %242 = call i64 @fwrite(ptr noundef %238, i64 noundef %240, i64 noundef 1, ptr noundef %241)
  %243 = load ptr, ptr %14, align 8, !tbaa !5
  call void @m_Free(ptr noundef %243)
  %244 = load ptr, ptr %7, align 8, !tbaa !5
  %245 = call i32 @fclose(ptr noundef %244)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

declare ptr @m_PropertyRead(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #3

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"MWave", !11, i64 0, !11, i64 4, !7, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!17, !18, i64 0}
!17 = !{!"MWAVHeader", !18, i64 0, !18, i64 2, !11, i64 4, !11, i64 8, !18, i64 12, !18, i64 14}
!18 = !{!"short", !7, i64 0}
!19 = !{!17, !18, i64 2}
!20 = !{!17, !11, i64 4}
!21 = !{!17, !11, i64 8}
!22 = !{!17, !18, i64 12}
!23 = !{!17, !18, i64 14}
!24 = !{!18, !18, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.MWAVHeader = type { i16, i16, i32, i32, i16, i16 }

@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [10 x i8], align 1
@__FUNCTION__.WAVSave = external hidden unnamed_addr constant [8 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #1

declare void @m_Free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @WAVSave(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca %struct.MWAVHeader, align 4
  %6 = alloca i32, align 4
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %7 [
    i64 -1, label %.critedge
    i64 0, label %.critedge
  ]

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = icmp eq ptr %8, inttoptr (i64 -1 to ptr)
  br i1 %9, label %.critedge, label %10

10:                                               ; preds = %7
  %11 = load i32, ptr %0, align 8, !tbaa !5
  %12 = icmp slt i32 %11, 1
  br i1 %12, label %.critedge, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !10
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %.critedge

.critedge:                                        ; preds = %2, %2, %10, %7, %13
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 143, ptr noundef nonnull @__FUNCTION__.WAVSave, ptr noundef nonnull @.str.10) #4
  %.pre = load i32, ptr %0, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %.critedge, %13
  %18 = phi i32 [ %.pre, %.critedge ], [ %11, %13 ]
  %19 = icmp sgt i32 %18, 2
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 144, ptr noundef nonnull @__FUNCTION__.WAVSave, ptr noundef nonnull @.str.10) #4
  br label %21

21:                                               ; preds = %20, %17
  %22 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.11)
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 147, ptr noundef nonnull @__FUNCTION__.WAVSave, ptr noundef nonnull @.str.12) #4
  br label %25

25:                                               ; preds = %24, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %26 = getelementptr inbounds i8, ptr %0, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !10
  %28 = shl i32 %27, 1
  %29 = load i32, ptr %0, align 8, !tbaa !5
  %30 = mul i32 %28, %29
  store i32 %30, ptr %3, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %31 = call ptr @m_PropertyRead(ptr noundef nonnull %0, ptr noundef nonnull @.str.13, ptr noundef nonnull %4, ptr noundef null) #4
  %32 = load float, ptr %4, align 4, !tbaa !12
  %33 = fcmp uno float %32, 0.000000e+00
  br i1 %33, label %34, label %35

34:                                               ; preds = %25
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 151, ptr noundef nonnull @__FUNCTION__.WAVSave, ptr noundef nonnull @.str.14) #4
  %.pre88 = load float, ptr %4, align 4, !tbaa !12
  br label %35

35:                                               ; preds = %34, %25
  %36 = phi float [ %.pre88, %34 ], [ %32, %25 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  store i16 1, ptr %5, align 4, !tbaa !14
  %37 = load i32, ptr %0, align 8, !tbaa !5
  %38 = trunc i32 %37 to i16
  %39 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 %38, ptr %39, align 2, !tbaa !17
  %40 = getelementptr inbounds i8, ptr %5, i64 4
  %41 = shl i32 %37, 1
  %42 = sitofp i32 %41 to float
  %43 = fmul float %36, %42
  %44 = insertelement <2 x float> poison, float %36, i64 0
  %45 = insertelement <2 x float> %44, float %43, i64 1
  %46 = fptosi <2 x float> %45 to <2 x i32>
  store <2 x i32> %46, ptr %40, align 4, !tbaa !11
  %47 = shl i16 %38, 1
  %48 = getelementptr inbounds i8, ptr %5, i64 12
  store i16 %47, ptr %48, align 4, !tbaa !18
  %49 = getelementptr inbounds i8, ptr %5, i64 14
  store i16 16, ptr %49, align 2, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %50 = call i64 @fwrite(ptr noundef nonnull @.str.2, i64 noundef 1, i64 noundef 4, ptr noundef %22)
  %51 = add nsw i32 %30, 36
  store i32 %51, ptr %6, align 4, !tbaa !11
  %52 = call i64 @fwrite(ptr noundef nonnull %6, i64 noundef 4, i64 noundef 1, ptr noundef %22)
  %53 = call i64 @fwrite(ptr noundef nonnull @.str.4, i64 noundef 1, i64 noundef 4, ptr noundef %22)
  %54 = call i64 @fwrite(ptr noundef nonnull @.str.7, i64 noundef 1, i64 noundef 4, ptr noundef %22)
  store i32 16, ptr %6, align 4, !tbaa !11
  %55 = call i64 @fwrite(ptr noundef nonnull %6, i64 noundef 4, i64 noundef 1, ptr noundef %22)
  %56 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 16, i64 noundef 1, ptr noundef %22)
  %57 = call i64 @fwrite(ptr noundef nonnull @.str.9, i64 noundef 1, i64 noundef 4, ptr noundef %22)
  %58 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 1, ptr noundef %22)
  %59 = load i32, ptr %3, align 4, !tbaa !11
  %60 = call ptr @m_Malloc(i32 noundef %59) #4
  %61 = load i32, ptr %26, align 4, !tbaa !10
  %62 = icmp sgt i32 %61, 0
  br i1 %62, label %.preheader.lr.ph, label %._crit_edge76

.preheader.lr.ph:                                 ; preds = %35
  %63 = load i32, ptr %0, align 8, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  %65 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %64, label %.preheader.us.preheader, label %._crit_edge76

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %66 = zext nneg i32 %63 to i64
  %wide.trip.count86 = zext nneg i32 %61 to i64
  %xtraiter = and i64 %66, 1
  %67 = icmp eq i32 %63, 1
  %unroll_iter = and i64 %66, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv81 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next82, %._crit_edge.us ]
  %indvars.iv79 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next80, %._crit_edge.us ]
  br i1 %67, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us
  %invariant.gep91.sink = getelementptr inbounds i16, ptr %60, i64 %indvars.iv79
  %invariant.gep91.sink.1 = getelementptr inbounds i16, ptr %60, i64 %indvars.iv79
  br label %68

68:                                               ; preds = %90, %.preheader.us.new
  %indvars.iv = phi i64 [ 0, %.preheader.us.new ], [ %indvars.iv.next.1, %90 ]
  %niter = phi i64 [ 0, %.preheader.us.new ], [ %niter.next.1, %90 ]
  %69 = getelementptr inbounds [32 x ptr], ptr %65, i64 0, i64 %indvars.iv
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  %71 = getelementptr inbounds float, ptr %70, i64 %indvars.iv81
  %72 = load float, ptr %71, align 4, !tbaa !12
  %73 = fcmp ult float %72, 1.000000e+00
  br i1 %73, label %74, label %79

74:                                               ; preds = %68
  %75 = fcmp ugt float %72, -1.000000e+00
  br i1 %75, label %76, label %79

76:                                               ; preds = %74
  %77 = fmul float %72, 3.276800e+04
  %78 = fptosi float %77 to i16
  br label %79

79:                                               ; preds = %74, %68, %76
  %.sink = phi i16 [ %78, %76 ], [ 32767, %68 ], [ -32768, %74 ]
  %gep92 = getelementptr inbounds i16, ptr %invariant.gep91.sink, i64 %indvars.iv
  store i16 %.sink, ptr %gep92, align 2, !tbaa !22
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %80 = getelementptr inbounds [32 x ptr], ptr %65, i64 0, i64 %indvars.iv.next
  %81 = load ptr, ptr %80, align 8, !tbaa !20
  %82 = getelementptr inbounds float, ptr %81, i64 %indvars.iv81
  %83 = load float, ptr %82, align 4, !tbaa !12
  %84 = fcmp ult float %83, 1.000000e+00
  br i1 %84, label %85, label %90

85:                                               ; preds = %79
  %86 = fcmp ugt float %83, -1.000000e+00
  br i1 %86, label %87, label %90

87:                                               ; preds = %85
  %88 = fmul float %83, 3.276800e+04
  %89 = fptosi float %88 to i16
  br label %90

90:                                               ; preds = %87, %85, %79
  %.sink.1 = phi i16 [ %89, %87 ], [ 32767, %79 ], [ -32768, %85 ]
  %gep92.1 = getelementptr inbounds i16, ptr %invariant.gep91.sink.1, i64 %indvars.iv.next
  store i16 %.sink.1, ptr %gep92.1, align 2, !tbaa !22
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %68, !llvm.loop !23

._crit_edge.us.unr-lcssa:                         ; preds = %90, %.preheader.us
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next.1, %90 ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa
  %91 = getelementptr inbounds [32 x ptr], ptr %65, i64 0, i64 %indvars.iv.unr
  %92 = load ptr, ptr %91, align 8, !tbaa !20
  %93 = getelementptr inbounds float, ptr %92, i64 %indvars.iv81
  %94 = load float, ptr %93, align 4, !tbaa !12
  %95 = fcmp ult float %94, 1.000000e+00
  br i1 %95, label %96, label %._crit_edge.us.epilog-lcssa

96:                                               ; preds = %.epil.preheader
  %97 = fcmp ugt float %94, -1.000000e+00
  br i1 %97, label %98, label %._crit_edge.us.epilog-lcssa

98:                                               ; preds = %96
  %99 = fmul float %94, 3.276800e+04
  %100 = fptosi float %99 to i16
  br label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %98, %96, %.epil.preheader
  %.sink.epil = phi i16 [ %100, %98 ], [ 32767, %.epil.preheader ], [ -32768, %96 ]
  %invariant.gep91.sink.epil = getelementptr inbounds i16, ptr %60, i64 %indvars.iv79
  %gep92.epil = getelementptr inbounds i16, ptr %invariant.gep91.sink.epil, i64 %indvars.iv.unr
  store i16 %.sink.epil, ptr %gep92.epil, align 2, !tbaa !22
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, %66
  %exitcond87.not = icmp eq i64 %indvars.iv.next82, %wide.trip.count86
  br i1 %exitcond87.not, label %._crit_edge76, label %.preheader.us, !llvm.loop !25

._crit_edge76:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %35
  %101 = sext i32 %59 to i64
  %102 = call i64 @fwrite(ptr noundef %60, i64 noundef %101, i64 noundef 1, ptr noundef %22)
  call void @m_Free(ptr noundef %60) #4
  %103 = call i32 @fclose(ptr noundef %22)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret void
}

declare ptr @m_PropertyRead(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"MWave", !7, i64 0, !7, i64 4, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"MWAVHeader", !16, i64 0, !16, i64 2, !7, i64 4, !7, i64 8, !16, i64 12, !16, i64 14}
!16 = !{!"short", !8, i64 0}
!17 = !{!15, !16, i64 2}
!18 = !{!15, !16, i64 12}
!19 = !{!15, !16, i64 14}
!20 = !{!21, !21, i64 0}
!21 = !{!"any pointer", !8, i64 0}
!22 = !{!16, !16, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass