; LLVM IR from NVIDIA/tensorflow :: tensorflow/lite/experimental/microfrontend/lib (pcan_gain_control_test)

; 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"

%"class.tflite::MicroErrorReporter" = type { %"class.tflite::ErrorReporter" }
%"class.tflite::ErrorReporter" = type { ptr }
%"class.(anonymous namespace)::PcanGainControlTestConfig" = type { %struct.PcanGainControlConfig }
%struct.PcanGainControlConfig = type { i32, float, float, i32 }
%struct.PcanGainControlState = type { i32, ptr, i32, ptr, i32 }

@_ZN10micro_test12tests_passedE = external dso_local global i32, align 4
@_ZN10micro_test12tests_failedE = external dso_local global i32, align 4
@_ZN10micro_test16is_test_completeE = external dso_local global i8, align 1
@_ZN10micro_test13did_test_failE = external dso_local global i8, align 1
@_ZN10micro_test8reporterE = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [40 x i8], align 1
@__const.main.estimate = external hidden unnamed_addr constant [2 x i32], align 4
@.str.2 = external hidden unnamed_addr constant [128 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [124 x i8], align 1
@__const.main.signal = external hidden unnamed_addr constant [2 x i32], align 4
@__const.main.expected = external hidden unnamed_addr constant [2 x i32], align 4
@.str.4 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %"class.tflite::MicroErrorReporter", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca [2 x i32], align 4
  %10 = alloca %"class.(anonymous namespace)::PcanGainControlTestConfig", align 4
  %11 = alloca %struct.PcanGainControlState, align 8
  %12 = alloca [2 x i32], align 4
  %13 = alloca [2 x i32], align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 0, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  store i32 0, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  store ptr %6, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %15 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %16 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef @.str, ptr noundef @.str.1)
          to label %17 unwind label %34

17:                                               ; preds = %2
  store i8 0, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  store i8 0, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %18

18:                                               ; preds = %113, %17
  %19 = load i8, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11, !range !13, !noundef !14
  %20 = trunc i8 %19 to i1
  %21 = xor i1 %20, true
  br i1 %21, label %22, label %130

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 @__const.main.estimate, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  invoke void @_ZN12_GLOBAL__N_125PcanGainControlTestConfigC2Ev(ptr noundef nonnull align 4 dereferenceable(16) %10)
          to label %23 unwind label %38

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #6
  br label %24

24:                                               ; preds = %23
  %25 = getelementptr inbounds %"class.(anonymous namespace)::PcanGainControlTestConfig", ptr %10, i32 0, i32 0
  %26 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %27 = invoke i32 @PcanGainControlPopulateState(ptr noundef %25, ptr noundef %11, ptr noundef %26, i32 noundef 2, i16 noundef zeroext 10, i32 noundef -1)
          to label %28 unwind label %42

28:                                               ; preds = %24
  %29 = icmp ne i32 %27, 0
  br i1 %29, label %46, label %30

30:                                               ; preds = %28
  %31 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %32 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %31, ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 49)
          to label %33 unwind label %42

33:                                               ; preds = %30
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %46

34:                                               ; preds = %144, %140, %130, %2
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %7, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %8, align 4
  br label %150

38:                                               ; preds = %22
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %7, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %8, align 4
  br label %129

42:                                               ; preds = %30, %24
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %7, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %8, align 4
  br label %128

46:                                               ; preds = %33, %28
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 @__const.main.signal, i64 8, i1 false)
  %49 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 0
  invoke void @PcanGainControlApply(ptr noundef %11, ptr noundef %49)
          to label %50 unwind label %62

50:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 @__const.main.expected, i64 8, i1 false)
  br label %51

51:                                               ; preds = %50
  %52 = getelementptr inbounds %struct.PcanGainControlState, ptr %11, i32 0, i32 2
  %53 = load i32, ptr %52, align 8, !tbaa !15
  %54 = sext i32 %53 to i64
  %55 = icmp ne i64 %54, 2
  br i1 %55, label %56, label %70

56:                                               ; preds = %51
  %57 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.PcanGainControlState, ptr %11, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !15
  %60 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef @.str.4, ptr noundef @.str.3, i32 noundef 56, i32 noundef %59, i64 noundef 2)
          to label %61 unwind label %66

61:                                               ; preds = %56
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %70

62:                                               ; preds = %48
  %63 = landingpad { ptr, i32 }
          cleanup
  %64 = extractvalue { ptr, i32 } %63, 0
  store ptr %64, ptr %7, align 8
  %65 = extractvalue { ptr, i32 } %63, 1
  store i32 %65, ptr %8, align 4
  br label %127

66:                                               ; preds = %56
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %7, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %8, align 4
  br label %126

70:                                               ; preds = %61, %51
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %108, %72
  %74 = load i32, ptr %14, align 4, !tbaa !5
  %75 = getelementptr inbounds %struct.PcanGainControlState, ptr %11, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !15
  %77 = icmp slt i32 %74, %76
  br i1 %77, label %78, label %111

78:                                               ; preds = %73
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %14, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %14, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [2 x i32], ptr %13, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = icmp ne i32 %83, %87
  br i1 %88, label %89, label %105

89:                                               ; preds = %79
  %90 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %91 = load i32, ptr %14, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr %14, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2 x i32], ptr %13, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %90, ptr noundef @.str.5, ptr noundef @.str.3, i32 noundef 59, i32 noundef %94, i32 noundef %98)
          to label %100 unwind label %101

100:                                              ; preds = %89
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %105

101:                                              ; preds = %111, %89
  %102 = landingpad { ptr, i32 }
          cleanup
  %103 = extractvalue { ptr, i32 } %102, 0
  store ptr %103, ptr %7, align 8
  %104 = extractvalue { ptr, i32 } %102, 1
  store i32 %104, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %126

105:                                              ; preds = %100, %79
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %14, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %14, align 4, !tbaa !5
  br label %73, !llvm.loop !17

111:                                              ; preds = %73
  invoke void @PcanGainControlFreeStateContents(ptr noundef %11)
          to label %112 unwind label %101

112:                                              ; preds = %111
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %113

113:                                              ; preds = %112
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %114 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %115 = trunc i8 %114 to i1
  %116 = zext i1 %115 to i64
  %117 = select i1 %115, i32 0, i32 1
  %118 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %119 = add nsw i32 %118, %117
  store i32 %119, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %120 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !13, !noundef !14
  %121 = trunc i8 %120 to i1
  %122 = zext i1 %121 to i64
  %123 = select i1 %121, i32 1, i32 0
  %124 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %125 = add nsw i32 %124, %123
  store i32 %125, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  br label %18, !llvm.loop !19

126:                                              ; preds = %101, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %127

127:                                              ; preds = %126, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %128

128:                                              ; preds = %127, %42
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #6
  br label %129

129:                                              ; preds = %128, %38
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %150

130:                                              ; preds = %18
  %131 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %132 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %133 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %134 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %135 = add nsw i32 %133, %134
  %136 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %131, ptr noundef @.str.6, i32 noundef %132, i32 noundef %135)
          to label %137 unwind label %34

137:                                              ; preds = %130
  %138 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %139 = icmp eq i32 %138, 0
  br i1 %139, label %140, label %144

140:                                              ; preds = %137
  %141 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %142 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %141, ptr noundef @.str.7)
          to label %143 unwind label %34

143:                                              ; preds = %140
  br label %148

144:                                              ; preds = %137
  %145 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %146 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %145, ptr noundef @.str.8)
          to label %147 unwind label %34

147:                                              ; preds = %144
  br label %148

148:                                              ; preds = %147, %143
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %149 = load i32, ptr %3, align 4
  ret i32 %149

150:                                              ; preds = %129, %34
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %151

151:                                              ; preds = %150
  %152 = load ptr, ptr %7, align 8
  %153 = load i32, ptr %8, align 4
  %154 = insertvalue { ptr, i32 } poison, ptr %152, 0
  %155 = insertvalue { ptr, i32 } %154, i32 %153, 1
  resume { ptr, i32 } %155
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare noundef i32 @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ...) #3

declare i32 @__gxx_personality_v0(...)

; 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) #4

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_125PcanGainControlTestConfigC2Ev(ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #5 align 2

declare i32 @PcanGainControlPopulateState(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i16 noundef zeroext, i32 noundef) #3

declare void @PcanGainControlApply(ptr noundef, ptr noundef) #3

declare void @PcanGainControlFreeStateContents(ptr noundef) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5 align 2

attributes #0 = { mustprogress norecurse 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 16}
!16 = !{!"_ZTS20PcanGainControlState", !6, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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"

%"class.tflite::MicroErrorReporter" = type { %"class.tflite::ErrorReporter" }
%"class.tflite::ErrorReporter" = type { ptr }
%"class.(anonymous namespace)::PcanGainControlTestConfig" = type { %struct.PcanGainControlConfig }
%struct.PcanGainControlConfig = type { i32, float, float, i32 }
%struct.PcanGainControlState = type { i32, ptr, i32, ptr, i32 }

@_ZN10micro_test12tests_passedE = external dso_local local_unnamed_addr global i32, align 4
@_ZN10micro_test12tests_failedE = external dso_local local_unnamed_addr global i32, align 4
@_ZN10micro_test16is_test_completeE = external dso_local local_unnamed_addr global i8, align 1
@_ZN10micro_test13did_test_failE = external dso_local local_unnamed_addr global i8, align 1
@_ZN10micro_test8reporterE = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [40 x i8], align 1
@__const.main.estimate = external hidden unnamed_addr constant [2 x i32], align 4
@.str.2 = external hidden unnamed_addr constant [128 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [124 x i8], align 1
@__const.main.signal = external hidden unnamed_addr constant [2 x i32], align 4
@__const.main.expected = external hidden unnamed_addr constant [2 x i32], align 4
@.str.4 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.tflite::MicroErrorReporter", align 8
  %4 = alloca [2 x i32], align 8
  %5 = alloca %"class.(anonymous namespace)::PcanGainControlTestConfig", align 4
  %6 = alloca %struct.PcanGainControlState, align 8
  %7 = alloca [2 x i32], align 8
  store i32 0, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  store i32 0, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  store ptr %3, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %8 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
          to label %9 unwind label %19

9:                                                ; preds = %2
  store i8 0, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  store i8 0, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  %10 = load i64, ptr @__const.main.signal, align 4
  %11 = getelementptr inbounds i8, ptr %6, i64 16
  %12 = load i64, ptr @__const.main.estimate, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store i64 %12, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  call void @_ZN12_GLOBAL__N_125PcanGainControlTestConfigC2Ev(ptr noundef nonnull align 4 dereferenceable(16) %5)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #5
  %13 = invoke i32 @PcanGainControlPopulateState(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %4, i32 noundef 2, i16 noundef zeroext 10, i32 noundef -1)
          to label %14 unwind label %21

14:                                               ; preds = %9
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %15, label %23

15:                                               ; preds = %14
  %16 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %17 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 49)
          to label %18 unwind label %21

18:                                               ; preds = %15
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  br label %23

19:                                               ; preds = %.invoke, %._crit_edge24, %2
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %65

21:                                               ; preds = %15, %9
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %49

23:                                               ; preds = %18, %14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store i64 %10, ptr %7, align 8
  invoke void @PcanGainControlApply(ptr noundef nonnull %6, ptr noundef nonnull %7)
          to label %24 unwind label %29

24:                                               ; preds = %23
  %25 = load i32, ptr %11, align 8, !tbaa !13
  %.not15 = icmp eq i32 %25, 2
  br i1 %.not15, label %.lr.ph.preheader, label %26

26:                                               ; preds = %24
  %27 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %28 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %27, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.3, i32 noundef 56, i32 noundef %25, i64 noundef 2)
          to label %33 unwind label %31

29:                                               ; preds = %23
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %48

31:                                               ; preds = %26
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %48

33:                                               ; preds = %26
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  %.pre = load i32, ptr %11, align 8, !tbaa !13
  %34 = icmp sgt i32 %.pre, 0
  br i1 %34, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %24, %33
  %.ph = phi i32 [ 2, %24 ], [ %.pre, %33 ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %44
  %35 = phi i32 [ %45, %44 ], [ %.ph, %.lr.ph.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %44 ], [ 0, %.lr.ph.preheader ]
  %36 = getelementptr inbounds [2 x i32], ptr %7, i64 0, i64 %indvars.iv
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = getelementptr inbounds [2 x i32], ptr @__const.main.expected, i64 0, i64 %indvars.iv
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %.not16 = icmp eq i32 %37, %39
  br i1 %.not16, label %44, label %40

40:                                               ; preds = %.lr.ph
  %41 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %42 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3, i32 noundef 59, i32 noundef %37, i32 noundef %39)
          to label %43 unwind label %.loopexit

43:                                               ; preds = %40
  store i8 1, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11
  %.pre26 = load i32, ptr %11, align 8, !tbaa !13
  br label %44

.loopexit:                                        ; preds = %40
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %48

.loopexit.split-lp:                               ; preds = %._crit_edge
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %48

44:                                               ; preds = %.lr.ph, %43
  %45 = phi i32 [ %35, %.lr.ph ], [ %.pre26, %43 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %46 = sext i32 %45 to i64
  %47 = icmp slt i64 %indvars.iv.next, %46
  br i1 %47, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %44, %33
  invoke void @PcanGainControlFreeStateContents(ptr noundef nonnull %6)
          to label %._crit_edge24 unwind label %.loopexit.split-lp

48:                                               ; preds = %.loopexit, %.loopexit.split-lp, %31, %29
  %.pn.pn = phi { ptr, i32 } [ %30, %29 ], [ %32, %31 ], [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %49

49:                                               ; preds = %48, %21
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %48 ], [ %22, %21 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %65

._crit_edge24:                                    ; preds = %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  store i8 1, ptr @_ZN10micro_test16is_test_completeE, align 1, !tbaa !11
  %50 = load i8, ptr @_ZN10micro_test13did_test_failE, align 1, !tbaa !11, !range !17, !noundef !18
  %51 = xor i8 %50, 1
  %not. = zext nneg i8 %51 to i32
  %52 = load i32, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %53 = add nsw i32 %52, %not.
  store i32 %53, ptr @_ZN10micro_test12tests_passedE, align 4, !tbaa !5
  %54 = zext nneg i8 %50 to i32
  %55 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %57 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %58 = add nsw i32 %56, %53
  %59 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull @.str.6, i32 noundef %53, i32 noundef %58)
          to label %.invoke unwind label %19

.invoke:                                          ; preds = %._crit_edge24
  %60 = load i32, ptr @_ZN10micro_test12tests_failedE, align 4, !tbaa !5
  %61 = icmp eq i32 %60, 0
  %62 = load ptr, ptr @_ZN10micro_test8reporterE, align 8, !tbaa !9
  %.str.7..str.8 = select i1 %61, ptr @.str.7, ptr @.str.8
  %63 = invoke noundef i32 (ptr, ptr, ...) @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8) %62, ptr noundef nonnull %.str.7..str.8)
          to label %64 unwind label %19

64:                                               ; preds = %.invoke
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i32 0

65:                                               ; preds = %49, %19
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %49 ], [ %20, %19 ]
  call void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  resume { ptr, i32 } %.pn.pn.pn.pn
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite18MicroErrorReporterC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare noundef i32 @_ZN6tflite13ErrorReporter6ReportEPKcz(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ...) local_unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_125PcanGainControlTestConfigC2Ev(ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #4 align 2

declare i32 @PcanGainControlPopulateState(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i16 noundef zeroext, i32 noundef) local_unnamed_addr #3

declare void @PcanGainControlApply(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @PcanGainControlFreeStateContents(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6tflite13ErrorReporterD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

attributes #0 = { mustprogress norecurse 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 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 #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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"_ZTS20PcanGainControlState", !6, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i8 0, i8 2}
!18 = !{}


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