; LLVM IR from reazon-research/OpenArm :: control/canfd_control/Drivers/STM32H7xx_HAL_Driver/Src (stm32h7xx_hal_flash_ex)

; 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.FLASH_OBProgramInitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @HAL_FLASHEx_OBGetConfig(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.FLASH_OBProgramInitTypeDef, ptr %3, i32 0, i32 0
  store i32 22, ptr %4, align 4, !tbaa !9
  %5 = call i32 @FLASH_OB_GetRDP()
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %6, i32 0, i32 3
  store i32 %5, ptr %7, align 4, !tbaa !12
  %8 = call i32 @FLASH_OB_GetUser()
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %9, i32 0, i32 6
  store i32 %8, ptr %10, align 4, !tbaa !13
  %11 = call i32 @FLASH_OB_GetBOR()
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %12, i32 0, i32 4
  store i32 %11, ptr %13, align 4, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %14, i32 0, i32 7
  %16 = load i32, ptr %15, align 4, !tbaa !15
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %48

18:                                               ; preds = %1
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = or i32 %21, 41
  store i32 %22, ptr %20, align 4, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %27, i32 0, i32 7
  %29 = load i32, ptr %28, align 4, !tbaa !15
  call void @FLASH_OB_GetWRP(ptr noundef %24, ptr noundef %26, i32 noundef %29)
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %30, i32 0, i32 8
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %32, i32 0, i32 9
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %34, i32 0, i32 10
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %36, i32 0, i32 7
  %38 = load i32, ptr %37, align 4, !tbaa !15
  call void @FLASH_OB_GetPCROP(ptr noundef %31, ptr noundef %33, ptr noundef %35, i32 noundef %38)
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %39, i32 0, i32 14
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %41, i32 0, i32 15
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %43, i32 0, i32 16
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %45, i32 0, i32 7
  %47 = load i32, ptr %46, align 4, !tbaa !15
  call void @FLASH_OB_GetSecureArea(ptr noundef %40, ptr noundef %42, ptr noundef %44, i32 noundef %47)
  br label %48

48:                                               ; preds = %18, %1
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %49, i32 0, i32 12
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %51, i32 0, i32 13
  call void @FLASH_OB_GetBootAdd(ptr noundef %50, ptr noundef %52)
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = or i32 %55, 64
  store i32 %56, ptr %54, align 4, !tbaa !9
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = or i32 %59, 256
  store i32 %60, ptr %58, align 4, !tbaa !9
  %61 = call i32 @FLASH_OB_SharedRAM_GetConfig()
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %62, i32 0, i32 17
  store i32 %61, ptr %63, align 4, !tbaa !16
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = or i32 %66, 512
  store i32 %67, ptr %65, align 4, !tbaa !9
  %68 = call i32 @FLASH_OB_CPUFreq_GetBoost()
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.FLASH_OBProgramInitTypeDef, ptr %69, i32 0, i32 18
  store i32 %68, ptr %70, align 4, !tbaa !17
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_GetRDP() #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_GetUser() #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_GetBOR() #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetWRP(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetPCROP(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetSecureArea(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetBootAdd(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_SharedRAM_GetConfig() #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_CPUFreq_GetBoost() #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, !11, i64 0}
!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 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 12}
!13 = !{!10, !11, i64 24}
!14 = !{!10, !11, i64 16}
!15 = !{!10, !11, i64 28}
!16 = !{!10, !11, i64 68}
!17 = !{!10, !11, i64 72}


; 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 void @HAL_FLASHEx_OBGetConfig(ptr noundef %0) local_unnamed_addr #0 {
  store i32 22, ptr %0, align 4, !tbaa !5
  %2 = tail call i32 @FLASH_OB_GetRDP()
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %2, ptr %3, align 4, !tbaa !10
  %4 = tail call i32 @FLASH_OB_GetUser()
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %4, ptr %5, align 4, !tbaa !11
  %6 = tail call i32 @FLASH_OB_GetBOR()
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %6, ptr %7, align 4, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %24

11:                                               ; preds = %1
  %12 = load i32, ptr %0, align 4, !tbaa !5
  %13 = or i32 %12, 41
  store i32 %13, ptr %0, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @FLASH_OB_GetWRP(ptr noundef nonnull %14, ptr noundef nonnull %15, i32 noundef 1)
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = getelementptr inbounds i8, ptr %0, i64 36
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load i32, ptr %8, align 4, !tbaa !13
  tail call void @FLASH_OB_GetPCROP(ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef nonnull %18, i32 noundef %19)
  %20 = getelementptr inbounds i8, ptr %0, i64 56
  %21 = getelementptr inbounds i8, ptr %0, i64 60
  %22 = getelementptr inbounds i8, ptr %0, i64 64
  %23 = load i32, ptr %8, align 4, !tbaa !13
  tail call void @FLASH_OB_GetSecureArea(ptr noundef nonnull %20, ptr noundef nonnull %21, ptr noundef nonnull %22, i32 noundef %23)
  br label %24

24:                                               ; preds = %11, %1
  %25 = getelementptr inbounds i8, ptr %0, i64 48
  %26 = getelementptr inbounds i8, ptr %0, i64 52
  tail call void @FLASH_OB_GetBootAdd(ptr noundef nonnull %25, ptr noundef nonnull %26)
  %27 = load i32, ptr %0, align 4, !tbaa !5
  %28 = or i32 %27, 320
  store i32 %28, ptr %0, align 4, !tbaa !5
  %29 = tail call i32 @FLASH_OB_SharedRAM_GetConfig()
  %30 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 %29, ptr %30, align 4, !tbaa !14
  %31 = load i32, ptr %0, align 4, !tbaa !5
  %32 = or i32 %31, 512
  store i32 %32, ptr %0, align 4, !tbaa !5
  %33 = tail call i32 @FLASH_OB_CPUFreq_GetBoost()
  %34 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 %33, ptr %34, align 4, !tbaa !15
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_GetRDP() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_GetUser() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_GetBOR() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetWRP(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetPCROP(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @FLASH_OB_GetSecureArea(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_SharedRAM_GetConfig() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @FLASH_OB_CPUFreq_GetBoost() 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 12}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 28}
!14 = !{!6, !7, i64 68}
!15 = !{!6, !7, i64 72}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass