; LLVM IR from lfarcaro/ARINC653_ARMV7A_AM335X :: Hardware (gpio_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 @GPIO0ModuleClkConfig() #0 {
  %1 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 4, !tbaa !5
  %2 = or i32 %1, 2
  store volatile i32 %2, ptr inttoptr (i64 1155531784 to ptr), align 4, !tbaa !5
  br label %3

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

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

8:                                                ; preds = %3
  %9 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 4, !tbaa !5
  %10 = or i32 %9, 262144
  store volatile i32 %10, ptr inttoptr (i64 1155531784 to ptr), align 4, !tbaa !5
  br label %11

11:                                               ; preds = %15, %8
  %12 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 4, !tbaa !5
  %13 = and i32 %12, 262144
  %14 = icmp ne i32 262144, %13
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %11
  br label %17

17:                                               ; preds = %21, %16
  %18 = load volatile i32, ptr inttoptr (i64 1155531780 to ptr), align 4, !tbaa !5
  %19 = and i32 %18, 196608
  %20 = icmp ne i32 0, %19
  br i1 %20, label %21, label %22

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

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %27, %22
  %24 = load volatile i32, ptr inttoptr (i64 1155531800 to ptr), align 4, !tbaa !5
  %25 = and i32 %24, 8
  %26 = icmp ne i32 8, %25
  br i1 %26, label %27, label %28

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

28:                                               ; preds = %23
  br label %29

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

33:                                               ; preds = %29
  br label %29, !llvm.loop !14

34:                                               ; preds = %29
  br label %35

35:                                               ; preds = %39, %34
  %36 = load volatile i32, ptr inttoptr (i64 1155531776 to ptr), align 4, !tbaa !5
  %37 = and i32 %36, 4
  %38 = icmp ne i32 4, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  br label %35, !llvm.loop !15

40:                                               ; preds = %35
  br label %41

41:                                               ; preds = %45, %40
  %42 = load volatile i32, ptr inttoptr (i64 1155531980 to ptr), align 4, !tbaa !5
  %43 = and i32 %42, 4
  %44 = icmp ne i32 4, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  br label %41, !llvm.loop !16

46:                                               ; preds = %41
  br label %47

47:                                               ; preds = %51, %46
  %48 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 4, !tbaa !5
  %49 = and i32 %48, 196608
  %50 = icmp ne i32 0, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  br label %47, !llvm.loop !17

52:                                               ; preds = %47
  br label %53

53:                                               ; preds = %57, %52
  %54 = load volatile i32, ptr inttoptr (i64 1155531776 to ptr), align 4, !tbaa !5
  %55 = and i32 %54, 256
  %56 = icmp ne i32 256, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  br label %53, !llvm.loop !18

58:                                               ; preds = %53
  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}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !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 @GPIO0ModuleClkConfig() local_unnamed_addr #0 {
  %1 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 8, !tbaa !5
  %2 = or i32 %1, 2
  store volatile i32 %2, ptr inttoptr (i64 1155531784 to ptr), align 8, !tbaa !5
  br label %3

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

6:                                                ; preds = %3
  %7 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 8, !tbaa !5
  %8 = or i32 %7, 262144
  store volatile i32 %8, ptr inttoptr (i64 1155531784 to ptr), align 8, !tbaa !5
  br label %9

9:                                                ; preds = %9, %6
  %10 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 8, !tbaa !5
  %11 = and i32 %10, 262144
  %.not1.not = icmp eq i32 %11, 0
  br i1 %.not1.not, label %9, label %.preheader14, !llvm.loop !11

.preheader14:                                     ; preds = %9, %.preheader14
  %12 = load volatile i32, ptr inttoptr (i64 1155531780 to ptr), align 4, !tbaa !5
  %13 = and i32 %12, 196608
  %.not2 = icmp eq i32 %13, 0
  br i1 %.not2, label %.preheader13, label %.preheader14, !llvm.loop !12

.preheader13:                                     ; preds = %.preheader14, %.preheader13
  %14 = load volatile i32, ptr inttoptr (i64 1155531800 to ptr), align 8, !tbaa !5
  %15 = and i32 %14, 8
  %.not3.not = icmp eq i32 %15, 0
  br i1 %.not3.not, label %.preheader13, label %.preheader12, !llvm.loop !13

.preheader12:                                     ; preds = %.preheader13, %.preheader12
  %16 = load volatile i32, ptr inttoptr (i64 1155531788 to ptr), align 4, !tbaa !5
  %17 = and i32 %16, 196608
  %.not4 = icmp eq i32 %17, 0
  br i1 %.not4, label %.preheader11, label %.preheader12, !llvm.loop !14

.preheader11:                                     ; preds = %.preheader12, %.preheader11
  %18 = load volatile i32, ptr inttoptr (i64 1155531776 to ptr), align 1024, !tbaa !5
  %19 = and i32 %18, 4
  %.not5.not = icmp eq i32 %19, 0
  br i1 %.not5.not, label %.preheader11, label %.preheader10, !llvm.loop !15

.preheader10:                                     ; preds = %.preheader11, %.preheader10
  %20 = load volatile i32, ptr inttoptr (i64 1155531980 to ptr), align 4, !tbaa !5
  %21 = and i32 %20, 4
  %.not6.not = icmp eq i32 %21, 0
  br i1 %.not6.not, label %.preheader10, label %.preheader9, !llvm.loop !16

.preheader9:                                      ; preds = %.preheader10, %.preheader9
  %22 = load volatile i32, ptr inttoptr (i64 1155531784 to ptr), align 8, !tbaa !5
  %23 = and i32 %22, 196608
  %.not7 = icmp eq i32 %23, 0
  br i1 %.not7, label %.preheader, label %.preheader9, !llvm.loop !17

.preheader:                                       ; preds = %.preheader9, %.preheader
  %24 = load volatile i32, ptr inttoptr (i64 1155531776 to ptr), align 1024, !tbaa !5
  %25 = and i32 %24, 256
  %.not8.not = icmp eq i32 %25, 0
  br i1 %.not8.not, label %.preheader, label %26, !llvm.loop !18

26:                                               ; 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}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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