; LLVM IR from CerebusOSS/CereLink :: cbhwlib/cbHwlibHi.ll (Z20cbSetAnaInOutDisplayjiiij)

; 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.cbSCALING = type { i16, i16, i32, i32, i32, [8 x i8] }

@cb_pc_status_buffer_ptr = external global [4 x ptr], align 16

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z15IsChanAnalogOutjj(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z14IsChanAudioOutjj(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef, i32 noundef) #2

declare noundef i32 @_Z16cbGetAoutOptionsjPjS_S_j(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

declare noundef i32 @_Z16cbGetAinpScalingjP9cbSCALINGj(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #4

declare noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20cbSetAnaInOutDisplayjiiij(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct.cbSCALING, align 1
  %18 = alloca i32, align 4
  %19 = alloca %struct.cbSCALING, align 1
  %20 = alloca i32, align 4
  %21 = alloca %struct.cbSCALING, align 1
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = sub nsw i32 0, %23
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = load i32, ptr %9, align 4, !tbaa !5
  %27 = load i32, ptr %10, align 4, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = call noundef i32 @_Z16cbSetAinpDisplayjiiiij(i32 noundef %22, i32 noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27, i32 noundef %28)
  store i32 %29, ptr %12, align 4, !tbaa !5
  %30 = load i32, ptr %12, align 4, !tbaa !5
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %5
  %33 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %33, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %165

34:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 1, ptr %14, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %158, %34
  %36 = load i32, ptr %14, align 4, !tbaa !5
  %37 = load ptr, ptr @cb_pc_status_buffer_ptr, align 16, !tbaa !9
  %38 = call noundef i32 @_ZN10cbPcStatus18cbGetNumTotalChansEv(ptr noundef nonnull align 1 dereferenceable(6160) %37)
  %39 = icmp ule i32 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  store i32 2, ptr %13, align 4
  br label %161

41:                                               ; preds = %35
  %42 = load i32, ptr %14, align 4, !tbaa !5
  %43 = call noundef zeroext i1 @_Z15IsChanAnalogOutjj(i32 noundef %42, i32 noundef 0)
  br i1 %43, label %47, label %44

44:                                               ; preds = %41
  %45 = load i32, ptr %14, align 4, !tbaa !5
  %46 = call noundef zeroext i1 @_Z14IsChanAudioOutjj(i32 noundef %45, i32 noundef 0)
  br i1 %46, label %47, label %157

47:                                               ; preds = %44, %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !5
  %48 = load i32, ptr %14, align 4, !tbaa !5
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = call noundef i32 @_Z16cbGetAoutOptionsjPjS_S_j(i32 noundef %48, ptr noundef %15, ptr noundef %16, ptr noundef null, i32 noundef %49)
  %51 = load i32, ptr %16, align 4, !tbaa !5
  %52 = call noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef %51, i32 noundef 0)
  %53 = load i32, ptr %16, align 4, !tbaa !5
  %54 = call noundef i32 @_Z26cbGetExpandedChannelNumberjj(i32 noundef %52, i32 noundef %53)
  store i32 %54, ptr %16, align 4, !tbaa !5
  %55 = load i32, ptr %16, align 4, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = icmp eq i32 %55, %56
  br i1 %57, label %58, label %153

58:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #5
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %11, align 4, !tbaa !5
  %61 = call noundef i32 @_Z16cbGetAinpScalingjP9cbSCALINGj(i32 noundef %59, ptr noundef %17, i32 noundef %60)
  store i32 %61, ptr %12, align 4, !tbaa !5
  %62 = load i32, ptr %12, align 4, !tbaa !5
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %58
  %65 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %65, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %150

66:                                               ; preds = %58
  %67 = load i32, ptr %15, align 4, !tbaa !5
  %68 = and i32 %67, 64
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %107

70:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = getelementptr inbounds %struct.cbSCALING, ptr %17, i32 0, i32 3
  %73 = load i32, ptr %72, align 1, !tbaa !11
  %74 = mul nsw i32 %71, %73
  %75 = getelementptr inbounds %struct.cbSCALING, ptr %17, i32 0, i32 1
  %76 = load i16, ptr %75, align 1, !tbaa !14
  %77 = sext i16 %76 to i32
  %78 = sdiv i32 %74, %77
  store i32 %78, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %19) #5
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = sub nsw i32 0, %79
  %81 = trunc i32 %80 to i16
  %82 = getelementptr inbounds %struct.cbSCALING, ptr %19, i32 0, i32 0
  store i16 %81, ptr %82, align 1, !tbaa !15
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = trunc i32 %83 to i16
  %85 = getelementptr inbounds %struct.cbSCALING, ptr %19, i32 0, i32 1
  store i16 %84, ptr %85, align 1, !tbaa !14
  %86 = load i32, ptr %18, align 4, !tbaa !5
  %87 = sub nsw i32 0, %86
  %88 = getelementptr inbounds %struct.cbSCALING, ptr %19, i32 0, i32 2
  store i32 %87, ptr %88, align 1, !tbaa !16
  %89 = load i32, ptr %18, align 4, !tbaa !5
  %90 = getelementptr inbounds %struct.cbSCALING, ptr %19, i32 0, i32 3
  store i32 %89, ptr %90, align 1, !tbaa !11
  %91 = getelementptr inbounds %struct.cbSCALING, ptr %19, i32 0, i32 5
  %92 = getelementptr inbounds [8 x i8], ptr %91, i64 0, i64 0
  %93 = getelementptr inbounds %struct.cbSCALING, ptr %17, i32 0, i32 5
  %94 = getelementptr inbounds [8 x i8], ptr %93, i64 0, i64 0
  %95 = call ptr @strncpy(ptr noundef %92, ptr noundef %94, i64 noundef 8) #5
  %96 = load i32, ptr %14, align 4, !tbaa !5
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %96, ptr noundef %19, i32 noundef %97)
  store i32 %98, ptr %12, align 4, !tbaa !5
  %99 = load i32, ptr %12, align 4, !tbaa !5
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %103

101:                                              ; preds = %70
  %102 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %102, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %104

103:                                              ; preds = %70
  store i32 0, ptr %13, align 4
  br label %104

104:                                              ; preds = %103, %101
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  %105 = load i32, ptr %13, align 4
  switch i32 %105, label %150 [
    i32 0, label %106
  ]

106:                                              ; preds = %104
  br label %149

107:                                              ; preds = %66
  %108 = load i32, ptr %15, align 4, !tbaa !5
  %109 = and i32 %108, 128
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %148

111:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %112 = load i32, ptr %9, align 4, !tbaa !5
  %113 = getelementptr inbounds %struct.cbSCALING, ptr %17, i32 0, i32 3
  %114 = load i32, ptr %113, align 1, !tbaa !11
  %115 = mul nsw i32 %112, %114
  %116 = getelementptr inbounds %struct.cbSCALING, ptr %17, i32 0, i32 1
  %117 = load i16, ptr %116, align 1, !tbaa !14
  %118 = sext i16 %117 to i32
  %119 = sdiv i32 %115, %118
  store i32 %119, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %21) #5
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = sub nsw i32 0, %120
  %122 = trunc i32 %121 to i16
  %123 = getelementptr inbounds %struct.cbSCALING, ptr %21, i32 0, i32 0
  store i16 %122, ptr %123, align 1, !tbaa !15
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = trunc i32 %124 to i16
  %126 = getelementptr inbounds %struct.cbSCALING, ptr %21, i32 0, i32 1
  store i16 %125, ptr %126, align 1, !tbaa !14
  %127 = load i32, ptr %20, align 4, !tbaa !5
  %128 = sub nsw i32 0, %127
  %129 = getelementptr inbounds %struct.cbSCALING, ptr %21, i32 0, i32 2
  store i32 %128, ptr %129, align 1, !tbaa !16
  %130 = load i32, ptr %20, align 4, !tbaa !5
  %131 = getelementptr inbounds %struct.cbSCALING, ptr %21, i32 0, i32 3
  store i32 %130, ptr %131, align 1, !tbaa !11
  %132 = getelementptr inbounds %struct.cbSCALING, ptr %21, i32 0, i32 5
  %133 = getelementptr inbounds [8 x i8], ptr %132, i64 0, i64 0
  %134 = getelementptr inbounds %struct.cbSCALING, ptr %17, i32 0, i32 5
  %135 = getelementptr inbounds [8 x i8], ptr %134, i64 0, i64 0
  %136 = call ptr @strncpy(ptr noundef %133, ptr noundef %135, i64 noundef 8) #5
  %137 = load i32, ptr %14, align 4, !tbaa !5
  %138 = load i32, ptr %11, align 4, !tbaa !5
  %139 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %137, ptr noundef %21, i32 noundef %138)
  store i32 %139, ptr %12, align 4, !tbaa !5
  %140 = load i32, ptr %12, align 4, !tbaa !5
  %141 = icmp ne i32 %140, 0
  br i1 %141, label %142, label %144

142:                                              ; preds = %111
  %143 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %143, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %145

144:                                              ; preds = %111
  store i32 0, ptr %13, align 4
  br label %145

145:                                              ; preds = %144, %142
  call void @llvm.lifetime.end.p0(i64 24, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  %146 = load i32, ptr %13, align 4
  switch i32 %146, label %150 [
    i32 0, label %147
  ]

147:                                              ; preds = %145
  br label %148

148:                                              ; preds = %147, %107
  br label %149

149:                                              ; preds = %148, %106
  store i32 0, ptr %13, align 4
  br label %150

150:                                              ; preds = %149, %145, %104, %64
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #5
  %151 = load i32, ptr %13, align 4
  switch i32 %151, label %154 [
    i32 0, label %152
  ]

152:                                              ; preds = %150
  br label %153

153:                                              ; preds = %152, %47
  store i32 0, ptr %13, align 4
  br label %154

154:                                              ; preds = %153, %150
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  %155 = load i32, ptr %13, align 4
  switch i32 %155, label %161 [
    i32 0, label %156
  ]

156:                                              ; preds = %154
  br label %157

157:                                              ; preds = %156, %44
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %14, align 4, !tbaa !5
  %160 = add i32 %159, 1
  store i32 %160, ptr %14, align 4, !tbaa !5
  br label %35, !llvm.loop !17

161:                                              ; preds = %154, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %162 = load i32, ptr %13, align 4
  switch i32 %162, label %165 [
    i32 2, label %163
  ]

163:                                              ; preds = %161
  %164 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %164, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %165

165:                                              ; preds = %163, %161, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %166 = load i32, ptr %6, align 4
  ret i32 %166
}

declare noundef i32 @_Z16cbSetAinpDisplayjiiiij(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN10cbPcStatus18cbGetNumTotalChansEv(ptr noundef nonnull align 1 dereferenceable(6160)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z26cbGetExpandedChannelNumberjj(i32 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { mustprogress 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 = { "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 "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 #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS9cbSCALING", !13, i64 0, !13, i64 2, !6, i64 4, !6, i64 8, !6, i64 12, !7, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 2}
!15 = !{!12, !13, i64 0}
!16 = !{!12, !6, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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.cbSCALING = type { i16, i16, i32, i32, i32, [8 x i8] }

@cb_pc_status_buffer_ptr = external local_unnamed_addr global [4 x ptr], align 16

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z15IsChanAnalogOutjj(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z14IsChanAudioOutjj(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef, i32 noundef) local_unnamed_addr #2

declare noundef i32 @_Z16cbGetAoutOptionsjPjS_S_j(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare noundef i32 @_Z16cbGetAinpScalingjP9cbSCALINGj(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #4

declare noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20cbSetAnaInOutDisplayjiiij(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.cbSCALING, align 1
  %9 = alloca %struct.cbSCALING, align 2
  %10 = alloca %struct.cbSCALING, align 2
  %11 = sub nsw i32 0, %1
  %12 = tail call noundef i32 @_Z16cbSetAinpDisplayjiiiij(i32 noundef %0, i32 noundef %11, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %5
  %13 = load ptr, ptr @cb_pc_status_buffer_ptr, align 16, !tbaa !5
  %14 = tail call noundef i32 @_ZN10cbPcStatus18cbGetNumTotalChansEv(ptr noundef nonnull align 1 dereferenceable(6160) %13)
  %.not6883 = icmp eq i32 %14, 0
  br i1 %.not6883, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %15 = getelementptr inbounds i8, ptr %8, i64 8
  %16 = getelementptr inbounds i8, ptr %8, i64 2
  %17 = trunc i32 %11 to i16
  %18 = trunc i32 %1 to i16
  %19 = getelementptr inbounds i8, ptr %9, i64 2
  %20 = getelementptr inbounds i8, ptr %9, i64 4
  %21 = getelementptr inbounds i8, ptr %9, i64 8
  %22 = getelementptr inbounds i8, ptr %9, i64 16
  %23 = getelementptr inbounds i8, ptr %8, i64 16
  %24 = trunc i32 %2 to i16
  %25 = sub i16 0, %24
  %26 = getelementptr inbounds i8, ptr %10, i64 2
  %27 = getelementptr inbounds i8, ptr %10, i64 4
  %28 = getelementptr inbounds i8, ptr %10, i64 8
  %29 = getelementptr inbounds i8, ptr %10, i64 16
  br label %30

30:                                               ; preds = %.lr.ph, %67
  %.05584 = phi i32 [ 1, %.lr.ph ], [ %68, %67 ]
  %31 = call noundef zeroext i1 @_Z15IsChanAnalogOutjj(i32 noundef %.05584, i32 noundef 0)
  br i1 %31, label %34, label %32

32:                                               ; preds = %30
  %33 = call noundef zeroext i1 @_Z14IsChanAudioOutjj(i32 noundef %.05584, i32 noundef 0)
  br i1 %33, label %34, label %67

34:                                               ; preds = %32, %30
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  %35 = call noundef i32 @_Z16cbGetAoutOptionsjPjS_S_j(i32 noundef %.05584, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef null, i32 noundef %4)
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = call noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef %36, i32 noundef 0)
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = call noundef i32 @_Z26cbGetExpandedChannelNumberjj(i32 noundef %37, i32 noundef %38)
  store i32 %39, ptr %7, align 4, !tbaa !9
  %40 = icmp eq i32 %39, %0
  br i1 %40, label %41, label %.thread

.thread:                                          ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  br label %67

41:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #5
  %42 = call noundef i32 @_Z16cbGetAinpScalingjP9cbSCALINGj(i32 noundef %0, ptr noundef nonnull %8, i32 noundef %4)
  %.not69 = icmp eq i32 %42, 0
  br i1 %.not69, label %43, label %.thread79

43:                                               ; preds = %41
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = and i32 %44, 64
  %.not70 = icmp eq i32 %45, 0
  br i1 %.not70, label %55, label %46

46:                                               ; preds = %43
  %47 = load i32, ptr %15, align 1, !tbaa !11
  %48 = mul nsw i32 %47, %1
  %49 = load i16, ptr %16, align 1, !tbaa !14
  %50 = sext i16 %49 to i32
  %51 = sdiv i32 %48, %50
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  store i16 %17, ptr %9, align 2, !tbaa !15
  store i16 %18, ptr %19, align 2, !tbaa !14
  %52 = sub nsw i32 0, %51
  store i32 %52, ptr %20, align 2, !tbaa !16
  store i32 %51, ptr %21, align 2, !tbaa !11
  %53 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %22, ptr noundef nonnull dereferenceable(1) %23, i64 noundef 8) #5
  %54 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %.05584, ptr noundef nonnull %9, i32 noundef %4)
  %.not73 = icmp eq i32 %54, 0
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br i1 %.not73, label %66, label %.thread79

55:                                               ; preds = %43
  %56 = and i32 %44, 128
  %.not71 = icmp eq i32 %56, 0
  br i1 %.not71, label %66, label %57

57:                                               ; preds = %55
  %58 = load i32, ptr %15, align 1, !tbaa !11
  %59 = mul nsw i32 %58, %2
  %60 = load i16, ptr %16, align 1, !tbaa !14
  %61 = sext i16 %60 to i32
  %62 = sdiv i32 %59, %61
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #5
  store i16 %25, ptr %10, align 2, !tbaa !15
  store i16 %24, ptr %26, align 2, !tbaa !14
  %63 = sub nsw i32 0, %62
  store i32 %63, ptr %27, align 2, !tbaa !16
  store i32 %62, ptr %28, align 2, !tbaa !11
  %64 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) %23, i64 noundef 8) #5
  %65 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %.05584, ptr noundef nonnull %10, i32 noundef %4)
  %.not72 = icmp eq i32 %65, 0
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  br i1 %.not72, label %66, label %.thread79

.thread79:                                        ; preds = %46, %57, %41
  %.250.ph = phi i32 [ %42, %41 ], [ %65, %57 ], [ %54, %46 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  br label %.loopexit

66:                                               ; preds = %46, %57, %55
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  br label %67

67:                                               ; preds = %66, %.thread, %32
  %68 = add i32 %.05584, 1
  %69 = load ptr, ptr @cb_pc_status_buffer_ptr, align 16, !tbaa !5
  %70 = call noundef i32 @_ZN10cbPcStatus18cbGetNumTotalChansEv(ptr noundef nonnull align 1 dereferenceable(6160) %69)
  %.not68 = icmp ugt i32 %68, %70
  br i1 %.not68, label %.loopexit, label %30, !llvm.loop !17

.loopexit:                                        ; preds = %67, %.preheader, %.thread79, %5
  %.9 = phi i32 [ %12, %5 ], [ %.250.ph, %.thread79 ], [ 0, %.preheader ], [ 0, %67 ]
  ret i32 %.9
}

declare noundef i32 @_Z16cbSetAinpDisplayjiiiij(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN10cbPcStatus18cbGetNumTotalChansEv(ptr noundef nonnull align 1 dereferenceable(6160)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z26cbGetExpandedChannelNumberjj(i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { mustprogress 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 = { "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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS9cbSCALING", !13, i64 0, !13, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !7, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 2}
!15 = !{!12, !13, i64 0}
!16 = !{!12, !10, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass