; LLVM IR from stonne-simulator/omega :: omega-code/stonne/src/STONNEModel.ll (ZN6Stonne10testMemoryEj)

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

%class.Stonne = type <{ %class.Config, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, [6 x i8], i64, i64, i64, i64, i64, i32, [4 x i8] }>
%class.Config = type { i32, %class.DSNetworkConfig, %class.DSwitchConfig, %class.MSNetworkConfig, %class.MSwitchConfig, %class.ASNetworkConfig, %class.ASwitchConfig, %class.LookUpTableConfig, %class.SDMemoryConfig }
%class.DSNetworkConfig = type { i32 }
%class.DSwitchConfig = type { i32, i32, i32, i32 }
%class.MSNetworkConfig = type { i32, i32, i32, i32 }
%class.MSwitchConfig = type { i32, i32, i32, i32, i32, i32 }
%class.ASNetworkConfig = type { i32, i32 }
%class.ASwitchConfig = type { i32, i32, i32, i32, i32, i32 }
%class.LookUpTableConfig = type { i32, i32 }
%class.SDMemoryConfig = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Stonne10testMemoryEj(ptr noundef nonnull align 8 dereferenceable(316) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %27, %2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 20
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %30

11:                                               ; preds = %7
  %12 = getelementptr inbounds %class.Stonne, ptr %6, i32 0, i32 7
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = load ptr, ptr %13, align 8, !tbaa !28
  %15 = getelementptr inbounds ptr, ptr %14, i64 2
  %16 = load ptr, ptr %15, align 8
  call void %16(ptr noundef nonnull align 8 dereferenceable(48) %13)
  %17 = getelementptr inbounds %class.Stonne, ptr %6, i32 0, i32 3
  %18 = load ptr, ptr %17, align 8, !tbaa !30
  %19 = load ptr, ptr %18, align 8, !tbaa !28
  %20 = getelementptr inbounds ptr, ptr %19, i64 2
  %21 = load ptr, ptr %20, align 8
  call void %21(ptr noundef nonnull align 8 dereferenceable(48) %18)
  %22 = getelementptr inbounds %class.Stonne, ptr %6, i32 0, i32 4
  %23 = load ptr, ptr %22, align 8, !tbaa !31
  %24 = load ptr, ptr %23, align 8, !tbaa !28
  %25 = getelementptr inbounds ptr, ptr %24, i64 2
  %26 = load ptr, ptr %25, align 8
  call void %26(ptr noundef nonnull align 8 dereferenceable(48) %23)
  br label %27

27:                                               ; preds = %11
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !32

30:                                               ; preds = %10
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 200}
!12 = !{!"_ZTS6Stonne", !13, i64 0, !10, i64 160, !10, i64 164, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !26, i64 264, !26, i64 265, !27, i64 272, !27, i64 280, !27, i64 288, !27, i64 296, !27, i64 304, !10, i64 312}
!13 = !{!"_ZTS6Config", !10, i64 0, !14, i64 4, !15, i64 8, !16, i64 24, !18, i64 40, !19, i64 64, !21, i64 72, !22, i64 96, !23, i64 104}
!14 = !{!"_ZTS15DSNetworkConfig", !10, i64 0}
!15 = !{!"_ZTS13DSwitchConfig", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!16 = !{!"_ZTS15MSNetworkConfig", !17, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!17 = !{!"_ZTS19MultiplierNetwork_t", !7, i64 0}
!18 = !{!"_ZTS13MSwitchConfig", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!19 = !{!"_ZTS15ASNetworkConfig", !20, i64 0, !10, i64 4}
!20 = !{!"_ZTS15ReduceNetwork_t", !7, i64 0}
!21 = !{!"_ZTS13ASwitchConfig", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!22 = !{!"_ZTS17LookUpTableConfig", !10, i64 0, !10, i64 4}
!23 = !{!"_ZTS14SDMemoryConfig", !24, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !25, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!24 = !{!"_ZTS18MemoryController_t", !7, i64 0}
!25 = !{!"_ZTS17MemoryHierarchy_t", !7, i64 0}
!26 = !{!"bool", !7, i64 0}
!27 = !{!"long", !7, i64 0}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !8, i64 0}
!30 = !{!12, !6, i64 168}
!31 = !{!12, !6, i64 176}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress uwtable
define dso_local void @_ZN6Stonne10testMemoryEj(ptr nocapture noundef nonnull readonly align 8 dereferenceable(316) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 200
  %4 = getelementptr inbounds i8, ptr %0, i64 168
  %5 = getelementptr inbounds i8, ptr %0, i64 176
  br label %7

6:                                                ; preds = %7
  ret void

7:                                                ; preds = %2, %7
  %.02 = phi i32 [ 0, %2 ], [ %20, %7 ]
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %8, align 8, !tbaa !26
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %11 = load ptr, ptr %10, align 8
  tail call void %11(ptr noundef nonnull align 8 dereferenceable(48) %8)
  %12 = load ptr, ptr %4, align 8, !tbaa !28
  %13 = load ptr, ptr %12, align 8, !tbaa !26
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8
  tail call void %15(ptr noundef nonnull align 8 dereferenceable(48) %12)
  %16 = load ptr, ptr %5, align 8, !tbaa !29
  %17 = load ptr, ptr %16, align 8, !tbaa !26
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8
  tail call void %19(ptr noundef nonnull align 8 dereferenceable(48) %16)
  %20 = add nuw nsw i32 %.02, 1
  %exitcond.not = icmp eq i32 %20, 20
  br i1 %exitcond.not, label %6, label %7, !llvm.loop !30
}

attributes #0 = { mustprogress 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, !23, i64 200}
!6 = !{!"_ZTS6Stonne", !7, i64 0, !8, i64 160, !8, i64 164, !23, i64 168, !23, i64 176, !23, i64 184, !23, i64 192, !23, i64 200, !23, i64 208, !23, i64 216, !23, i64 224, !23, i64 232, !23, i64 240, !23, i64 248, !23, i64 256, !24, i64 264, !24, i64 265, !25, i64 272, !25, i64 280, !25, i64 288, !25, i64 296, !25, i64 304, !8, i64 312}
!7 = !{!"_ZTS6Config", !8, i64 0, !11, i64 4, !12, i64 8, !13, i64 24, !15, i64 40, !16, i64 64, !18, i64 72, !19, i64 96, !20, i64 104}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS15DSNetworkConfig", !8, i64 0}
!12 = !{!"_ZTS13DSwitchConfig", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!13 = !{!"_ZTS15MSNetworkConfig", !14, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!14 = !{!"_ZTS19MultiplierNetwork_t", !9, i64 0}
!15 = !{!"_ZTS13MSwitchConfig", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20}
!16 = !{!"_ZTS15ASNetworkConfig", !17, i64 0, !8, i64 4}
!17 = !{!"_ZTS15ReduceNetwork_t", !9, i64 0}
!18 = !{!"_ZTS13ASwitchConfig", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20}
!19 = !{!"_ZTS17LookUpTableConfig", !8, i64 0, !8, i64 4}
!20 = !{!"_ZTS14SDMemoryConfig", !21, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !22, i64 28, !8, i64 32, !8, i64 36, !8, i64 40, !8, i64 44, !8, i64 48, !8, i64 52}
!21 = !{!"_ZTS18MemoryController_t", !9, i64 0}
!22 = !{!"_ZTS17MemoryHierarchy_t", !9, i64 0}
!23 = !{!"any pointer", !9, i64 0}
!24 = !{!"bool", !9, i64 0}
!25 = !{!"long", !9, i64 0}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !10, i64 0}
!28 = !{!6, !23, i64 168}
!29 = !{!6, !23, i64 176}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass