; LLVM IR from lfarcaro/ARINC653_ARMV7A_AM335X :: Hardware (clock)

; 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.ADPLL = type { i8, ptr, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, i32, [4 x i32], i32, [4 x i32], i32, [4 x i32], ptr, i32, i32, i32, i32, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local void @configADPLL(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ADPLL, ptr %5, i32 0, i32 0
  %7 = load i8, ptr %6, align 8, !tbaa !11
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %51, label %9

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  call void @setLPBypassMode(ptr noundef %10, i32 noundef 1)
  br label %11

11:                                               ; preds = %25, %9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ADPLL, ptr %12, i32 0, i32 3
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load volatile i32, ptr %14, align 4, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ADPLL, ptr %16, i32 0, i32 4
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = and i32 %15, %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ADPLL, ptr %20, i32 0, i32 5
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = lshr i32 %19, %22
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %11
  br label %11, !llvm.loop !16

26:                                               ; preds = %11
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  call void @configADPLLAutoIdleCtrl(ptr noundef %27)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  call void @setBypassClockSource(ptr noundef %28)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !9
  call void @setClkMultDiv(ptr noundef %29, i32 noundef %30)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  call void @setRelockRampCtrl(ptr noundef %31)
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  call void @setLPBypassMode(ptr noundef %32, i32 noundef 0)
  br label %33

33:                                               ; preds = %47, %26
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ADPLL, ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load volatile i32, ptr %36, align 4, !tbaa !9
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ADPLL, ptr %38, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = and i32 %37, %40
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ADPLL, ptr %42, i32 0, i32 5
  %44 = load i32, ptr %43, align 4, !tbaa !15
  %45 = lshr i32 %41, %44
  %46 = icmp ne i32 %45, 1
  br i1 %46, label %47, label %48

47:                                               ; preds = %33
  br label %33, !llvm.loop !18

48:                                               ; preds = %33
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ADPLL, ptr %49, i32 0, i32 0
  store i8 1, ptr %50, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %48, %2
  ret void
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @setRelockRampCtrl(ptr noundef) #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"", !7, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !7, i64 68, !10, i64 84, !7, i64 88, !10, i64 104, !7, i64 108, !6, i64 128, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152}
!13 = !{!12, !6, i64 24}
!14 = !{!12, !10, i64 32}
!15 = !{!12, !10, i64 36}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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
declare dso_local void @setLPBypassMode(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @configADPLL(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i8, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i8 %3, 0
  br i1 %.not, label %4, label %24

4:                                                ; preds = %2
  tail call void @setLPBypassMode(ptr noundef nonnull %0, i32 noundef 1)
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load i32, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 36
  %10 = load i32, ptr %9, align 4, !tbaa !13
  br label %11

11:                                               ; preds = %11, %4
  %12 = load volatile i32, ptr %6, align 4, !tbaa !14
  %13 = and i32 %8, %12
  %14 = lshr i32 %13, %10
  %.not14 = icmp eq i32 %14, 0
  br i1 %.not14, label %15, label %11, !llvm.loop !15

15:                                               ; preds = %11
  tail call void @configADPLLAutoIdleCtrl(ptr noundef nonnull %0)
  tail call void @setBypassClockSource(ptr noundef nonnull %0)
  tail call void @setClkMultDiv(ptr noundef nonnull %0, i32 noundef %1)
  tail call void @setRelockRampCtrl(ptr noundef nonnull %0)
  tail call void @setLPBypassMode(ptr noundef nonnull %0, i32 noundef 0)
  %16 = load ptr, ptr %5, align 8, !tbaa !11
  %17 = load i32, ptr %7, align 8, !tbaa !12
  %18 = load i32, ptr %9, align 4, !tbaa !13
  br label %19

19:                                               ; preds = %19, %15
  %20 = load volatile i32, ptr %16, align 4, !tbaa !14
  %21 = and i32 %17, %20
  %22 = lshr i32 %21, %18
  %.not15 = icmp eq i32 %22, 1
  br i1 %.not15, label %23, label %19, !llvm.loop !17

23:                                               ; preds = %19
  store i8 1, ptr %0, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %23, %2
  ret void
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @setRelockRampCtrl(ptr 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 0}
!6 = !{!"", !7, i64 0, !9, i64 8, !10, i64 16, !9, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !9, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !7, i64 68, !10, i64 84, !7, i64 88, !10, i64 104, !7, i64 108, !9, i64 128, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!6, !9, i64 24}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !10, i64 36}
!14 = !{!10, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,LCSSAPass,LICMPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass