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

; 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.__I2C_HandleTypeDef = type { ptr, %struct.I2C_InitTypeDef, ptr, i16, i16, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.I2C_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.I2C_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_I2C_Init(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store i32 1, ptr %2, align 4
  br label %149

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %8, i32 0, i32 11
  %10 = load volatile i32, ptr %9, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %16

12:                                               ; preds = %7
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %13, i32 0, i32 10
  store i32 0, ptr %14, align 8, !tbaa !14
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @HAL_I2C_MspInit(ptr noundef %15)
  br label %16

16:                                               ; preds = %12, %7
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %17, i32 0, i32 11
  store volatile i32 36, ptr %18, align 4, !tbaa !9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.I2C_TypeDef, ptr %21, i32 0, i32 0
  %23 = load volatile i32, ptr %22, align 4, !tbaa !16
  %24 = zext i32 %23 to i64
  %25 = and i64 %24, -2
  %26 = trunc i64 %25 to i32
  store volatile i32 %26, ptr %22, align 4, !tbaa !16
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !18
  %31 = and i32 %30, -251658241
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = getelementptr inbounds %struct.I2C_TypeDef, ptr %34, i32 0, i32 4
  store volatile i32 %31, ptr %35, align 4, !tbaa !19
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds %struct.I2C_TypeDef, ptr %38, i32 0, i32 2
  %40 = load volatile i32, ptr %39, align 4, !tbaa !20
  %41 = zext i32 %40 to i64
  %42 = and i64 %41, -32769
  %43 = trunc i64 %42 to i32
  store volatile i32 %43, ptr %39, align 4, !tbaa !20
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !21
  %48 = icmp eq i32 %47, 1
  br i1 %48, label %49, label %61

49:                                               ; preds = %16
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !22
  %54 = zext i32 %53 to i64
  %55 = or i64 32768, %54
  %56 = trunc i64 %55 to i32
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = getelementptr inbounds %struct.I2C_TypeDef, ptr %59, i32 0, i32 2
  store volatile i32 %56, ptr %60, align 4, !tbaa !20
  br label %73

61:                                               ; preds = %16
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !22
  %66 = zext i32 %65 to i64
  %67 = or i64 33792, %66
  %68 = trunc i64 %67 to i32
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !15
  %72 = getelementptr inbounds %struct.I2C_TypeDef, ptr %71, i32 0, i32 2
  store volatile i32 %68, ptr %72, align 4, !tbaa !20
  br label %73

73:                                               ; preds = %61, %49
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %75, i32 0, i32 2
  %77 = load i32, ptr %76, align 8, !tbaa !21
  %78 = icmp eq i32 %77, 2
  br i1 %78, label %79, label %84

79:                                               ; preds = %73
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !15
  %83 = getelementptr inbounds %struct.I2C_TypeDef, ptr %82, i32 0, i32 1
  store volatile i32 2048, ptr %83, align 4, !tbaa !23
  br label %84

84:                                               ; preds = %79, %73
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = getelementptr inbounds %struct.I2C_TypeDef, ptr %87, i32 0, i32 1
  %89 = load volatile i32, ptr %88, align 4, !tbaa !23
  %90 = zext i32 %89 to i64
  %91 = or i64 %90, 33587200
  %92 = trunc i64 %91 to i32
  store volatile i32 %92, ptr %88, align 4, !tbaa !23
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !15
  %96 = getelementptr inbounds %struct.I2C_TypeDef, ptr %95, i32 0, i32 3
  %97 = load volatile i32, ptr %96, align 4, !tbaa !24
  %98 = zext i32 %97 to i64
  %99 = and i64 %98, -32769
  %100 = trunc i64 %99 to i32
  store volatile i32 %100, ptr %96, align 4, !tbaa !24
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %101, i32 0, i32 1
  %103 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %102, i32 0, i32 3
  %104 = load i32, ptr %103, align 4, !tbaa !25
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %105, i32 0, i32 1
  %107 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %106, i32 0, i32 4
  %108 = load i32, ptr %107, align 8, !tbaa !26
  %109 = or i32 %104, %108
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %110, i32 0, i32 1
  %112 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %111, i32 0, i32 5
  %113 = load i32, ptr %112, align 4, !tbaa !27
  %114 = shl i32 %113, 8
  %115 = or i32 %109, %114
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %116, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !15
  %119 = getelementptr inbounds %struct.I2C_TypeDef, ptr %118, i32 0, i32 3
  store volatile i32 %115, ptr %119, align 4, !tbaa !24
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %120, i32 0, i32 1
  %122 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %121, i32 0, i32 6
  %123 = load i32, ptr %122, align 8, !tbaa !28
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %124, i32 0, i32 1
  %126 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %125, i32 0, i32 7
  %127 = load i32, ptr %126, align 4, !tbaa !29
  %128 = or i32 %123, %127
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !15
  %132 = getelementptr inbounds %struct.I2C_TypeDef, ptr %131, i32 0, i32 0
  store volatile i32 %128, ptr %132, align 4, !tbaa !16
  %133 = load ptr, ptr %3, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %133, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !15
  %136 = getelementptr inbounds %struct.I2C_TypeDef, ptr %135, i32 0, i32 0
  %137 = load volatile i32, ptr %136, align 4, !tbaa !16
  %138 = zext i32 %137 to i64
  %139 = or i64 %138, 1
  %140 = trunc i64 %139 to i32
  store volatile i32 %140, ptr %136, align 4, !tbaa !16
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %141, i32 0, i32 13
  store volatile i32 0, ptr %142, align 4, !tbaa !30
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %143, i32 0, i32 11
  store volatile i32 32, ptr %144, align 4, !tbaa !9
  %145 = load ptr, ptr %3, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %145, i32 0, i32 6
  store volatile i32 0, ptr %146, align 8, !tbaa !31
  %147 = load ptr, ptr %3, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %147, i32 0, i32 12
  store volatile i32 0, ptr %148, align 8, !tbaa !32
  store i32 0, ptr %2, align 4
  br label %149

149:                                              ; preds = %84, %6
  %150 = load i32, ptr %2, align 4
  ret i32 %150
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_I2C_MspInit(ptr noundef) #0

attributes #0 = { 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" }

!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, !12, i64 92}
!10 = !{!"__I2C_HandleTypeDef", !6, i64 0, !11, i64 8, !6, i64 40, !13, i64 48, !13, i64 50, !12, i64 52, !12, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104}
!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 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !12, i64 88}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"", !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}
!18 = !{!10, !12, i64 8}
!19 = !{!17, !12, i64 16}
!20 = !{!17, !12, i64 8}
!21 = !{!10, !12, i64 16}
!22 = !{!10, !12, i64 12}
!23 = !{!17, !12, i64 4}
!24 = !{!17, !12, i64 12}
!25 = !{!10, !12, i64 20}
!26 = !{!10, !12, i64 24}
!27 = !{!10, !12, i64 28}
!28 = !{!10, !12, i64 32}
!29 = !{!10, !12, i64 36}
!30 = !{!10, !12, i64 100}
!31 = !{!10, !12, i64 56}
!32 = !{!10, !12, i64 96}


; 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: nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_I2C_Init(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %57, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 92
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 0, ptr %8, align 8, !tbaa !13
  tail call void @HAL_I2C_MspInit(ptr noundef nonnull %0)
  br label %9

9:                                                ; preds = %7, %3
  store volatile i32 36, ptr %4, align 4, !tbaa !5
  %10 = load ptr, ptr %0, align 8, !tbaa !14
  %11 = load volatile i32, ptr %10, align 4, !tbaa !15
  %12 = and i32 %11, -2
  store volatile i32 %12, ptr %10, align 4, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = and i32 %14, -251658241
  %16 = getelementptr inbounds i8, ptr %10, i64 16
  store volatile i32 %15, ptr %16, align 4, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %10, i64 8
  %18 = load volatile i32, ptr %17, align 4, !tbaa !19
  %19 = and i32 %18, -32769
  store volatile i32 %19, ptr %17, align 4, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load i32, ptr %20, align 8, !tbaa !20
  %22 = icmp eq i32 %21, 1
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load i32, ptr %23, align 4, !tbaa !21
  br i1 %22, label %.thread, label %26

.thread:                                          ; preds = %9
  %25 = or i32 %24, 32768
  store volatile i32 %25, ptr %17, align 4, !tbaa !19
  br label %31

26:                                               ; preds = %9
  %27 = or i32 %24, 33792
  store volatile i32 %27, ptr %17, align 4, !tbaa !19
  %28 = icmp eq i32 %21, 2
  br i1 %28, label %29, label %31

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %10, i64 4
  store volatile i32 2048, ptr %30, align 4, !tbaa !22
  br label %31

31:                                               ; preds = %.thread, %29, %26
  %32 = getelementptr inbounds i8, ptr %10, i64 4
  %33 = load volatile i32, ptr %32, align 4, !tbaa !22
  %34 = or i32 %33, 33587200
  store volatile i32 %34, ptr %32, align 4, !tbaa !22
  %35 = getelementptr inbounds i8, ptr %10, i64 12
  %36 = load volatile i32, ptr %35, align 4, !tbaa !23
  %37 = and i32 %36, -32769
  store volatile i32 %37, ptr %35, align 4, !tbaa !23
  %38 = getelementptr inbounds i8, ptr %0, i64 20
  %39 = load i32, ptr %38, align 4, !tbaa !24
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = load i32, ptr %40, align 8, !tbaa !25
  %42 = or i32 %41, %39
  %43 = getelementptr inbounds i8, ptr %0, i64 28
  %44 = load i32, ptr %43, align 4, !tbaa !26
  %45 = shl i32 %44, 8
  %46 = or i32 %42, %45
  store volatile i32 %46, ptr %35, align 4, !tbaa !23
  %47 = getelementptr inbounds i8, ptr %0, i64 32
  %48 = load i32, ptr %47, align 8, !tbaa !27
  %49 = getelementptr inbounds i8, ptr %0, i64 36
  %50 = load i32, ptr %49, align 4, !tbaa !28
  %51 = or i32 %50, %48
  store volatile i32 %51, ptr %10, align 4, !tbaa !15
  %52 = load volatile i32, ptr %10, align 4, !tbaa !15
  %53 = or i32 %52, 1
  store volatile i32 %53, ptr %10, align 4, !tbaa !15
  %54 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 0, ptr %54, align 4, !tbaa !29
  store volatile i32 32, ptr %4, align 4, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %0, i64 56
  store volatile i32 0, ptr %55, align 8, !tbaa !30
  %56 = getelementptr inbounds i8, ptr %0, i64 96
  store volatile i32 0, ptr %56, align 8, !tbaa !31
  br label %57

57:                                               ; preds = %1, %31
  %.0 = phi i32 [ 0, %31 ], [ 1, %1 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_I2C_MspInit(ptr noundef) local_unnamed_addr #0

attributes #0 = { 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" }

!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 92}
!6 = !{!"__I2C_HandleTypeDef", !7, i64 0, !10, i64 8, !7, i64 40, !12, i64 48, !12, i64 50, !11, i64 52, !11, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104}
!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 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !11, i64 88}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !11, i64 0}
!16 = !{!"", !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}
!17 = !{!6, !11, i64 8}
!18 = !{!16, !11, i64 16}
!19 = !{!16, !11, i64 8}
!20 = !{!6, !11, i64 16}
!21 = !{!6, !11, i64 12}
!22 = !{!16, !11, i64 4}
!23 = !{!16, !11, i64 12}
!24 = !{!6, !11, i64 20}
!25 = !{!6, !11, i64 24}
!26 = !{!6, !11, i64 28}
!27 = !{!6, !11, i64 32}
!28 = !{!6, !11, i64 36}
!29 = !{!6, !11, i64 100}
!30 = !{!6, !11, i64 56}
!31 = !{!6, !11, i64 96}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass