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

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

; 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 @_Z12IsChanDigoutjj(i32 noundef, i32 noundef) #1

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

; 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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12TrackChanneljj(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.cbPROCINFO, align 1
  %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 %struct.cbSCALING, align 1
  %17 = alloca i32, align 4
  %18 = alloca %struct.cbSCALING, align 1
  %19 = alloca i32, align 4
  %20 = alloca %struct.cbSCALING, align 1
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 108, ptr %9) #5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = call noundef zeroext i1 @_Z14IsChanAnalogInjj(i32 noundef %23, i32 noundef 0)
  br i1 %24, label %25, label %182

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

26:                                               ; preds = %49, %25
  %27 = load i32, ptr %10, align 4, !tbaa !5
  %28 = icmp ule i32 %27, 3
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 2, ptr %11, align 4
  br label %52

30:                                               ; preds = %26
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = call noundef i32 @_Z14cbGetNspStatusj(i32 noundef %31)
  %33 = icmp eq i32 3, %32
  br i1 %33, label %34, label %48

34:                                               ; preds = %30
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = call noundef i32 @_Z13cbGetProcInfojP10cbPROCINFOj(i32 noundef %35, ptr noundef %9, i32 noundef 0)
  %37 = getelementptr inbounds %struct.cbPROCINFO, ptr %9, i32 0, i32 3
  %38 = load i32, ptr %37, align 1, !tbaa !9
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = add i32 %39, %38
  store i32 %40, ptr %8, align 4, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = call noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef %41, i32 noundef 0)
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %34
  store i32 2, ptr %11, align 4
  br label %52

46:                                               ; preds = %34
  %47 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %47, ptr %7, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %46, %30
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = add i32 %50, 1
  store i32 %51, ptr %10, align 4, !tbaa !5
  br label %26, !llvm.loop !11

52:                                               ; preds = %45, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %53

53:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = add i32 %54, 1
  store i32 %55, ptr %12, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %178, %53
  %57 = load i32, ptr %12, align 4, !tbaa !5
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = icmp ule i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %181

61:                                               ; preds = %56
  %62 = load i32, ptr %12, align 4, !tbaa !5
  %63 = call noundef zeroext i1 @_Z15IsChanAnalogOutjj(i32 noundef %62, i32 noundef 0)
  br i1 %63, label %67, label %64

64:                                               ; preds = %61
  %65 = load i32, ptr %12, align 4, !tbaa !5
  %66 = call noundef zeroext i1 @_Z14IsChanAudioOutjj(i32 noundef %65, i32 noundef 0)
  br i1 %66, label %67, label %156

67:                                               ; preds = %64, %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %68 = load i32, ptr %12, align 4, !tbaa !5
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = call noundef i32 @_Z16cbGetAoutOptionsjPjS_S_j(i32 noundef %68, ptr noundef %13, ptr noundef %14, ptr noundef %15, i32 noundef %69)
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %155

72:                                               ; preds = %67
  %73 = load i32, ptr %13, align 4, !tbaa !5
  %74 = and i32 %73, 4
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %154

76:                                               ; preds = %72
  %77 = load i32, ptr %12, align 4, !tbaa !5
  %78 = load i32, ptr %13, align 4, !tbaa !5
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = load i32, ptr %15, align 4, !tbaa !5
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = call noundef i32 @_Z16cbSetAoutOptionsjjjjj(i32 noundef %77, i32 noundef %78, i32 noundef %79, i32 noundef %80, i32 noundef %81)
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #5
  %83 = load i32, ptr %3, align 4, !tbaa !5
  %84 = call noundef i32 @_Z16cbGetAinpDisplayjPiS_S_S_j(i32 noundef %83, ptr noundef null, ptr noundef %5, ptr noundef %6, ptr noundef null, i32 noundef 0)
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = call noundef i32 @_Z16cbGetAinpScalingjP9cbSCALINGj(i32 noundef %85, ptr noundef %16, i32 noundef %86)
  %88 = load i32, ptr %13, align 4, !tbaa !5
  %89 = and i32 %88, 64
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %120

91:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = getelementptr inbounds %struct.cbSCALING, ptr %16, i32 0, i32 3
  %94 = load i32, ptr %93, align 1, !tbaa !13
  %95 = mul nsw i32 %92, %94
  %96 = getelementptr inbounds %struct.cbSCALING, ptr %16, i32 0, i32 1
  %97 = load i16, ptr %96, align 1, !tbaa !16
  %98 = sext i16 %97 to i32
  %99 = sdiv i32 %95, %98
  store i32 %99, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #5
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = sub nsw i32 0, %100
  %102 = trunc i32 %101 to i16
  %103 = getelementptr inbounds %struct.cbSCALING, ptr %18, i32 0, i32 0
  store i16 %102, ptr %103, align 1, !tbaa !17
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = trunc i32 %104 to i16
  %106 = getelementptr inbounds %struct.cbSCALING, ptr %18, i32 0, i32 1
  store i16 %105, ptr %106, align 1, !tbaa !16
  %107 = load i32, ptr %17, align 4, !tbaa !5
  %108 = sub nsw i32 0, %107
  %109 = getelementptr inbounds %struct.cbSCALING, ptr %18, i32 0, i32 2
  store i32 %108, ptr %109, align 1, !tbaa !18
  %110 = load i32, ptr %17, align 4, !tbaa !5
  %111 = getelementptr inbounds %struct.cbSCALING, ptr %18, i32 0, i32 3
  store i32 %110, ptr %111, align 1, !tbaa !13
  %112 = getelementptr inbounds %struct.cbSCALING, ptr %18, i32 0, i32 5
  %113 = getelementptr inbounds [8 x i8], ptr %112, i64 0, i64 0
  %114 = getelementptr inbounds %struct.cbSCALING, ptr %16, i32 0, i32 5
  %115 = getelementptr inbounds [8 x i8], ptr %114, i64 0, i64 0
  %116 = call ptr @strncpy(ptr noundef %113, ptr noundef %115, i64 noundef 8) #5
  %117 = load i32, ptr %12, align 4, !tbaa !5
  %118 = load i32, ptr %4, align 4, !tbaa !5
  %119 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %117, ptr noundef %18, i32 noundef %118)
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %120

120:                                              ; preds = %91, %76
  %121 = load i32, ptr %13, align 4, !tbaa !5
  %122 = and i32 %121, 128
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %153

124:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = getelementptr inbounds %struct.cbSCALING, ptr %16, i32 0, i32 3
  %127 = load i32, ptr %126, align 1, !tbaa !13
  %128 = mul nsw i32 %125, %127
  %129 = getelementptr inbounds %struct.cbSCALING, ptr %16, i32 0, i32 1
  %130 = load i16, ptr %129, align 1, !tbaa !16
  %131 = sext i16 %130 to i32
  %132 = sdiv i32 %128, %131
  store i32 %132, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #5
  %133 = load i32, ptr %6, align 4, !tbaa !5
  %134 = sub nsw i32 0, %133
  %135 = trunc i32 %134 to i16
  %136 = getelementptr inbounds %struct.cbSCALING, ptr %20, i32 0, i32 0
  store i16 %135, ptr %136, align 1, !tbaa !17
  %137 = load i32, ptr %6, align 4, !tbaa !5
  %138 = trunc i32 %137 to i16
  %139 = getelementptr inbounds %struct.cbSCALING, ptr %20, i32 0, i32 1
  store i16 %138, ptr %139, align 1, !tbaa !16
  %140 = load i32, ptr %19, align 4, !tbaa !5
  %141 = sub nsw i32 0, %140
  %142 = getelementptr inbounds %struct.cbSCALING, ptr %20, i32 0, i32 2
  store i32 %141, ptr %142, align 1, !tbaa !18
  %143 = load i32, ptr %19, align 4, !tbaa !5
  %144 = getelementptr inbounds %struct.cbSCALING, ptr %20, i32 0, i32 3
  store i32 %143, ptr %144, align 1, !tbaa !13
  %145 = getelementptr inbounds %struct.cbSCALING, ptr %20, i32 0, i32 5
  %146 = getelementptr inbounds [8 x i8], ptr %145, i64 0, i64 0
  %147 = getelementptr inbounds %struct.cbSCALING, ptr %16, i32 0, i32 5
  %148 = getelementptr inbounds [8 x i8], ptr %147, i64 0, i64 0
  %149 = call ptr @strncpy(ptr noundef %146, ptr noundef %148, i64 noundef 8) #5
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = load i32, ptr %4, align 4, !tbaa !5
  %152 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %150, ptr noundef %20, i32 noundef %151)
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %153

153:                                              ; preds = %124, %120
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #5
  br label %154

154:                                              ; preds = %153, %72
  br label %155

155:                                              ; preds = %154, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %156

156:                                              ; preds = %155, %64
  %157 = load i32, ptr %12, align 4, !tbaa !5
  %158 = call noundef zeroext i1 @_Z12IsChanDigoutjj(i32 noundef %157, i32 noundef 0)
  br i1 %158, label %159, label %177

159:                                              ; preds = %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %160 = load i32, ptr %12, align 4, !tbaa !5
  %161 = load i32, ptr %4, align 4, !tbaa !5
  %162 = call noundef i32 @_Z16cbGetDoutOptionsjPjS_S_PhPtS1_j(i32 noundef %160, ptr noundef %21, ptr noundef null, ptr noundef %22, ptr noundef null, ptr noundef null, ptr noundef null, i32 noundef %161)
  %163 = icmp eq i32 0, %162
  br i1 %163, label %164, label %176

164:                                              ; preds = %159
  %165 = load i32, ptr %21, align 4, !tbaa !5
  %166 = and i32 %165, 131072
  %167 = icmp ne i32 %166, 0
  br i1 %167, label %168, label %175

168:                                              ; preds = %164
  %169 = load i32, ptr %12, align 4, !tbaa !5
  %170 = load i32, ptr %21, align 4, !tbaa !5
  %171 = load i32, ptr %3, align 4, !tbaa !5
  %172 = load i32, ptr %22, align 4, !tbaa !5
  %173 = load i32, ptr %4, align 4, !tbaa !5
  %174 = call noundef i32 @_Z16cbSetDoutOptionsjjjjhttj(i32 noundef %169, i32 noundef %170, i32 noundef %171, i32 noundef %172, i8 noundef zeroext 0, i16 noundef zeroext 0, i16 noundef zeroext 0, i32 noundef %173)
  br label %175

175:                                              ; preds = %168, %164
  br label %176

176:                                              ; preds = %175, %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  br label %177

177:                                              ; preds = %176, %156
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %12, align 4, !tbaa !5
  %180 = add i32 %179, 1
  store i32 %180, ptr %12, align 4, !tbaa !5
  br label %56, !llvm.loop !19

181:                                              ; preds = %60
  br label %182

182:                                              ; preds = %181, %2
  call void @llvm.lifetime.end.p0(i64 108, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

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

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

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

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

declare noundef i32 @_Z16cbSetAoutOptionsjjjjj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

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

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

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

declare noundef i32 @_Z16cbSetDoutOptionsjjjjhttj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i32 noundef) #2

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 = { "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 = { 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 #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, !6, i64 72}
!10 = !{!"_ZTS10cbPROCINFO", !6, i64 0, !7, i64 4, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !6, i64 100, !6, i64 104}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS9cbSCALING", !15, i64 0, !15, i64 2, !6, i64 4, !6, i64 8, !6, i64 12, !7, i64 16}
!15 = !{!"short", !7, i64 0}
!16 = !{!14, !15, i64 2}
!17 = !{!14, !15, i64 0}
!18 = !{!14, !6, i64 4}
!19 = distinct !{!19, !12}


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

; 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 @_Z12IsChanDigoutjj(i32 noundef, i32 noundef) local_unnamed_addr #1

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

; 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

declare noundef i32 @_Z16cbGetDoutOptionsjPjS_S_PhPtS1_j(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12TrackChanneljj(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.cbPROCINFO, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.cbSCALING, align 1
  %10 = alloca %struct.cbSCALING, align 2
  %11 = alloca %struct.cbSCALING, align 2
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 108, ptr nonnull %5) #5
  %14 = tail call noundef zeroext i1 @_Z14IsChanAnalogInjj(i32 noundef %0, i32 noundef 0)
  br i1 %14, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %15 = getelementptr inbounds i8, ptr %5, i64 72
  %16 = tail call noundef i32 @_Z14cbGetNspStatusj(i32 noundef 1)
  %17 = icmp eq i32 %16, 3
  br i1 %17, label %18, label %23

18:                                               ; preds = %.preheader
  %19 = call noundef i32 @_Z13cbGetProcInfojP10cbPROCINFOj(i32 noundef 1, ptr noundef nonnull %5, i32 noundef 0)
  %20 = load i32, ptr %15, align 1, !tbaa !9
  %21 = call noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef %0, i32 noundef 0)
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %41, label %23

23:                                               ; preds = %18, %.preheader
  %.138 = phi i32 [ 0, %.preheader ], [ %20, %18 ]
  %24 = call noundef i32 @_Z14cbGetNspStatusj(i32 noundef 2)
  %25 = icmp eq i32 %24, 3
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = call noundef i32 @_Z13cbGetProcInfojP10cbPROCINFOj(i32 noundef 2, ptr noundef nonnull %5, i32 noundef 0)
  %28 = load i32, ptr %15, align 1, !tbaa !9
  %29 = add i32 %28, %.138
  %30 = call noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef %0, i32 noundef 0)
  %31 = icmp eq i32 %30, 2
  br i1 %31, label %41, label %32

32:                                               ; preds = %26, %23
  %.138.1 = phi i32 [ %.138, %23 ], [ %29, %26 ]
  %33 = call noundef i32 @_Z14cbGetNspStatusj(i32 noundef 3)
  %34 = icmp eq i32 %33, 3
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = call noundef i32 @_Z13cbGetProcInfojP10cbPROCINFOj(i32 noundef 3, ptr noundef nonnull %5, i32 noundef 0)
  %37 = load i32, ptr %15, align 1, !tbaa !9
  %38 = add i32 %37, %.138.1
  %39 = call noundef i32 @_Z19cbGetChanInstrumentjj(i32 noundef %0, i32 noundef 0)
  %40 = icmp eq i32 %39, 3
  %spec.select = select i1 %40, i32 %.138.1, i32 %38
  br label %41

41:                                               ; preds = %35, %32, %26, %18
  %.0.lcssa = phi i32 [ 0, %18 ], [ %.138, %26 ], [ %.138.1, %32 ], [ %spec.select, %35 ]
  %.2 = phi i32 [ %20, %18 ], [ %29, %26 ], [ %.138.1, %32 ], [ %38, %35 ]
  %.03948 = add i32 %.0.lcssa, 1
  %.not49 = icmp ugt i32 %.03948, %.2
  br i1 %.not49, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %41
  %42 = getelementptr inbounds i8, ptr %9, i64 8
  %43 = getelementptr inbounds i8, ptr %9, i64 2
  %44 = getelementptr inbounds i8, ptr %10, i64 2
  %45 = getelementptr inbounds i8, ptr %10, i64 4
  %46 = getelementptr inbounds i8, ptr %10, i64 8
  %47 = getelementptr inbounds i8, ptr %10, i64 16
  %48 = getelementptr inbounds i8, ptr %9, i64 16
  %49 = getelementptr inbounds i8, ptr %11, i64 2
  %50 = getelementptr inbounds i8, ptr %11, i64 4
  %51 = getelementptr inbounds i8, ptr %11, i64 8
  %52 = getelementptr inbounds i8, ptr %11, i64 16
  br label %53

53:                                               ; preds = %.lr.ph, %111
  %.03950 = phi i32 [ %.03948, %.lr.ph ], [ %.039, %111 ]
  %54 = call noundef zeroext i1 @_Z15IsChanAnalogOutjj(i32 noundef %.03950, i32 noundef 0)
  br i1 %54, label %57, label %55

55:                                               ; preds = %53
  %56 = call noundef zeroext i1 @_Z14IsChanAudioOutjj(i32 noundef %.03950, i32 noundef 0)
  br i1 %56, label %57, label %99

57:                                               ; preds = %55, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %58 = call noundef i32 @_Z16cbGetAoutOptionsjPjS_S_j(i32 noundef %.03950, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, i32 noundef %1)
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %98

60:                                               ; preds = %57
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = and i32 %61, 4
  %.not41 = icmp eq i32 %62, 0
  br i1 %.not41, label %98, label %63

63:                                               ; preds = %60
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = call noundef i32 @_Z16cbSetAoutOptionsjjjjj(i32 noundef %.03950, i32 noundef %61, i32 noundef %0, i32 noundef %64, i32 noundef %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  %66 = call noundef i32 @_Z16cbGetAinpDisplayjPiS_S_S_j(i32 noundef %0, ptr noundef null, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef null, i32 noundef 0)
  %67 = call noundef i32 @_Z16cbGetAinpScalingjP9cbSCALINGj(i32 noundef %0, ptr noundef nonnull %9, i32 noundef %1)
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = and i32 %68, 64
  %.not42 = icmp eq i32 %69, 0
  br i1 %.not42, label %82, label %70

70:                                               ; preds = %63
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = load i32, ptr %42, align 1, !tbaa !11
  %73 = mul nsw i32 %72, %71
  %74 = load i16, ptr %43, align 1, !tbaa !14
  %75 = sext i16 %74 to i32
  %76 = sdiv i32 %73, %75
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #5
  %77 = trunc i32 %71 to i16
  %78 = sub i16 0, %77
  store i16 %78, ptr %10, align 2, !tbaa !15
  store i16 %77, ptr %44, align 2, !tbaa !14
  %79 = sub nsw i32 0, %76
  store i32 %79, ptr %45, align 2, !tbaa !16
  store i32 %76, ptr %46, align 2, !tbaa !11
  %80 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %47, ptr noundef nonnull dereferenceable(1) %48, i64 noundef 8) #5
  %81 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %.03950, ptr noundef nonnull %10, i32 noundef %1)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  %.pre = load i32, ptr %6, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %70, %63
  %83 = phi i32 [ %.pre, %70 ], [ %68, %63 ]
  %84 = and i32 %83, 128
  %.not43 = icmp eq i32 %84, 0
  br i1 %.not43, label %97, label %85

85:                                               ; preds = %82
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = load i32, ptr %42, align 1, !tbaa !11
  %88 = mul nsw i32 %87, %86
  %89 = load i16, ptr %43, align 1, !tbaa !14
  %90 = sext i16 %89 to i32
  %91 = sdiv i32 %88, %90
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #5
  %92 = trunc i32 %86 to i16
  %93 = sub i16 0, %92
  store i16 %93, ptr %11, align 2, !tbaa !15
  store i16 %92, ptr %49, align 2, !tbaa !14
  %94 = sub nsw i32 0, %91
  store i32 %94, ptr %50, align 2, !tbaa !16
  store i32 %91, ptr %51, align 2, !tbaa !11
  %95 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %52, ptr noundef nonnull dereferenceable(1) %48, i64 noundef 8) #5
  %96 = call noundef i32 @_Z16cbSetAoutScalingjP9cbSCALINGj(i32 noundef %.03950, ptr noundef nonnull %11, i32 noundef %1)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #5
  br label %97

97:                                               ; preds = %85, %82
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br label %98

98:                                               ; preds = %60, %97, %57
  call void @llvm.lifetime.end.p0(i64 4, 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 %99

99:                                               ; preds = %98, %55
  %100 = call noundef zeroext i1 @_Z12IsChanDigoutjj(i32 noundef %.03950, i32 noundef 0)
  br i1 %100, label %101, label %111

101:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #5
  %102 = call noundef i32 @_Z16cbGetDoutOptionsjPjS_S_PhPtS1_j(i32 noundef %.03950, ptr noundef nonnull %12, ptr noundef null, ptr noundef nonnull %13, ptr noundef null, ptr noundef null, ptr noundef null, i32 noundef %1)
  %103 = icmp eq i32 %102, 0
  br i1 %103, label %104, label %110

104:                                              ; preds = %101
  %105 = load i32, ptr %12, align 4, !tbaa !5
  %106 = and i32 %105, 131072
  %.not44 = icmp eq i32 %106, 0
  br i1 %.not44, label %110, label %107

107:                                              ; preds = %104
  %108 = load i32, ptr %13, align 4, !tbaa !5
  %109 = call noundef i32 @_Z16cbSetDoutOptionsjjjjhttj(i32 noundef %.03950, i32 noundef %105, i32 noundef %0, i32 noundef %108, i8 noundef zeroext 0, i16 noundef zeroext 0, i16 noundef zeroext 0, i32 noundef %1)
  br label %110

110:                                              ; preds = %104, %107, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #5
  br label %111

111:                                              ; preds = %99, %110
  %.039 = add i32 %.03950, 1
  %.not = icmp ugt i32 %.039, %.2
  br i1 %.not, label %.loopexit, label %53, !llvm.loop !17

.loopexit:                                        ; preds = %111, %41, %2
  call void @llvm.lifetime.end.p0(i64 108, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret void
}

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

declare noundef i32 @_Z13cbGetProcInfojP10cbPROCINFOj(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

declare noundef i32 @_Z16cbSetAoutOptionsjjjjj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare noundef i32 @_Z16cbGetAinpDisplayjPiS_S_S_j(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

; 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 #2

declare noundef i32 @_Z16cbSetDoutOptionsjjjjhttj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i32 noundef) local_unnamed_addr #2

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 = { "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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 72}
!10 = !{!"_ZTS10cbPROCINFO", !6, i64 0, !7, i64 4, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !6, i64 100, !6, i64 104}
!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"}


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