; 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 }
%struct.RCC_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, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [9 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32] }

@HAL_RCC_FDCAN_CLK_ENABLED = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @HAL_FDCAN_MspDeInit(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %3, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp eq ptr %5, inttoptr (i64 1073782784 to ptr)
  br i1 %6, label %7, label %18

7:                                                ; preds = %1
  %8 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %9 = add i32 %8, -1
  store i32 %9, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %10 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %7
  %13 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 51), align 4, !tbaa !15
  %14 = zext i32 %13 to i64
  %15 = and i64 %14, -257
  %16 = trunc i64 %15 to i32
  store volatile i32 %16, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 51), align 4, !tbaa !15
  br label %17

17:                                               ; preds = %12, %7
  call void @HAL_GPIO_DeInit(ptr noundef inttoptr (i64 1476529152 to ptr), i32 noundef 3)
  call void @HAL_NVIC_DisableIRQ(i32 noundef 19)
  br label %52

18:                                               ; preds = %1
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = icmp eq ptr %21, inttoptr (i64 1073783808 to ptr)
  br i1 %22, label %23, label %34

23:                                               ; preds = %18
  %24 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %25 = add i32 %24, -1
  store i32 %25, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %26 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %23
  %29 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 51), align 4, !tbaa !15
  %30 = zext i32 %29 to i64
  %31 = and i64 %30, -257
  %32 = trunc i64 %31 to i32
  store volatile i32 %32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 51), align 4, !tbaa !15
  br label %33

33:                                               ; preds = %28, %23
  call void @HAL_GPIO_DeInit(ptr noundef inttoptr (i64 1476527104 to ptr), i32 noundef 96)
  call void @HAL_NVIC_DisableIRQ(i32 noundef 20)
  br label %51

34:                                               ; preds = %18
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.FDCAN_HandleTypeDef, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = icmp eq ptr %37, inttoptr (i64 1073796096 to ptr)
  br i1 %38, label %39, label %50

39:                                               ; preds = %34
  %40 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %41 = add i32 %40, -1
  store i32 %41, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %42 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !14
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %39
  %45 = load volatile i32, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 51), align 4, !tbaa !15
  %46 = zext i32 %45 to i64
  %47 = and i64 %46, -257
  %48 = trunc i64 %47 to i32
  store volatile i32 %48, ptr getelementptr inbounds (%struct.RCC_TypeDef, ptr inttoptr (i64 1476543488 to ptr), i32 0, i32 51), align 4, !tbaa !15
  br label %49

49:                                               ; preds = %44, %39
  call void @HAL_GPIO_DeInit(ptr noundef inttoptr (i64 1476529152 to ptr), i32 noundef 12288)
  br label %50

50:                                               ; preds = %49, %34
  br label %51

51:                                               ; preds = %50, %33
  br label %52

52:                                               ; preds = %51, %17
  ret void
}

declare void @HAL_GPIO_DeInit(ptr noundef, i32 noundef) #1

declare void @HAL_NVIC_DisableIRQ(i32 noundef) #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, !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, !6, i64 8, !11, i64 16, !13, i64 124, !12, i64 164, !12, i64 168, !12, i64 172, !12, i64 176}
!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, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !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}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !12, i64 236}
!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, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !12, i64 148, !12, i64 152, !12, i64 156, !12, i64 160, !12, i64 164, !12, i64 168, !7, i64 172, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !12, i64 224, !12, i64 228, !12, i64 232, !12, i64 236, !12, i64 240, !12, i64 244, !12, i64 248, !12, i64 252, !12, i64 256, !12, i64 260, !12, i64 264, !12, i64 268, !12, i64 272, !12, i64 276, !12, i64 280, !12, i64 284, !7, i64 288}


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

@HAL_RCC_FDCAN_CLK_ENABLED = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @HAL_FDCAN_MspDeInit(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %magicptr3 = ptrtoint ptr %2 to i64
  switch i64 %magicptr3, label %27 [
    i64 1073782784, label %3
    i64 1073783808, label %11
    i64 1073796096, label %19
  ]

3:                                                ; preds = %1
  %4 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !13
  %5 = add i32 %4, -1
  store i32 %5, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !13
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %10

7:                                                ; preds = %3
  %8 = load volatile i32, ptr inttoptr (i64 1476543724 to ptr), align 4, !tbaa !14
  %9 = and i32 %8, -257
  store volatile i32 %9, ptr inttoptr (i64 1476543724 to ptr), align 4, !tbaa !14
  br label %10

10:                                               ; preds = %7, %3
  tail call void @HAL_GPIO_DeInit(ptr noundef nonnull inttoptr (i64 1476529152 to ptr), i32 noundef 3) #2
  tail call void @HAL_NVIC_DisableIRQ(i32 noundef 19) #2
  br label %27

11:                                               ; preds = %1
  %12 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !13
  %13 = add i32 %12, -1
  store i32 %13, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !13
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %18

15:                                               ; preds = %11
  %16 = load volatile i32, ptr inttoptr (i64 1476543724 to ptr), align 4, !tbaa !14
  %17 = and i32 %16, -257
  store volatile i32 %17, ptr inttoptr (i64 1476543724 to ptr), align 4, !tbaa !14
  br label %18

18:                                               ; preds = %15, %11
  tail call void @HAL_GPIO_DeInit(ptr noundef nonnull inttoptr (i64 1476527104 to ptr), i32 noundef 96) #2
  tail call void @HAL_NVIC_DisableIRQ(i32 noundef 20) #2
  br label %27

19:                                               ; preds = %1
  %20 = load i32, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !13
  %21 = add i32 %20, -1
  store i32 %21, ptr @HAL_RCC_FDCAN_CLK_ENABLED, align 4, !tbaa !13
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  %24 = load volatile i32, ptr inttoptr (i64 1476543724 to ptr), align 4, !tbaa !14
  %25 = and i32 %24, -257
  store volatile i32 %25, ptr inttoptr (i64 1476543724 to ptr), align 4, !tbaa !14
  br label %26

26:                                               ; preds = %23, %19
  tail call void @HAL_GPIO_DeInit(ptr noundef nonnull inttoptr (i64 1476529152 to ptr), i32 noundef 12288) #2
  br label %27

27:                                               ; preds = %1, %18, %26, %10
  ret void
}

declare void @HAL_GPIO_DeInit(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @HAL_NVIC_DisableIRQ(i32 noundef) 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 = !{!15, !11, i64 236}
!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, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !11, i64 160, !11, i64 164, !11, i64 168, !8, i64 172, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !11, i64 232, !11, i64 236, !11, i64 240, !11, i64 244, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !8, i64 288}


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