; LLVM IR from duc0/ContestNeko :: CPPProjects/UndirectedGraph.ll (Z11getEquationii)

; 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.Equation = type { i32, i32 }

@n = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z11getEquationii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca %struct.Equation, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = add nsw i32 %7, %8
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  %12 = icmp sgt i32 %9, %11
  br i1 %12, label %13, label %23

13:                                               ; preds = %2
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = sub nsw i32 %14, %15
  %17 = add nsw i32 %16, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sub nsw i32 %18, %19
  %21 = add nsw i32 %20, 1
  %22 = call i64 @_Z11getEquationii(i32 noundef %17, i32 noundef %21)
  store i64 %22, ptr %3, align 4
  br label %54

23:                                               ; preds = %2
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp sgt i32 %24, %25
  br i1 %26, label %27, label %31

27:                                               ; preds = %23
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = call i64 @_Z11getEquationii(i32 noundef %28, i32 noundef %29)
  store i64 %30, ptr %3, align 4
  br label %54

31:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sub nsw i32 %32, %33
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = getelementptr inbounds %struct.Equation, ptr %3, i32 0, i32 0
  store i32 %36, ptr %37, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sub nsw i32 %39, 1
  %41 = mul nsw i32 2, %40
  %42 = add nsw i32 %38, %41
  %43 = getelementptr inbounds %struct.Equation, ptr %3, i32 0, i32 1
  store i32 %42, ptr %43, align 4, !tbaa !11
  %44 = getelementptr inbounds %struct.Equation, ptr %3, i32 0, i32 0
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp sle i32 %45, 2
  br i1 %46, label %47, label %49

47:                                               ; preds = %31
  %48 = getelementptr inbounds %struct.Equation, ptr %3, i32 0, i32 0
  store i32 0, ptr %48, align 4, !tbaa !9
  br label %53

49:                                               ; preds = %31
  %50 = getelementptr inbounds %struct.Equation, ptr %3, i32 0, i32 0
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = sub nsw i32 %51, 2
  store i32 %52, ptr %50, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %49, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %54

54:                                               ; preds = %53, %27, %13
  %55 = load i64, ptr %3, align 4
  ret i64 %55
}

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

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

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


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

@n = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i64 @_Z11getEquationii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = add nsw i32 %1, %0
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = add nsw i32 %4, 1
  %6 = icmp sgt i32 %3, %5
  br i1 %6, label %7, label %11

7:                                                ; preds = %2
  %reass.sub = sub i32 %4, %1
  %8 = add i32 %reass.sub, 1
  %reass.sub22 = sub i32 %4, %0
  %9 = add i32 %reass.sub22, 1
  %10 = tail call i64 @_Z11getEquationii(i32 noundef %8, i32 noundef %9)
  %.sroa.0.0.extract.trunc = trunc i64 %10 to i32
  %.sroa.8.0.extract.shift = lshr i64 %10, 32
  %.sroa.8.0.extract.trunc = trunc nuw i64 %.sroa.8.0.extract.shift to i32
  br label %21

11:                                               ; preds = %2
  %12 = icmp sgt i32 %0, %1
  br i1 %12, label %13, label %15

13:                                               ; preds = %11
  %14 = tail call i64 @_Z11getEquationii(i32 noundef %1, i32 noundef %0)
  %.sroa.0.0.extract.trunc14 = trunc i64 %14 to i32
  %.sroa.8.0.extract.shift16 = lshr i64 %14, 32
  %.sroa.8.0.extract.trunc17 = trunc nuw i64 %.sroa.8.0.extract.shift16 to i32
  br label %21

15:                                               ; preds = %11
  %16 = sub nsw i32 %1, %0
  %17 = shl i32 %0, 1
  %18 = add i32 %16, -1
  %19 = add i32 %18, %17
  %20 = icmp slt i32 %16, 2
  %.sroa.0.0 = select i1 %20, i32 0, i32 %18
  br label %21

21:                                               ; preds = %15, %13, %7
  %.sroa.0.1 = phi i32 [ %.sroa.0.0.extract.trunc, %7 ], [ %.sroa.0.0.extract.trunc14, %13 ], [ %.sroa.0.0, %15 ]
  %.sroa.8.0 = phi i32 [ %.sroa.8.0.extract.trunc, %7 ], [ %.sroa.8.0.extract.trunc17, %13 ], [ %19, %15 ]
  %.sroa.8.0.insert.ext = zext i32 %.sroa.8.0 to i64
  %.sroa.8.0.insert.shift = shl nuw i64 %.sroa.8.0.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %.sroa.0.1 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.8.0.insert.shift, %.sroa.0.0.insert.ext
  ret i64 %.sroa.0.0.insert.insert
}

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass