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

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

; Function Attrs: nounwind uwtable
define dso_local void @DMTimer1msModuleClkConfig(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %3 = load volatile i32, ptr inttoptr (i64 1155532072 to ptr), align 4, !tbaa !5
  %4 = and i32 %3, -8
  store volatile i32 %4, ptr inttoptr (i64 1155532072 to ptr), align 4, !tbaa !5
  br label %5

5:                                                ; preds = %9, %1
  %6 = load volatile i32, ptr inttoptr (i64 1155532072 to ptr), align 4, !tbaa !5
  %7 = and i32 %6, 7
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %5
  br label %5, !llvm.loop !9

10:                                               ; preds = %5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  store volatile i32 %11, ptr inttoptr (i64 1155532072 to ptr), align 4, !tbaa !5
  br label %12

12:                                               ; preds = %17, %10
  %13 = load volatile i32, ptr inttoptr (i64 1155532072 to ptr), align 4, !tbaa !5
  %14 = and i32 %13, 7
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp ne i32 %14, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  br label %12, !llvm.loop !11

18:                                               ; preds = %12
  %19 = load volatile i32, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  %20 = or i32 %19, 2
  store volatile i32 %20, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  br label %21

21:                                               ; preds = %25, %18
  %22 = load volatile i32, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  %23 = and i32 %22, 3
  %24 = icmp ne i32 %23, 2
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  br label %21, !llvm.loop !12

26:                                               ; preds = %21
  br label %27

27:                                               ; preds = %31, %26
  %28 = load volatile i32, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  %29 = and i32 %28, 196608
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  br label %27, !llvm.loop !13

32:                                               ; preds = %27
  ret void
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; 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 void @DMTimer1msModuleClkConfig(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load volatile i32, ptr inttoptr (i64 1155532072 to ptr), align 8, !tbaa !5
  %3 = and i32 %2, -8
  store volatile i32 %3, ptr inttoptr (i64 1155532072 to ptr), align 8, !tbaa !5
  br label %4

4:                                                ; preds = %4, %1
  %5 = load volatile i32, ptr inttoptr (i64 1155532072 to ptr), align 8, !tbaa !5
  %6 = and i32 %5, 7
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %4, !llvm.loop !9

7:                                                ; preds = %4
  store volatile i32 %0, ptr inttoptr (i64 1155532072 to ptr), align 8, !tbaa !5
  br label %8

8:                                                ; preds = %8, %7
  %9 = load volatile i32, ptr inttoptr (i64 1155532072 to ptr), align 8, !tbaa !5
  %10 = and i32 %9, 7
  %.not2 = icmp eq i32 %10, %0
  br i1 %.not2, label %11, label %8, !llvm.loop !11

11:                                               ; preds = %8
  %12 = load volatile i32, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  %13 = or i32 %12, 2
  store volatile i32 %13, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  br label %14

14:                                               ; preds = %14, %11
  %15 = load volatile i32, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  %16 = and i32 %15, 3
  %.not3 = icmp eq i32 %16, 2
  br i1 %.not3, label %.preheader, label %14, !llvm.loop !12

.preheader:                                       ; preds = %14, %.preheader
  %17 = load volatile i32, ptr inttoptr (i64 1155531972 to ptr), align 4, !tbaa !5
  %18 = and i32 %17, 196608
  %.not4 = icmp eq i32 %18, 0
  br i1 %.not4, label %19, label %.preheader, !llvm.loop !13

19:                                               ; preds = %.preheader
  ret void
}

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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: GlobalOptPass,InferAlignmentPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass