; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Drivers/STM32H7xx_HAL_Driver/Src (Enable)

; 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.ADC_HandleTypeDef = type { ptr, %struct.ADC_InitTypeDef, ptr, i32, i32, i32, %struct.ADC_InjectionConfigTypeDef }
%struct.ADC_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ADC_OversamplingTypeDef }
%struct.ADC_OversamplingTypeDef = type { i32, i32, i32, i32 }
%struct.ADC_InjectionConfigTypeDef = type { i32, i32 }
%struct.ADC_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @LL_ADC_IsEnabled(ptr noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @LL_ADC_GetMultimode(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ADC_Enable(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = call i32 @LL_ADC_IsEnabled(ptr noundef %9)
  %11 = zext i32 %10 to i64
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %13, label %118

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.ADC_TypeDef, ptr %16, i32 0, i32 2
  %18 = load volatile i32, ptr %17, align 4, !tbaa !15
  %19 = zext i32 %18 to i64
  %20 = and i64 %19, 2147483711
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %33

22:                                               ; preds = %13
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %23, i32 0, i32 4
  %25 = load volatile i32, ptr %24, align 4, !tbaa !17
  %26 = zext i32 %25 to i64
  %27 = or i64 %26, 16
  %28 = trunc i64 %27 to i32
  store volatile i32 %28, ptr %24, align 4, !tbaa !17
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %29, i32 0, i32 5
  %31 = load volatile i32, ptr %30, align 8, !tbaa !18
  %32 = or i32 %31, 1
  store volatile i32 %32, ptr %30, align 8, !tbaa !18
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %119

33:                                               ; preds = %13
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  call void @LL_ADC_Enable(ptr noundef %36)
  %37 = call i32 @HAL_GetTick()
  store i32 %37, ptr %4, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = icmp eq ptr %40, inttoptr (i64 1073881088 to ptr)
  br i1 %41, label %47, label %42

42:                                               ; preds = %33
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = icmp eq ptr %45, inttoptr (i64 1073881344 to ptr)
  br label %47

47:                                               ; preds = %42, %33
  %48 = phi i1 [ true, %33 ], [ %46, %42 ]
  %49 = zext i1 %48 to i64
  %50 = select i1 %48, ptr inttoptr (i64 1073881856 to ptr), ptr inttoptr (i64 1476551424 to ptr)
  %51 = call i32 @LL_ADC_GetMultimode(ptr noundef %50)
  store i32 %51, ptr %6, align 4, !tbaa !19
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = icmp eq ptr %54, inttoptr (i64 1073881344 to ptr)
  br i1 %55, label %56, label %57

56:                                               ; preds = %47
  br label %61

57:                                               ; preds = %47
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %57, %56
  %62 = phi ptr [ inttoptr (i64 1073881088 to ptr), %56 ], [ %60, %57 ]
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = icmp eq ptr %62, %65
  br i1 %66, label %71, label %67

67:                                               ; preds = %61
  %68 = load i32, ptr %6, align 4, !tbaa !19
  %69 = zext i32 %68 to i64
  %70 = icmp eq i64 %69, 0
  br i1 %70, label %71, label %114

71:                                               ; preds = %67, %61
  br label %72

72:                                               ; preds = %112, %71
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.ADC_TypeDef, ptr %75, i32 0, i32 0
  %77 = load volatile i32, ptr %76, align 4, !tbaa !20
  %78 = zext i32 %77 to i64
  %79 = and i64 %78, 1
  %80 = icmp eq i64 %79, 1
  %81 = zext i1 %80 to i32
  %82 = sext i32 %81 to i64
  %83 = icmp eq i64 %82, 0
  br i1 %83, label %84, label %113

84:                                               ; preds = %72
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = call i32 @LL_ADC_IsEnabled(ptr noundef %87)
  %89 = zext i32 %88 to i64
  %90 = icmp eq i64 %89, 0
  br i1 %90, label %91, label %95

91:                                               ; preds = %84
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !9
  call void @LL_ADC_Enable(ptr noundef %94)
  br label %95

95:                                               ; preds = %91, %84
  %96 = call i32 @HAL_GetTick()
  %97 = load i32, ptr %4, align 4, !tbaa !19
  %98 = sub i32 %96, %97
  %99 = zext i32 %98 to i64
  %100 = icmp ugt i64 %99, 2
  br i1 %100, label %101, label %112

101:                                              ; preds = %95
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %102, i32 0, i32 4
  %104 = load volatile i32, ptr %103, align 4, !tbaa !17
  %105 = zext i32 %104 to i64
  %106 = or i64 %105, 16
  %107 = trunc i64 %106 to i32
  store volatile i32 %107, ptr %103, align 4, !tbaa !17
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.ADC_HandleTypeDef, ptr %108, i32 0, i32 5
  %110 = load volatile i32, ptr %109, align 8, !tbaa !18
  %111 = or i32 %110, 1
  store volatile i32 %111, ptr %109, align 8, !tbaa !18
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %115

112:                                              ; preds = %95
  br label %72, !llvm.loop !21

113:                                              ; preds = %72
  br label %114

114:                                              ; preds = %113, %67
  store i32 0, ptr %5, align 4
  br label %115

115:                                              ; preds = %114, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %116 = load i32, ptr %5, align 4
  switch i32 %116, label %119 [
    i32 0, label %117
  ]

117:                                              ; preds = %115
  br label %118

118:                                              ; preds = %117, %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %119

119:                                              ; preds = %118, %115, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %120 = load i32, ptr %2, align 4
  ret i32 %120
}

declare i32 @HAL_GetTick() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @LL_ADC_Enable(ptr noundef) #1

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 88, !12, i64 96, !12, i64 100, !12, i64 104, !14, i64 108}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !13, i64 60}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!14 = !{!"", !12, i64 0, !12, i64 4}
!15 = !{!16, !12, i64 8}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !7, i64 80, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !7, i64 112, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !7, i64 144, !12, i64 160, !12, i64 164, !12, i64 168, !12, i64 172, !12, i64 176, !12, i64 180, !12, i64 184, !12, i64 188, !12, i64 192, !12, i64 196, !12, i64 200}
!17 = !{!10, !12, i64 100}
!18 = !{!10, !12, i64 104}
!19 = !{!12, !12, i64 0}
!20 = !{!16, !12, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @LL_ADC_IsEnabled(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @LL_ADC_GetMultimode(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ADC_Enable(ptr noundef %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = tail call i32 @LL_ADC_IsEnabled(ptr noundef %2)
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %5, label %.loopexit

5:                                                ; preds = %1
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load volatile i32, ptr %7, align 4, !tbaa !14
  %9 = and i32 %8, -2147483585
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %.loopexit.sink.split

10:                                               ; preds = %5
  tail call void @LL_ADC_Enable(ptr noundef nonnull %6)
  %11 = tail call i32 @HAL_GetTick() #3
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = icmp eq ptr %12, inttoptr (i64 1073881088 to ptr)
  %14 = icmp eq ptr %12, inttoptr (i64 1073881344 to ptr)
  %spec.select = or i1 %13, %14
  %15 = select i1 %spec.select, ptr inttoptr (i64 1073881856 to ptr), ptr inttoptr (i64 1476551424 to ptr)
  %16 = tail call i32 @LL_ADC_GetMultimode(ptr noundef nonnull %15)
  %17 = load ptr, ptr %0, align 8, !tbaa !5
  %18 = icmp ne ptr %17, inttoptr (i64 1073881344 to ptr)
  %19 = icmp eq i32 %16, 0
  %or.cond = select i1 %18, i1 true, i1 %19
  br i1 %or.cond, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %10, %29
  %20 = load ptr, ptr %0, align 8, !tbaa !5
  %21 = load volatile i32, ptr %20, align 4, !tbaa !16
  %22 = and i32 %21, 1
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %.loopexit

24:                                               ; preds = %.preheader
  %25 = tail call i32 @LL_ADC_IsEnabled(ptr noundef nonnull %20)
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %24
  %28 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @LL_ADC_Enable(ptr noundef %28)
  br label %29

29:                                               ; preds = %27, %24
  %30 = tail call i32 @HAL_GetTick() #3
  %31 = sub i32 %30, %11
  %32 = icmp ugt i32 %31, 2
  br i1 %32, label %.loopexit.sink.split, label %.preheader, !llvm.loop !17

.loopexit.sink.split:                             ; preds = %29, %5
  %33 = getelementptr inbounds i8, ptr %0, i64 100
  %34 = load volatile i32, ptr %33, align 4, !tbaa !19
  %35 = or i32 %34, 16
  store volatile i32 %35, ptr %33, align 4, !tbaa !19
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  %37 = load volatile i32, ptr %36, align 8, !tbaa !20
  %38 = or i32 %37, 1
  store volatile i32 %38, ptr %36, align 8, !tbaa !20
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.sink.split, %1, %10
  %.1 = phi i32 [ 0, %10 ], [ 0, %1 ], [ 1, %.loopexit.sink.split ], [ 0, %.preheader ]
  ret i32 %.1
}

declare i32 @HAL_GetTick() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @LL_ADC_Enable(ptr noundef) local_unnamed_addr #0

attributes #0 = { inlinehint 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 #1 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 88, !11, i64 96, !11, i64 100, !11, i64 104, !13, i64 108}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !12, i64 60}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!13 = !{!"", !11, i64 0, !11, i64 4}
!14 = !{!15, !11, i64 8}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !8, i64 80, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !8, i64 112, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !8, i64 144, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200}
!16 = !{!15, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !11, i64 100}
!20 = !{!6, !11, i64 104}


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