; LLVM IR from ShahjalalShohag/code-library :: Number Theory/Phi Field.ll (Z3fibx)

; 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.field = type { %struct.modint, %struct.modint }
%struct.modint = type { i32 }

@phi = external dso_local global %struct.field, align 4
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._Z3fibx = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5fieldC2E6modintILi998244353EES1_(ptr noundef nonnull align 4 dereferenceable(8), i32, i32) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local i32 @_Z3fibx(i64 noundef %0) #1 {
  %2 = alloca %struct.modint, align 4
  %3 = alloca i64, align 8
  %4 = alloca %struct.field, align 4
  %5 = alloca %struct.field, align 4
  %6 = alloca %struct.field, align 4
  %7 = alloca %struct.field, align 4
  %8 = alloca %struct.field, align 4
  %9 = alloca %struct.modint, align 4
  %10 = alloca %struct.modint, align 4
  %11 = alloca %struct.field, align 4
  %12 = alloca %struct.field, align 4
  %13 = alloca %struct.modint, align 4
  %14 = alloca %struct.modint, align 4
  %15 = alloca %struct.modint, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %17 = call i64 @_ZN5field3powEx(ptr noundef nonnull align 4 dereferenceable(8) @phi, i64 noundef %16)
  store i64 %17, ptr %5, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %9, i32 noundef 1)
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %10, i32 noundef 0)
  %18 = getelementptr inbounds %struct.modint, ptr %9, i32 0, i32 0
  %19 = load i32, ptr %18, align 4
  %20 = getelementptr inbounds %struct.modint, ptr %10, i32 0, i32 0
  %21 = load i32, ptr %20, align 4
  call void @_ZN5fieldC2E6modintILi998244353EES1_(ptr noundef nonnull align 4 dereferenceable(8) %8, i32 %19, i32 %21)
  %22 = call i64 @_ZNK5fieldmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) @phi)
  store i64 %22, ptr %7, align 4
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = call i64 @_ZN5field3powEx(ptr noundef nonnull align 4 dereferenceable(8) %7, i64 noundef %23)
  store i64 %24, ptr %6, align 4
  %25 = call i64 @_ZNK5fieldmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6)
  store i64 %25, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef 0)
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %14, i32 noundef 1)
  %26 = getelementptr inbounds %struct.modint, ptr %13, i32 0, i32 0
  %27 = load i32, ptr %26, align 4
  %28 = getelementptr inbounds %struct.modint, ptr %14, i32 0, i32 0
  %29 = load i32, ptr %28, align 4
  call void @_ZN5fieldC2E6modintILi998244353EES1_(ptr noundef nonnull align 4 dereferenceable(8) %12, i32 %27, i32 %29)
  %30 = load i64, ptr %12, align 4
  %31 = call i64 @_ZN5fielddvES_(ptr noundef nonnull align 4 dereferenceable(8) %4, i64 %30)
  store i64 %31, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %32 = getelementptr inbounds %struct.field, ptr %4, i32 0, i32 1
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %15, i32 noundef 0)
  %33 = getelementptr inbounds %struct.modint, ptr %15, i32 0, i32 0
  %34 = load i32, ptr %33, align 4
  %35 = call noundef zeroext i1 @_ZNK6modintILi998244353EEeqES0_(ptr noundef nonnull align 4 dereferenceable(4) %32, i32 %34)
  br i1 %35, label %36, label %37

36:                                               ; preds = %1
  br label %39

37:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 79, ptr noundef @__PRETTY_FUNCTION__._Z3fibx) #7
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  %40 = getelementptr inbounds %struct.field, ptr %4, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %40, i64 4, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %41 = getelementptr inbounds %struct.modint, ptr %2, i32 0, i32 0
  %42 = load i32, ptr %41, align 4
  ret i32 %42
}

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN5field3powEx(ptr noundef nonnull align 4 dereferenceable(8), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZNK5fieldmiERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN5fielddvES_(ptr noundef nonnull align 4 dereferenceable(8), i64) #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6modintILi998244353EEeqES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) #4 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

attributes #0 = { mustprogress 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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress 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 #5 = { noreturn nounwind "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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{i64 0, i64 4, !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"

%struct.field = type { %struct.modint, %struct.modint }
%struct.modint = type { i32 }

@phi = external dso_local global %struct.field, align 4
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._Z3fibx = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5fieldC2E6modintILi998244353EES1_(ptr noundef nonnull align 4 dereferenceable(8), i32, i32) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local i32 @_Z3fibx(i64 noundef %0) local_unnamed_addr #1 {
  %2 = alloca %struct.field, align 8
  %3 = alloca %struct.field, align 8
  %4 = alloca %struct.field, align 8
  %5 = alloca %struct.field, align 8
  %6 = alloca %struct.field, align 4
  %7 = alloca %struct.modint, align 4
  %8 = alloca %struct.modint, align 4
  %9 = alloca %struct.field, align 8
  %10 = alloca %struct.modint, align 4
  %11 = alloca %struct.modint, align 4
  %12 = alloca %struct.modint, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %13 = tail call i64 @_ZN5field3powEx(ptr noundef nonnull align 4 dereferenceable(8) @phi, i64 noundef %0)
  store i64 %13, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %7, i32 noundef 1)
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %8, i32 noundef 0)
  %14 = load i32, ptr %7, align 4
  %15 = load i32, ptr %8, align 4
  call void @_ZN5fieldC2E6modintILi998244353EES1_(ptr noundef nonnull align 4 dereferenceable(8) %6, i32 %14, i32 %15)
  %16 = call i64 @_ZNK5fieldmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) @phi)
  store i64 %16, ptr %5, align 8
  %17 = call i64 @_ZN5field3powEx(ptr noundef nonnull align 4 dereferenceable(8) %5, i64 noundef %0)
  store i64 %17, ptr %4, align 8
  %18 = call i64 @_ZNK5fieldmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %4)
  store i64 %18, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %10, i32 noundef 0)
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef 1)
  %19 = load i32, ptr %10, align 4
  %20 = load i32, ptr %11, align 4
  call void @_ZN5fieldC2E6modintILi998244353EES1_(ptr noundef nonnull align 4 dereferenceable(8) %9, i32 %19, i32 %20)
  %21 = load i64, ptr %9, align 8
  %22 = call i64 @_ZN5fielddvES_(ptr noundef nonnull align 4 dereferenceable(8) %2, i64 %21)
  store i64 %22, ptr %2, align 8
  %23 = getelementptr inbounds i8, ptr %2, i64 4
  call void @_ZN6modintILi998244353EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef 0)
  %24 = load i32, ptr %12, align 4
  %25 = call noundef zeroext i1 @_ZNK6modintILi998244353EEeqES0_(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 %24)
  br i1 %25, label %27, label %26

26:                                               ; preds = %1
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 79, ptr noundef nonnull @__PRETTY_FUNCTION__._Z3fibx) #6
  unreachable

27:                                               ; preds = %1
  %.sroa.02.0.copyload = load i32, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret i32 %.sroa.02.0.copyload
}

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN5field3powEx(ptr noundef nonnull align 4 dereferenceable(8), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZNK5fieldmiERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN5fielddvES_(ptr noundef nonnull align 4 dereferenceable(8), i64) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6modintILi998244353EEeqES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) local_unnamed_addr #3 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 #4 = { noreturn nounwind "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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass