; LLVM IR from reazon-research/OpenArm :: control/canfd_control/Core/Src (fdcan)

; 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.FDCAN_HandleTypeDef = type { ptr, ptr, %struct.FDCAN_InitTypeDef, %struct.FDCAN_MsgRamAddressTypeDef, i32, i32, i32, i32 }
%struct.FDCAN_InitTypeDef = 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 }
%struct.FDCAN_MsgRamAddressTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@hfdcan1 = external dso_local global %struct.FDCAN_HandleTypeDef, align 8

; Function Attrs: nounwind uwtable
define dso_local void @MX_FDCAN1_Init() #0 {
  store ptr inttoptr (i64 1073782784 to ptr), ptr @hfdcan1, align 8, !tbaa !5
  store i32 768, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), align 8, !tbaa !13
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 1), align 4, !tbaa !14
  store i32 1, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 2), align 8, !tbaa !15
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 3), align 4, !tbaa !16
  store i32 1, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 4), align 8, !tbaa !17
  store i32 4, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 5), align 4, !tbaa !18
  store i32 19, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 7), align 4, !tbaa !19
  store i32 5, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 8), align 8, !tbaa !20
  store i32 1, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 6), align 8, !tbaa !21
  store i32 1, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 9), align 4, !tbaa !22
  store i32 16, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 11), align 4, !tbaa !23
  store i32 3, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 12), align 8, !tbaa !24
  store i32 2, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 10), align 8, !tbaa !25
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 13), align 4, !tbaa !26
  store i32 5, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 14), align 8, !tbaa !27
  store i32 5, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 15), align 4, !tbaa !28
  store i32 16, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 16), align 8, !tbaa !29
  store i32 4, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 17), align 4, !tbaa !30
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 18), align 8, !tbaa !31
  store i32 8, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 19), align 4, !tbaa !32
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 20), align 8, !tbaa !33
  store i32 4, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 21), align 4, !tbaa !34
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 22), align 8, !tbaa !35
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 23), align 4, !tbaa !36
  store i32 16, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 24), align 8, !tbaa !37
  store i32 0, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 25), align 4, !tbaa !38
  store i32 8, ptr getelementptr inbounds (%struct.FDCAN_InitTypeDef, ptr getelementptr inbounds (%struct.FDCAN_HandleTypeDef, ptr @hfdcan1, i32 0, i32 2), i32 0, i32 26), align 8, !tbaa !39
  %1 = call i32 @HAL_FDCAN_Init(ptr noundef @hfdcan1)
  %2 = icmp ne i32 %1, 0
  br i1 %2, label %3, label %4

3:                                                ; preds = %0
  call void @Error_Handler()
  br label %4

4:                                                ; preds = %3, %0
  ret void
}

declare i32 @HAL_FDCAN_Init(ptr noundef) #1

declare void @Error_Handler() #1

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" }
attributes #1 = { "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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 124, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176}
!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, !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}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !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}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !11, i64 20}
!15 = !{!6, !11, i64 24}
!16 = !{!6, !11, i64 28}
!17 = !{!6, !11, i64 32}
!18 = !{!6, !11, i64 36}
!19 = !{!6, !11, i64 44}
!20 = !{!6, !11, i64 48}
!21 = !{!6, !11, i64 40}
!22 = !{!6, !11, i64 52}
!23 = !{!6, !11, i64 60}
!24 = !{!6, !11, i64 64}
!25 = !{!6, !11, i64 56}
!26 = !{!6, !11, i64 68}
!27 = !{!6, !11, i64 72}
!28 = !{!6, !11, i64 76}
!29 = !{!6, !11, i64 80}
!30 = !{!6, !11, i64 84}
!31 = !{!6, !11, i64 88}
!32 = !{!6, !11, i64 92}
!33 = !{!6, !11, i64 96}
!34 = !{!6, !11, i64 100}
!35 = !{!6, !11, i64 104}
!36 = !{!6, !11, i64 108}
!37 = !{!6, !11, i64 112}
!38 = !{!6, !11, i64 116}
!39 = !{!6, !11, i64 120}


; 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.FDCAN_HandleTypeDef = type { ptr, ptr, %struct.FDCAN_InitTypeDef, %struct.FDCAN_MsgRamAddressTypeDef, i32, i32, i32, i32 }
%struct.FDCAN_InitTypeDef = 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 }
%struct.FDCAN_MsgRamAddressTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@hfdcan1 = external dso_local global %struct.FDCAN_HandleTypeDef, align 8

; Function Attrs: nounwind uwtable
define dso_local void @MX_FDCAN1_Init() local_unnamed_addr #0 {
  store ptr inttoptr (i64 1073782784 to ptr), ptr @hfdcan1, align 8, !tbaa !5
  store <4 x i32> <i32 768, i32 0, i32 1, i32 0>, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 16), align 8, !tbaa !13
  store <4 x i32> <i32 1, i32 4, i32 1, i32 19>, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 32), align 8, !tbaa !13
  store <4 x i32> <i32 5, i32 1, i32 2, i32 16>, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 48), align 8, !tbaa !13
  store <4 x i32> <i32 3, i32 0, i32 5, i32 5>, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 64), align 8, !tbaa !13
  store <4 x i32> <i32 16, i32 4, i32 0, i32 8>, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 80), align 8, !tbaa !13
  store <4 x i32> <i32 0, i32 4, i32 0, i32 0>, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 96), align 8, !tbaa !13
  store i32 16, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 112), align 8, !tbaa !14
  store i32 0, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 116), align 4, !tbaa !15
  store i32 8, ptr getelementptr inbounds (i8, ptr @hfdcan1, i64 120), align 8, !tbaa !16
  %1 = tail call i32 @HAL_FDCAN_Init(ptr noundef nonnull @hfdcan1) #2
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %3, label %2

2:                                                ; preds = %0
  tail call void @Error_Handler() #2
  br label %3

3:                                                ; preds = %2, %0
  ret void
}

declare i32 @HAL_FDCAN_Init(ptr noundef) local_unnamed_addr #1

declare void @Error_Handler() local_unnamed_addr #1

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" }
attributes #1 = { "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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 124, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176}
!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, !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}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !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}
!13 = !{!11, !11, i64 0}
!14 = !{!6, !11, i64 112}
!15 = !{!6, !11, i64 116}
!16 = !{!6, !11, i64 120}


; Effective O3 passes: GlobalOptPass,InstCombinePass,SLPVectorizerPass,TailCallElimPass