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

; 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_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, [40 x i32], i32, i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, i32, i32, [4 x i32], 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_FLASH_OB_Launch() #1 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  %2 = call i32 @FLASH_CRC_WaitForLastOperation(i32 noundef 50000, i32 noundef 1)
  %3 = icmp ne i32 %2, 0
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %11

5:                                                ; preds = %0
  %6 = call i32 @FLASH_CRC_WaitForLastOperation(i32 noundef 50000, i32 noundef 2)
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %5
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %10

9:                                                ; preds = %5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %9, %8
  br label %11

11:                                               ; preds = %10, %4
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %11
  %15 = load volatile i32, ptr getelementptr inbounds (%struct.FLASH_TypeDef, ptr inttoptr (i64 1375739904 to ptr), i32 0, i32 6), align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = or i64 %16, 2
  %18 = trunc i64 %17 to i32
  store volatile i32 %18, ptr getelementptr inbounds (%struct.FLASH_TypeDef, ptr inttoptr (i64 1375739904 to ptr), i32 0, i32 6), align 4, !tbaa !9
  %19 = call i32 @FLASH_OB_WaitForLastOperation(i32 noundef 50000)
  store i32 %19, ptr %1, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %14, %11
  %21 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret i32 %21
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @FLASH_CRC_WaitForLastOperation(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @FLASH_OB_WaitForLastOperation(i32 noundef) #1

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !7, i64 72, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !7, i64 100, !6, i64 260, !6, i64 264, !6, i64 268, !6, i64 272, !6, i64 276, !7, i64 280, !6, i64 296, !6, i64 300, !6, i64 304, !6, i64 308, !6, i64 312, !6, i64 316, !7, i64 320, !6, i64 336, !6, i64 340, !6, i64 344, !6, i64 348, !6, i64 352}


; 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 i32 @HAL_FLASH_OB_Launch() local_unnamed_addr #0 {
  %1 = tail call i32 @FLASH_CRC_WaitForLastOperation(i32 noundef 50000, i32 noundef 1)
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %2, label %.critedge

2:                                                ; preds = %0
  %3 = tail call i32 @FLASH_CRC_WaitForLastOperation(i32 noundef 50000, i32 noundef 2)
  %.not2 = icmp eq i32 %3, 0
  br i1 %.not2, label %4, label %.critedge

4:                                                ; preds = %2
  %5 = load volatile i32, ptr inttoptr (i64 1375739928 to ptr), align 8, !tbaa !5
  %6 = or i32 %5, 2
  store volatile i32 %6, ptr inttoptr (i64 1375739928 to ptr), align 8, !tbaa !5
  %7 = tail call i32 @FLASH_OB_WaitForLastOperation(i32 noundef 50000)
  br label %.critedge

.critedge:                                        ; preds = %0, %4, %2
  %.1 = phi i32 [ %7, %4 ], [ 1, %2 ], [ 1, %0 ]
  ret i32 %.1
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @FLASH_CRC_WaitForLastOperation(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @FLASH_OB_WaitForLastOperation(i32 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, !7, i64 24}
!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, !8, i64 72, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !8, i64 100, !7, i64 260, !7, i64 264, !7, i64 268, !7, i64 272, !7, i64 276, !8, i64 280, !7, i64 296, !7, i64 300, !7, i64 304, !7, i64 308, !7, i64 312, !7, i64 316, !8, i64 320, !7, i64 336, !7, i64 340, !7, i64 344, !7, i64 348, !7, i64 352}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


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