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

; 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.TIM_HandleTypeDef = type { ptr, %struct.TIM_Base_InitTypeDef, i32, [7 x ptr], i32, i32 }
%struct.TIM_Base_InitTypeDef = type { i32, i32, i32, i32, i32, i32 }
%struct.TIM_BreakDeadTimeConfigTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.TIM_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_TIMEx_ConfigBreakDeadTime(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %9, i32 0, i32 4
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %14

13:                                               ; preds = %8
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %142

14:                                               ; preds = %8
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %15, i32 0, i32 4
  store i32 1, ptr %16, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %14
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = and i64 %21, -256
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %23, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !14
  %26 = zext i32 %25 to i64
  %27 = or i64 %22, %26
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = and i64 %30, -769
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = zext i32 %34 to i64
  %36 = or i64 %31, %35
  %37 = trunc i64 %36 to i32
  store i32 %37, ptr %6, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = and i64 %39, -1025
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = zext i32 %43 to i64
  %45 = or i64 %40, %44
  %46 = trunc i64 %45 to i32
  store i32 %46, ptr %6, align 4, !tbaa !9
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = and i64 %48, -2049
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !18
  %53 = zext i32 %52 to i64
  %54 = or i64 %49, %53
  %55 = trunc i64 %54 to i32
  store i32 %55, ptr %6, align 4, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = and i64 %57, -4097
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %59, i32 0, i32 4
  %61 = load i32, ptr %60, align 4, !tbaa !19
  %62 = zext i32 %61 to i64
  %63 = or i64 %58, %62
  %64 = trunc i64 %63 to i32
  store i32 %64, ptr %6, align 4, !tbaa !9
  %65 = load i32, ptr %6, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = and i64 %66, -8193
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %68, i32 0, i32 5
  %70 = load i32, ptr %69, align 4, !tbaa !20
  %71 = zext i32 %70 to i64
  %72 = or i64 %67, %71
  %73 = trunc i64 %72 to i32
  store i32 %73, ptr %6, align 4, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = and i64 %75, -16385
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %77, i32 0, i32 10
  %79 = load i32, ptr %78, align 4, !tbaa !21
  %80 = zext i32 %79 to i64
  %81 = or i64 %76, %80
  %82 = trunc i64 %81 to i32
  store i32 %82, ptr %6, align 4, !tbaa !9
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = and i64 %84, -983041
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %86, i32 0, i32 6
  %88 = load i32, ptr %87, align 4, !tbaa !22
  %89 = shl i32 %88, 16
  %90 = zext i32 %89 to i64
  %91 = or i64 %85, %90
  %92 = trunc i64 %91 to i32
  store i32 %92, ptr %6, align 4, !tbaa !9
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !23
  %96 = icmp eq ptr %95, inttoptr (i64 1073807360 to ptr)
  br i1 %96, label %102, label %97

97:                                               ; preds = %19
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !23
  %101 = icmp eq ptr %100, inttoptr (i64 1073808384 to ptr)
  br i1 %101, label %102, label %131

102:                                              ; preds = %97, %19
  %103 = load i32, ptr %6, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = and i64 %104, -15728641
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %106, i32 0, i32 9
  %108 = load i32, ptr %107, align 4, !tbaa !24
  %109 = shl i32 %108, 20
  %110 = zext i32 %109 to i64
  %111 = or i64 %105, %110
  %112 = trunc i64 %111 to i32
  store i32 %112, ptr %6, align 4, !tbaa !9
  %113 = load i32, ptr %6, align 4, !tbaa !9
  %114 = zext i32 %113 to i64
  %115 = and i64 %114, -16777217
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %116, i32 0, i32 7
  %118 = load i32, ptr %117, align 4, !tbaa !25
  %119 = zext i32 %118 to i64
  %120 = or i64 %115, %119
  %121 = trunc i64 %120 to i32
  store i32 %121, ptr %6, align 4, !tbaa !9
  %122 = load i32, ptr %6, align 4, !tbaa !9
  %123 = zext i32 %122 to i64
  %124 = and i64 %123, -33554433
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.TIM_BreakDeadTimeConfigTypeDef, ptr %125, i32 0, i32 8
  %127 = load i32, ptr %126, align 4, !tbaa !26
  %128 = zext i32 %127 to i64
  %129 = or i64 %124, %128
  %130 = trunc i64 %129 to i32
  store i32 %130, ptr %6, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %102, %97
  %132 = load i32, ptr %6, align 4, !tbaa !9
  %133 = load ptr, ptr %4, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %133, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !23
  %136 = getelementptr inbounds %struct.TIM_TypeDef, ptr %135, i32 0, i32 17
  store volatile i32 %132, ptr %136, align 4, !tbaa !27
  br label %137

137:                                              ; preds = %131
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.TIM_HandleTypeDef, ptr %138, i32 0, i32 4
  store i32 0, ptr %139, align 8, !tbaa !11
  br label %140

140:                                              ; preds = %137
  br label %141

141:                                              ; preds = %140
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %142

142:                                              ; preds = %141, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %143 = load i32, ptr %3, align 4
  ret i32 %143
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 96}
!12 = !{!"", !6, i64 0, !13, i64 8, !10, i64 32, !7, i64 40, !10, i64 96, !10, i64 100}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!14 = !{!15, !10, i64 12}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40}
!16 = !{!15, !10, i64 8}
!17 = !{!15, !10, i64 4}
!18 = !{!15, !10, i64 0}
!19 = !{!15, !10, i64 16}
!20 = !{!15, !10, i64 20}
!21 = !{!15, !10, i64 40}
!22 = !{!15, !10, i64 24}
!23 = !{!12, !6, i64 0}
!24 = !{!15, !10, i64 36}
!25 = !{!15, !10, i64 28}
!26 = !{!15, !10, i64 32}
!27 = !{!28, !10, i64 68}
!28 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104}


; 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: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_TIMEx_ConfigBreakDeadTime(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %37, label %6

6:                                                ; preds = %2
  %7 = load <4 x i32>, ptr %1, align 4, !tbaa !12
  %8 = and <4 x i32> %7, <i32 -1011713, i32 -1013761, i32 -15361, i32 -16129>
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %.masked33 = and i32 %10, -1007617
  %11 = getelementptr inbounds i8, ptr %1, i64 20
  %12 = load i32, ptr %11, align 4, !tbaa !15
  %13 = tail call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %8)
  %op.rdx = or i32 %13, %.masked33
  %op.rdx37 = or i32 %op.rdx, %12
  %14 = and i32 %op.rdx37, -999425
  %15 = getelementptr inbounds i8, ptr %1, i64 40
  %16 = load i32, ptr %15, align 4, !tbaa !16
  %.masked34 = and i32 %16, -983041
  %17 = or i32 %14, %.masked34
  %18 = getelementptr inbounds i8, ptr %1, i64 24
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = shl i32 %19, 16
  %21 = or i32 %17, %20
  %22 = load ptr, ptr %0, align 8, !tbaa !18
  %magicptr = ptrtoint ptr %22 to i64
  switch i64 %magicptr, label %35 [
    i64 1073807360, label %23
    i64 1073808384, label %23
  ]

23:                                               ; preds = %6, %6
  %24 = and i32 %21, -66060289
  %25 = getelementptr inbounds i8, ptr %1, i64 36
  %26 = load i32, ptr %25, align 4, !tbaa !19
  %27 = shl i32 %26, 20
  %.masked35 = and i32 %27, -51380224
  %28 = or i32 %.masked35, %24
  %29 = getelementptr inbounds i8, ptr %1, i64 28
  %30 = load i32, ptr %29, align 4, !tbaa !20
  %.masked36 = and i32 %30, -33554433
  %31 = or i32 %28, %.masked36
  %32 = getelementptr inbounds i8, ptr %1, i64 32
  %33 = load i32, ptr %32, align 4, !tbaa !21
  %34 = or i32 %31, %33
  br label %35

35:                                               ; preds = %6, %23
  %.0 = phi i32 [ %34, %23 ], [ %21, %6 ]
  %36 = getelementptr inbounds i8, ptr %22, i64 68
  store volatile i32 %.0, ptr %36, align 4, !tbaa !22
  store i32 0, ptr %3, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %2, %35
  %.029 = phi i32 [ 0, %35 ], [ 2, %2 ]
  ret i32 %.029
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.or.v4i32(<4 x i32>) #1

attributes #0 = { nofree norecurse 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !11, i64 96}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 32, !8, i64 40, !11, i64 96, !11, i64 100}
!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 = !{!"int", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 16}
!14 = !{!"", !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}
!15 = !{!14, !11, i64 20}
!16 = !{!14, !11, i64 40}
!17 = !{!14, !11, i64 24}
!18 = !{!6, !7, i64 0}
!19 = !{!14, !11, i64 36}
!20 = !{!14, !11, i64 28}
!21 = !{!14, !11, i64 32}
!22 = !{!23, !11, i64 68}
!23 = !{!"", !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, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass