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

; 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.OSPI_HandleTypeDef = type { ptr, %struct.OSPI_InitTypeDef, ptr, i32, i32, ptr, i32, i32, i32 }
%struct.OSPI_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.OCTOSPI_TypeDef = type { i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, [6 x i32], i32, i32, i32, i32, i32, [11 x i32], i32, i32, i32, i32, i32, [27 x i32], i32, i32, i32, i32, i32, [3 x i32], i32, [3 x i32], i32, [3 x i32], i32, i32, i32, i32, i32, [3 x i32], i32, [7 x i32], i32, i32, i32, i32, i32, [3 x i32], i32, [23 x i32], i32, [122 x 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_OSPI_Receive_IT(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %10, i32 0, i32 12
  %12 = load volatile i32, ptr %11, align 4, !tbaa !14
  store i32 %12, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %15, i32 0, i32 26
  %17 = load volatile i32, ptr %16, align 4, !tbaa !16
  store i32 %17, ptr %7, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %2
  store i32 1, ptr %5, align 4, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %21, i32 0, i32 7
  store volatile i32 8, ptr %22, align 4, !tbaa !17
  br label %110

23:                                               ; preds = %2
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %24, i32 0, i32 6
  %26 = load volatile i32, ptr %25, align 8, !tbaa !18
  %27 = icmp eq i32 %26, 4
  br i1 %27, label %28, label %106

28:                                               ; preds = %23
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %31, i32 0, i32 10
  %33 = load volatile i32, ptr %32, align 4, !tbaa !19
  %34 = add i32 %33, 1
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %35, i32 0, i32 4
  store volatile i32 %34, ptr %36, align 4, !tbaa !20
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %37, i32 0, i32 4
  %39 = load volatile i32, ptr %38, align 4, !tbaa !20
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %40, i32 0, i32 3
  store volatile i32 %39, ptr %41, align 8, !tbaa !21
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %43, i32 0, i32 2
  store ptr %42, ptr %44, align 8, !tbaa !22
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %47, i32 0, i32 0
  %49 = load volatile i32, ptr %48, align 4, !tbaa !23
  %50 = zext i32 %49 to i64
  %51 = and i64 %50, -805306369
  %52 = or i64 %51, 268435456
  %53 = trunc i64 %52 to i32
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %56, i32 0, i32 0
  store volatile i32 %53, ptr %57, align 4, !tbaa !23
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %60, i32 0, i32 8
  store volatile i32 3, ptr %61, align 4, !tbaa !24
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %62, i32 0, i32 6
  store volatile i32 40, ptr %63, align 8, !tbaa !18
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  %67 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %66, i32 0, i32 0
  %68 = load volatile i32, ptr %67, align 4, !tbaa !23
  %69 = zext i32 %68 to i64
  %70 = or i64 %69, 458752
  %71 = trunc i64 %70 to i32
  store volatile i32 %71, ptr %67, align 4, !tbaa !23
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %72, i32 0, i32 1
  %74 = getelementptr inbounds %struct.OSPI_InitTypeDef, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !25
  %76 = icmp eq i32 %75, 67108864
  br i1 %76, label %77, label %83

77:                                               ; preds = %28
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !11
  %82 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %81, i32 0, i32 12
  store volatile i32 %78, ptr %82, align 4, !tbaa !14
  br label %105

83:                                               ; preds = %28
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !11
  %87 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %86, i32 0, i32 22
  %88 = load volatile i32, ptr %87, align 4, !tbaa !26
  %89 = zext i32 %88 to i64
  %90 = and i64 %89, 1792
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %92, label %98

92:                                               ; preds = %83
  %93 = load i32, ptr %6, align 4, !tbaa !9
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  %97 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %96, i32 0, i32 12
  store volatile i32 %93, ptr %97, align 4, !tbaa !14
  br label %104

98:                                               ; preds = %83
  %99 = load i32, ptr %7, align 4, !tbaa !9
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %100, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8, !tbaa !11
  %103 = getelementptr inbounds %struct.OCTOSPI_TypeDef, ptr %102, i32 0, i32 26
  store volatile i32 %99, ptr %103, align 4, !tbaa !16
  br label %104

104:                                              ; preds = %98, %92
  br label %105

105:                                              ; preds = %104, %77
  br label %109

106:                                              ; preds = %23
  store i32 1, ptr %5, align 4, !tbaa !9
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.OSPI_HandleTypeDef, ptr %107, i32 0, i32 7
  store volatile i32 16, ptr %108, align 4, !tbaa !17
  br label %109

109:                                              ; preds = %106, %105
  br label %110

110:                                              ; preds = %109, %20
  %111 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %111
}

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, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 72, !10, i64 80, !10, i64 84, !6, i64 88, !10, i64 96, !10, i64 100, !10, i64 104}
!13 = !{!"", !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}
!14 = !{!15, !10, i64 72}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 84, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !7, i64 148, !10, i64 256, !10, i64 260, !10, i64 264, !10, i64 268, !10, i64 272, !7, i64 276, !10, i64 288, !7, i64 292, !10, i64 304, !7, i64 308, !10, i64 320, !10, i64 324, !10, i64 328, !10, i64 332, !10, i64 336, !7, i64 340, !10, i64 352, !7, i64 356, !10, i64 384, !10, i64 388, !10, i64 392, !10, i64 396, !10, i64 400, !7, i64 404, !10, i64 416, !7, i64 420, !10, i64 512, !7, i64 516, !10, i64 1004, !10, i64 1008, !10, i64 1012, !10, i64 1016}
!16 = !{!15, !10, i64 272}
!17 = !{!12, !10, i64 100}
!18 = !{!12, !10, i64 96}
!19 = !{!15, !10, i64 64}
!20 = !{!12, !10, i64 84}
!21 = !{!12, !10, i64 80}
!22 = !{!12, !6, i64 72}
!23 = !{!15, !10, i64 0}
!24 = !{!15, !10, i64 36}
!25 = !{!12, !10, i64 16}
!26 = !{!15, !10, i64 256}


; 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, 2) i32 @HAL_OSPI_Receive_IT(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 72
  %5 = load volatile i32, ptr %4, align 4, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %3, i64 272
  %7 = load volatile i32, ptr %6, align 4, !tbaa !14
  %8 = icmp eq ptr %1, null
  br i1 %8, label %9, label %11

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 8, ptr %10, align 4, !tbaa !15
  br label %41

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = load volatile i32, ptr %12, align 8, !tbaa !16
  %14 = icmp eq i32 %13, 4
  br i1 %14, label %15, label %39

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %3, i64 64
  %17 = load volatile i32, ptr %16, align 4, !tbaa !17
  %18 = add i32 %17, 1
  %19 = getelementptr inbounds i8, ptr %0, i64 84
  store volatile i32 %18, ptr %19, align 4, !tbaa !18
  %20 = load volatile i32, ptr %19, align 4, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %0, i64 80
  store volatile i32 %20, ptr %21, align 8, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %1, ptr %22, align 8, !tbaa !20
  %23 = load volatile i32, ptr %3, align 4, !tbaa !21
  %24 = and i32 %23, -805306369
  %25 = or disjoint i32 %24, 268435456
  store volatile i32 %25, ptr %3, align 4, !tbaa !21
  %26 = getelementptr inbounds i8, ptr %3, i64 36
  store volatile i32 3, ptr %26, align 4, !tbaa !22
  store volatile i32 40, ptr %12, align 8, !tbaa !16
  %27 = load volatile i32, ptr %3, align 4, !tbaa !21
  %28 = or i32 %27, 458752
  store volatile i32 %28, ptr %3, align 4, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  %30 = load i32, ptr %29, align 8, !tbaa !23
  %31 = icmp eq i32 %30, 67108864
  br i1 %31, label %32, label %33

32:                                               ; preds = %15
  store volatile i32 %5, ptr %4, align 4, !tbaa !12
  br label %41

33:                                               ; preds = %15
  %34 = getelementptr inbounds i8, ptr %3, i64 256
  %35 = load volatile i32, ptr %34, align 4, !tbaa !24
  %36 = and i32 %35, 1792
  %.not = icmp eq i32 %36, 0
  br i1 %.not, label %38, label %37

37:                                               ; preds = %33
  store volatile i32 %5, ptr %4, align 4, !tbaa !12
  br label %41

38:                                               ; preds = %33
  store volatile i32 %7, ptr %6, align 4, !tbaa !14
  br label %41

39:                                               ; preds = %11
  %40 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 16, ptr %40, align 4, !tbaa !15
  br label %41

41:                                               ; preds = %39, %37, %38, %32, %9
  %.0 = phi i32 [ 1, %9 ], [ 0, %32 ], [ 0, %37 ], [ 0, %38 ], [ 1, %39 ]
  ret i32 %.0
}

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

!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, !10, i64 8, !7, i64 72, !11, i64 80, !11, i64 84, !7, i64 88, !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, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 72}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !8, i64 24, !11, i64 32, !11, i64 36, !8, i64 40, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !8, i64 84, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !8, i64 148, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !8, i64 276, !11, i64 288, !8, i64 292, !11, i64 304, !8, i64 308, !11, i64 320, !11, i64 324, !11, i64 328, !11, i64 332, !11, i64 336, !8, i64 340, !11, i64 352, !8, i64 356, !11, i64 384, !11, i64 388, !11, i64 392, !11, i64 396, !11, i64 400, !8, i64 404, !11, i64 416, !8, i64 420, !11, i64 512, !8, i64 516, !11, i64 1004, !11, i64 1008, !11, i64 1012, !11, i64 1016}
!14 = !{!13, !11, i64 272}
!15 = !{!6, !11, i64 100}
!16 = !{!6, !11, i64 96}
!17 = !{!13, !11, i64 64}
!18 = !{!6, !11, i64 84}
!19 = !{!6, !11, i64 80}
!20 = !{!6, !7, i64 72}
!21 = !{!13, !11, i64 0}
!22 = !{!13, !11, i64 36}
!23 = !{!6, !11, i64 16}
!24 = !{!13, !11, i64 256}


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