; LLVM IR from dbry/wavpack-stream :: cli (dsf)

; 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.DSFFileChunk = type <{ [4 x i8], i64, i64, i64 }>
%struct.DSFFormatChunk = type <{ [4 x i8], i64, i32, i32, i32, i32, i32, i32, i64, i32, i32 }>
%struct.DSFChunkHeader = type <{ [4 x i8], i64 }>

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@debug_logging_mode = external global i32, align 4
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@channel_masks = external hidden constant [7 x i16], align 2
@.str.20 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [43 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare void @error_line(ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @WriteDsfHeader(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca %struct.DSFFileChunk, align 4
  %17 = alloca %struct.DSFFormatChunk, align 4
  %18 = alloca %struct.DSFChunkHeader, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call i32 @WavpackStreamGetChannelMask(ptr noundef %22)
  store i32 %23, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call i32 @WavpackStreamGetNumChannels(ptr noundef %24)
  store i32 %25, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 28, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 52, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %26 = load i32, ptr @debug_logging_mode, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %4
  %29 = load i64, ptr %8, align 8, !tbaa !9
  %30 = load i32, ptr %9, align 4, !tbaa !11
  call void (ptr, ...) @error_line(ptr noundef @.str.20, i64 noundef %29, i32 noundef %30)
  br label %31

31:                                               ; preds = %28, %4
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %48, %31
  %33 = load i32, ptr %20, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = icmp ult i64 %34, 7
  br i1 %35, label %36, label %51

36:                                               ; preds = %32
  %37 = load i32, ptr %10, align 4, !tbaa !11
  %38 = load i32, ptr %20, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [7 x i16], ptr @channel_masks, i64 0, i64 %39
  %41 = load i16, ptr %40, align 2, !tbaa !13
  %42 = zext i16 %41 to i32
  %43 = icmp eq i32 %37, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %36
  %45 = load i32, ptr %20, align 4, !tbaa !11
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %11, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %44, %36
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %20, align 4, !tbaa !11
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %20, align 4, !tbaa !11
  br label %32, !llvm.loop !15

51:                                               ; preds = %32
  %52 = load i32, ptr %11, align 4, !tbaa !11
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %68, label %54

54:                                               ; preds = %51
  %55 = load i32, ptr %12, align 4, !tbaa !11
  %56 = icmp sgt i32 %55, 6
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  store i32 7, ptr %11, align 4, !tbaa !11
  br label %67

58:                                               ; preds = %54
  %59 = load i32, ptr %12, align 4, !tbaa !11
  %60 = icmp sgt i32 %59, 4
  br i1 %60, label %61, label %64

61:                                               ; preds = %58
  %62 = load i32, ptr %12, align 4, !tbaa !11
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %11, align 4, !tbaa !11
  br label %66

64:                                               ; preds = %58
  %65 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %65, ptr %11, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %64, %61
  br label %67

67:                                               ; preds = %66, %57
  br label %68

68:                                               ; preds = %67, %51
  %69 = load i64, ptr %8, align 8, !tbaa !9
  %70 = add nsw i64 %69, 4096
  %71 = sub nsw i64 %70, 1
  %72 = sdiv i64 %71, 4096
  store i64 %72, ptr %14, align 8, !tbaa !9
  %73 = load i64, ptr %14, align 8, !tbaa !9
  %74 = mul nsw i64 %73, 4096
  %75 = load i32, ptr %12, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = mul nsw i64 %74, %76
  store i64 %77, ptr %15, align 8, !tbaa !9
  %78 = load i64, ptr %15, align 8, !tbaa !9
  %79 = add i64 %78, 28
  %80 = add i64 %79, 52
  %81 = add i64 %80, 12
  store i64 %81, ptr %13, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.DSFFileChunk, ptr %16, i32 0, i32 0
  %83 = getelementptr inbounds [4 x i8], ptr %82, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %83, ptr align 1 @.str.21, i64 4, i1 false)
  %84 = getelementptr inbounds %struct.DSFFileChunk, ptr %16, i32 0, i32 1
  store i64 28, ptr %84, align 4, !tbaa !17
  %85 = load i64, ptr %13, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.DSFFileChunk, ptr %16, i32 0, i32 2
  store i64 %85, ptr %86, align 4, !tbaa !19
  %87 = getelementptr inbounds %struct.DSFFileChunk, ptr %16, i32 0, i32 3
  store i64 0, ptr %87, align 4, !tbaa !20
  %88 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 0
  %89 = getelementptr inbounds [4 x i8], ptr %88, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %89, ptr align 1 @.str.6, i64 4, i1 false)
  %90 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 1
  store i64 52, ptr %90, align 4, !tbaa !21
  %91 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 2
  store i32 1, ptr %91, align 4, !tbaa !23
  %92 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 3
  store i32 0, ptr %92, align 4, !tbaa !24
  %93 = load i32, ptr %11, align 4, !tbaa !11
  %94 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 4
  store i32 %93, ptr %94, align 4, !tbaa !25
  %95 = load i32, ptr %12, align 4, !tbaa !11
  %96 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 5
  store i32 %95, ptr %96, align 4, !tbaa !26
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = call i32 @WavpackStreamGetSampleRate(ptr noundef %97)
  %99 = mul i32 %98, 8
  %100 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 6
  store i32 %99, ptr %100, align 4, !tbaa !27
  %101 = load i32, ptr %9, align 4, !tbaa !11
  %102 = and i32 %101, 16
  %103 = icmp ne i32 %102, 0
  %104 = zext i1 %103 to i64
  %105 = select i1 %103, i32 1, i32 8
  %106 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 7
  store i32 %105, ptr %106, align 4, !tbaa !28
  %107 = load i64, ptr %8, align 8, !tbaa !9
  %108 = mul nsw i64 %107, 8
  %109 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 8
  store i64 %108, ptr %109, align 4, !tbaa !29
  %110 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 9
  store i32 4096, ptr %110, align 4, !tbaa !30
  %111 = getelementptr inbounds %struct.DSFFormatChunk, ptr %17, i32 0, i32 10
  store i32 0, ptr %111, align 4, !tbaa !31
  %112 = getelementptr inbounds %struct.DSFChunkHeader, ptr %18, i32 0, i32 0
  %113 = getelementptr inbounds [4 x i8], ptr %112, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %113, ptr align 1 @.str.12, i64 4, i1 false)
  %114 = load i64, ptr %15, align 8, !tbaa !9
  %115 = add nsw i64 %114, 12
  %116 = getelementptr inbounds %struct.DSFChunkHeader, ptr %18, i32 0, i32 1
  store i64 %115, ptr %116, align 4, !tbaa !32
  call void @WavpackStreamNativeToLittleEndian(ptr noundef %16, ptr noundef @.str.2)
  call void @WavpackStreamNativeToLittleEndian(ptr noundef %17, ptr noundef @.str.7)
  call void @WavpackStreamNativeToLittleEndian(ptr noundef %18, ptr noundef @.str.13)
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = call i32 @DoWriteFile(ptr noundef %117, ptr noundef %16, i32 noundef 28, ptr noundef %19)
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %140

120:                                              ; preds = %68
  %121 = load i32, ptr %19, align 4, !tbaa !11
  %122 = zext i32 %121 to i64
  %123 = icmp ne i64 %122, 28
  br i1 %123, label %140, label %124

124:                                              ; preds = %120
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = call i32 @DoWriteFile(ptr noundef %125, ptr noundef %17, i32 noundef 52, ptr noundef %19)
  %127 = icmp ne i32 %126, 0
  br i1 %127, label %128, label %140

128:                                              ; preds = %124
  %129 = load i32, ptr %19, align 4, !tbaa !11
  %130 = zext i32 %129 to i64
  %131 = icmp ne i64 %130, 52
  br i1 %131, label %140, label %132

132:                                              ; preds = %128
  %133 = load ptr, ptr %6, align 8, !tbaa !5
  %134 = call i32 @DoWriteFile(ptr noundef %133, ptr noundef %18, i32 noundef 12, ptr noundef %19)
  %135 = icmp ne i32 %134, 0
  br i1 %135, label %136, label %140

136:                                              ; preds = %132
  %137 = load i32, ptr %19, align 4, !tbaa !11
  %138 = zext i32 %137 to i64
  %139 = icmp ne i64 %138, 12
  br i1 %139, label %140, label %141

140:                                              ; preds = %136, %132, %128, %124, %120, %68
  call void (ptr, ...) @error_line(ptr noundef @.str.22)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %21, align 4
  br label %142

141:                                              ; preds = %136
  store i32 1, ptr %5, align 4
  store i32 1, ptr %21, align 4
  br label %142

142:                                              ; preds = %141, %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 52, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 28, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %143 = load i32, ptr %5, align 4
  ret i32 %143
}

declare i32 @WavpackStreamGetChannelMask(ptr noundef) #2

declare i32 @WavpackStreamGetNumChannels(ptr noundef) #2

declare i32 @WavpackStreamGetSampleRate(ptr noundef) #2

declare void @WavpackStreamNativeToLittleEndian(ptr noundef, ptr noundef) #2

declare i32 @DoWriteFile(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !10, i64 4}
!18 = !{!"", !7, i64 0, !10, i64 4, !10, i64 12, !10, i64 20}
!19 = !{!18, !10, i64 12}
!20 = !{!18, !10, i64 20}
!21 = !{!22, !10, i64 4}
!22 = !{!"", !7, i64 0, !10, i64 4, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !10, i64 36, !12, i64 44, !12, i64 48}
!23 = !{!22, !12, i64 12}
!24 = !{!22, !12, i64 16}
!25 = !{!22, !12, i64 20}
!26 = !{!22, !12, i64 24}
!27 = !{!22, !12, i64 28}
!28 = !{!22, !12, i64 32}
!29 = !{!22, !10, i64 36}
!30 = !{!22, !12, i64 44}
!31 = !{!22, !12, i64 48}
!32 = !{!33, !10, i64 4}
!33 = !{!"", !7, i64 0, !10, i64 4}


; 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.DSFFileChunk = type <{ [4 x i8], i64, i64, i64 }>
%struct.DSFFormatChunk = type <{ [4 x i8], i64, i32, i32, i32, i32, i32, i32, i64, i32, i32 }>
%struct.DSFChunkHeader = type <{ [4 x i8], i64 }>

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@debug_logging_mode = external local_unnamed_addr global i32, align 4
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@channel_masks = external hidden local_unnamed_addr constant [7 x i16], align 2
@.str.20 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [43 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 @error_line(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: nounwind uwtable
define dso_local range(i32 0, 2) i32 @WriteDsfHeader(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.DSFFileChunk, align 4
  %6 = alloca %struct.DSFFormatChunk, align 4
  %7 = alloca %struct.DSFChunkHeader, align 4
  %8 = alloca i32, align 4
  %9 = tail call i32 @WavpackStreamGetChannelMask(ptr noundef %1) #3
  %10 = tail call i32 @WavpackStreamGetNumChannels(ptr noundef %1) #3
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 52, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %11 = load i32, ptr @debug_logging_mode, align 4, !tbaa !5
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %13, label %12

12:                                               ; preds = %4
  tail call void (ptr, ...) @error_line(ptr noundef nonnull @.str.20, i64 noundef %2, i32 noundef %3) #3
  br label %13

13:                                               ; preds = %12, %4
  %14 = load i16, ptr @channel_masks, align 2, !tbaa !9
  %15 = zext i16 %14 to i32
  %16 = icmp eq i32 %9, %15
  %spec.select = zext i1 %16 to i32
  %17 = load i16, ptr getelementptr inbounds (i8, ptr @channel_masks, i64 2), align 2, !tbaa !9
  %18 = zext i16 %17 to i32
  %19 = icmp eq i32 %9, %18
  %spec.select.1 = select i1 %19, i32 2, i32 %spec.select
  %20 = load i16, ptr getelementptr inbounds (i8, ptr @channel_masks, i64 4), align 2, !tbaa !9
  %21 = zext i16 %20 to i32
  %22 = icmp eq i32 %9, %21
  %spec.select.2 = select i1 %22, i32 3, i32 %spec.select.1
  %23 = load i16, ptr getelementptr inbounds (i8, ptr @channel_masks, i64 6), align 2, !tbaa !9
  %24 = zext i16 %23 to i32
  %25 = icmp eq i32 %9, %24
  %spec.select.3 = select i1 %25, i32 4, i32 %spec.select.2
  %26 = load i16, ptr getelementptr inbounds (i8, ptr @channel_masks, i64 8), align 2, !tbaa !9
  %27 = zext i16 %26 to i32
  %28 = icmp eq i32 %9, %27
  %spec.select.4 = select i1 %28, i32 5, i32 %spec.select.3
  %29 = load i16, ptr getelementptr inbounds (i8, ptr @channel_masks, i64 10), align 2, !tbaa !9
  %30 = zext i16 %29 to i32
  %31 = icmp eq i32 %9, %30
  %spec.select.5 = select i1 %31, i32 6, i32 %spec.select.4
  %32 = load i16, ptr getelementptr inbounds (i8, ptr @channel_masks, i64 12), align 2, !tbaa !9
  %33 = zext i16 %32 to i32
  %34 = icmp eq i32 %9, %33
  %spec.select.6 = select i1 %34, i32 7, i32 %spec.select.5
  %.not40 = icmp eq i32 %spec.select.6, 0
  br i1 %.not40, label %35, label %40

35:                                               ; preds = %13
  %36 = icmp sgt i32 %10, 6
  br i1 %36, label %40, label %37

37:                                               ; preds = %35
  %38 = icmp sgt i32 %10, 4
  %39 = zext i1 %38 to i32
  %spec.select42 = add nuw nsw i32 %10, %39
  br label %40

40:                                               ; preds = %37, %35, %13
  %.2 = phi i32 [ %spec.select.6, %13 ], [ 7, %35 ], [ %spec.select42, %37 ]
  %41 = add nsw i64 %2, 4095
  %42 = sdiv i64 %41, 4096
  %43 = shl nsw i64 %42, 12
  %44 = sext i32 %10 to i64
  %45 = mul nsw i64 %43, %44
  %46 = or disjoint i64 %45, 92
  %47 = load i32, ptr @.str.21, align 1
  store i32 %47, ptr %5, align 4
  %48 = getelementptr inbounds i8, ptr %5, i64 4
  store i64 28, ptr %48, align 4, !tbaa !11
  %49 = getelementptr inbounds i8, ptr %5, i64 12
  store i64 %46, ptr %49, align 4, !tbaa !14
  %50 = getelementptr inbounds i8, ptr %5, i64 20
  store i64 0, ptr %50, align 4, !tbaa !15
  %51 = load i32, ptr @.str.6, align 1
  store i32 %51, ptr %6, align 4
  %52 = getelementptr inbounds i8, ptr %6, i64 4
  store i64 52, ptr %52, align 4, !tbaa !16
  %53 = getelementptr inbounds i8, ptr %6, i64 12
  store i32 1, ptr %53, align 4, !tbaa !18
  %54 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 0, ptr %54, align 4, !tbaa !19
  %55 = getelementptr inbounds i8, ptr %6, i64 20
  store i32 %.2, ptr %55, align 4, !tbaa !20
  %56 = getelementptr inbounds i8, ptr %6, i64 24
  store i32 %10, ptr %56, align 4, !tbaa !21
  %57 = tail call i32 @WavpackStreamGetSampleRate(ptr noundef %1) #3
  %58 = shl i32 %57, 3
  %59 = getelementptr inbounds i8, ptr %6, i64 28
  store i32 %58, ptr %59, align 4, !tbaa !22
  %60 = and i32 %3, 16
  %.not41 = icmp eq i32 %60, 0
  %61 = select i1 %.not41, i32 8, i32 1
  %62 = getelementptr inbounds i8, ptr %6, i64 32
  store i32 %61, ptr %62, align 4, !tbaa !23
  %63 = shl nsw i64 %2, 3
  %64 = getelementptr inbounds i8, ptr %6, i64 36
  store i64 %63, ptr %64, align 4, !tbaa !24
  %65 = getelementptr inbounds i8, ptr %6, i64 44
  store i32 4096, ptr %65, align 4, !tbaa !25
  %66 = getelementptr inbounds i8, ptr %6, i64 48
  store i32 0, ptr %66, align 4, !tbaa !26
  %67 = load i32, ptr @.str.12, align 1
  store i32 %67, ptr %7, align 4
  %68 = or disjoint i64 %45, 12
  %69 = getelementptr inbounds i8, ptr %7, i64 4
  store i64 %68, ptr %69, align 4, !tbaa !27
  call void @WavpackStreamNativeToLittleEndian(ptr noundef nonnull %5, ptr noundef nonnull @.str.2) #3
  call void @WavpackStreamNativeToLittleEndian(ptr noundef nonnull %6, ptr noundef nonnull @.str.7) #3
  call void @WavpackStreamNativeToLittleEndian(ptr noundef nonnull %7, ptr noundef nonnull @.str.13) #3
  %70 = call i32 @DoWriteFile(ptr noundef %0, ptr noundef nonnull %5, i32 noundef 28, ptr noundef nonnull %8) #3
  %71 = icmp eq i32 %70, 0
  %72 = load i32, ptr %8, align 4
  %73 = icmp ne i32 %72, 28
  %or.cond = select i1 %71, i1 true, i1 %73
  br i1 %or.cond, label %84, label %74

74:                                               ; preds = %40
  %75 = call i32 @DoWriteFile(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 52, ptr noundef nonnull %8) #3
  %76 = icmp eq i32 %75, 0
  %77 = load i32, ptr %8, align 4
  %78 = icmp ne i32 %77, 52
  %or.cond5 = select i1 %76, i1 true, i1 %78
  br i1 %or.cond5, label %84, label %79

79:                                               ; preds = %74
  %80 = call i32 @DoWriteFile(ptr noundef %0, ptr noundef nonnull %7, i32 noundef 12, ptr noundef nonnull %8) #3
  %81 = icmp eq i32 %80, 0
  %82 = load i32, ptr %8, align 4
  %83 = icmp ne i32 %82, 12
  %or.cond8 = select i1 %81, i1 true, i1 %83
  br i1 %or.cond8, label %84, label %85

84:                                               ; preds = %79, %74, %40
  call void (ptr, ...) @error_line(ptr noundef nonnull @.str.22) #3
  br label %85

85:                                               ; preds = %79, %84
  %.036 = phi i32 [ 0, %84 ], [ 1, %79 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 52, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %5) #3
  ret i32 %.036
}

declare i32 @WavpackStreamGetChannelMask(ptr noundef) local_unnamed_addr #1

declare i32 @WavpackStreamGetNumChannels(ptr noundef) local_unnamed_addr #1

declare i32 @WavpackStreamGetSampleRate(ptr noundef) local_unnamed_addr #1

declare void @WavpackStreamNativeToLittleEndian(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @DoWriteFile(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"", !7, i64 0, !13, i64 4, !13, i64 12, !13, i64 20}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 12}
!15 = !{!12, !13, i64 20}
!16 = !{!17, !13, i64 4}
!17 = !{!"", !7, i64 0, !13, i64 4, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !13, i64 36, !6, i64 44, !6, i64 48}
!18 = !{!17, !6, i64 12}
!19 = !{!17, !6, i64 16}
!20 = !{!17, !6, i64 20}
!21 = !{!17, !6, i64 24}
!22 = !{!17, !6, i64 28}
!23 = !{!17, !6, i64 32}
!24 = !{!17, !13, i64 36}
!25 = !{!17, !6, i64 44}
!26 = !{!17, !6, i64 48}
!27 = !{!28, !13, i64 4}
!28 = !{!"", !7, i64 0, !13, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass