; LLVM IR from lfarcaro/ARINC653_ARMV7A_Z7000 :: ARINC653_ARMV7A_Z7000.sw/MEASURE/src/ARINC653_PORT (pmu)

; 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 @PMU_STARTUP() #0 {
  call void @PMU_WRITE_PMCR(i32 noundef 14)
  call void @PMU_WRITE_PMUSERENR(i32 noundef 1)
  call void @PMU_WRITE_PMINTENCLR(i32 noundef -1)
  call void @PMU_WRITE_PMCNTENCLR(i32 noundef -1)
  call void @PMU_WRITE_PMOVSR(i32 noundef -1)
  %1 = call i32 @PMU_READ_PMCR()
  %2 = lshr i32 %1, 11
  %3 = and i32 %2, 31
  %4 = icmp ult i32 %3, 1
  br i1 %4, label %5, label %7

5:                                                ; preds = %0
  br label %6

6:                                                ; preds = %6, %5
  br label %6

7:                                                ; preds = %0
  %8 = call i32 @PMU_READ_PMCR()
  %9 = or i32 %8, 1
  call void @PMU_WRITE_PMCR(i32 noundef %9)
  ret void
}

declare void @PMU_WRITE_PMCR(i32 noundef) #1

declare void @PMU_WRITE_PMUSERENR(i32 noundef) #1

declare void @PMU_WRITE_PMINTENCLR(i32 noundef) #1

declare void @PMU_WRITE_PMCNTENCLR(i32 noundef) #1

declare void @PMU_WRITE_PMOVSR(i32 noundef) #1

declare i32 @PMU_READ_PMCR() #1

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" }
attributes #1 = { "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)"}


; 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 void @PMU_STARTUP() local_unnamed_addr #0 {
  tail call void @PMU_WRITE_PMCR(i32 noundef 14) #2
  tail call void @PMU_WRITE_PMUSERENR(i32 noundef 1) #2
  tail call void @PMU_WRITE_PMINTENCLR(i32 noundef -1) #2
  tail call void @PMU_WRITE_PMCNTENCLR(i32 noundef -1) #2
  tail call void @PMU_WRITE_PMOVSR(i32 noundef -1) #2
  %1 = tail call i32 @PMU_READ_PMCR() #2
  %2 = and i32 %1, 63488
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %.preheader, label %4

.preheader:                                       ; preds = %0, %.preheader
  br label %.preheader

4:                                                ; preds = %0
  %5 = tail call i32 @PMU_READ_PMCR() #2
  %6 = or i32 %5, 1
  tail call void @PMU_WRITE_PMCR(i32 noundef %6) #2
  ret void
}

declare void @PMU_WRITE_PMCR(i32 noundef) local_unnamed_addr #1

declare void @PMU_WRITE_PMUSERENR(i32 noundef) local_unnamed_addr #1

declare void @PMU_WRITE_PMINTENCLR(i32 noundef) local_unnamed_addr #1

declare void @PMU_WRITE_PMCNTENCLR(i32 noundef) local_unnamed_addr #1

declare void @PMU_WRITE_PMOVSR(i32 noundef) local_unnamed_addr #1

declare i32 @PMU_READ_PMCR() local_unnamed_addr #1

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" }
attributes #1 = { "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)"}


; Effective O3 passes: GlobalOptPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SimplifyCFGPass,TailCallElimPass