; 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
define dso_local void @setLPBypassMode(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 i32, ptr %4, align 4, !tbaa !9
  %6 = icmp eq i32 0, %5
  br i1 %6, label %7, label %40

7:                                                ; preds = %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.ADPLL, ptr %8, i32 0, i32 17
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = load volatile i32, ptr %10, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ADPLL, ptr %12, i32 0, i32 18
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = xor i32 %14, -1
  %16 = and i32 %11, %15
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ADPLL, ptr %17, i32 0, i32 19
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = or i32 %16, %19
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ADPLL, ptr %21, i32 0, i32 17
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  store volatile i32 %20, ptr %23, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %38, %7
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ADPLL, ptr %25, i32 0, i32 3
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = load volatile i32, ptr %27, align 4, !tbaa !9
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ADPLL, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 8, !tbaa !16
  %32 = and i32 %28, %31
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ADPLL, ptr %33, i32 0, i32 5
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = lshr i32 %32, %35
  %37 = icmp ne i32 %36, 1
  br i1 %37, label %38, label %39

38:                                               ; preds = %24
  br label %24, !llvm.loop !18

39:                                               ; preds = %24
  br label %40

40:                                               ; preds = %39, %2
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = icmp eq i32 1, %41
  br i1 %42, label %43, label %76

43:                                               ; preds = %40
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ADPLL, ptr %44, i32 0, i32 17
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  %47 = load volatile i32, ptr %46, align 4, !tbaa !9
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ADPLL, ptr %48, i32 0, i32 18
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = xor i32 %50, -1
  %52 = and i32 %47, %51
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ADPLL, ptr %53, i32 0, i32 20
  %55 = load i32, ptr %54, align 8, !tbaa !20
  %56 = or i32 %52, %55
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ADPLL, ptr %57, i32 0, i32 17
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  store volatile i32 %56, ptr %59, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %74, %43
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ADPLL, ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = load volatile i32, ptr %63, align 4, !tbaa !9
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ADPLL, ptr %65, i32 0, i32 4
  %67 = load i32, ptr %66, align 8, !tbaa !16
  %68 = and i32 %64, %67
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ADPLL, ptr %69, i32 0, i32 5
  %71 = load i32, ptr %70, align 4, !tbaa !17
  %72 = lshr i32 %68, %71
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %60
  br label %60, !llvm.loop !21

75:                                               ; preds = %60
  br label %76

76:                                               ; preds = %75, %40
  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 = !{!"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 128}
!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, !10, i64 136}
!14 = !{!12, !10, i64 140}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !10, i64 36}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !10, i64 144}
!21 = distinct !{!21, !19}


; 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 @setLPBypassMode(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  switch i32 %1, label %.loopexit [
    i32 0, label %3
    i32 1, label %24
  ]

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 128
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load volatile i32, ptr %5, align 4, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 136
  %8 = load i32, ptr %7, align 8, !tbaa !12
  %9 = xor i32 %8, -1
  %10 = and i32 %6, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 140
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = or i32 %10, %12
  store volatile i32 %13, ptr %5, align 4, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load i32, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %0, i64 36
  %19 = load i32, ptr %18, align 4, !tbaa !16
  br label %20

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

24:                                               ; preds = %2
  %25 = getelementptr inbounds i8, ptr %0, i64 128
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load volatile i32, ptr %26, align 4, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %0, i64 136
  %29 = load i32, ptr %28, align 8, !tbaa !12
  %30 = xor i32 %29, -1
  %31 = and i32 %27, %30
  %32 = getelementptr inbounds i8, ptr %0, i64 144
  %33 = load i32, ptr %32, align 8, !tbaa !19
  %34 = or i32 %31, %33
  store volatile i32 %34, ptr %26, align 4, !tbaa !11
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = getelementptr inbounds i8, ptr %0, i64 32
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %0, i64 36
  %40 = load i32, ptr %39, align 4, !tbaa !16
  br label %41

41:                                               ; preds = %41, %24
  %42 = load volatile i32, ptr %36, align 4, !tbaa !11
  %43 = and i32 %38, %42
  %44 = lshr i32 %43, %40
  %.not15 = icmp eq i32 %44, 0
  br i1 %.not15, label %.loopexit, label %41, !llvm.loop !20

.loopexit:                                        ; preds = %41, %20, %2
  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, !9, i64 128}
!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 = !{!10, !10, i64 0}
!12 = !{!6, !10, i64 136}
!13 = !{!6, !10, i64 140}
!14 = !{!6, !9, i64 24}
!15 = !{!6, !10, i64 32}
!16 = !{!6, !10, i64 36}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !10, i64 144}
!20 = distinct !{!20, !18}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass