; LLVM IR from avrtt/finite-element-method :: boundaries.ll (Z12boundaryCondv)

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

@edges = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12boundaryCondv() #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @_Z9readEdgesv()
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %2

2:                                                ; preds = %25, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = icmp slt i32 %3, 4
  br i1 %4, label %5, label %28

5:                                                ; preds = %2
  %6 = load ptr, ptr @edges, align 8, !tbaa !9
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds double, ptr %6, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fcmp oeq double %10, 2.000000e+00
  br i1 %11, label %12, label %14

12:                                               ; preds = %5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z10secondCondi(i32 noundef %13)
  br label %24

14:                                               ; preds = %5
  %15 = load ptr, ptr @edges, align 8, !tbaa !9
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %15, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = fcmp oeq double %19, 3.000000e+00
  br i1 %20, label %21, label %23

21:                                               ; preds = %14
  %22 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z9thirdCondi(i32 noundef %22)
  br label %23

23:                                               ; preds = %21, %14
  br label %24

24:                                               ; preds = %23, %12
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !13

28:                                               ; preds = %2
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %42, %28
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = icmp slt i32 %30, 4
  br i1 %31, label %32, label %45

32:                                               ; preds = %29
  %33 = load ptr, ptr @edges, align 8, !tbaa !9
  %34 = load i32, ptr %1, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = fcmp oeq double %37, 1.000000e+00
  br i1 %38, label %39, label %41

39:                                               ; preds = %32
  %40 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z9firstCondi(i32 noundef %40)
  br label %41

41:                                               ; preds = %39, %32
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %1, align 4, !tbaa !5
  br label %29, !llvm.loop !15

45:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

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

declare void @_Z9readEdgesv() #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10secondCondi(i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9thirdCondi(i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9firstCondi(i32 noundef) #0

; 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 = { "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 #3 = { 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@edges = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12boundaryCondv() local_unnamed_addr #0 {
  tail call void @_Z9readEdgesv()
  %1 = load ptr, ptr @edges, align 8, !tbaa !5
  %2 = load double, ptr %1, align 8, !tbaa !9
  %3 = fcmp oeq double %2, 2.000000e+00
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  tail call void @_Z10secondCondi(i32 noundef 0)
  br label %8

5:                                                ; preds = %0
  %6 = fcmp oeq double %2, 3.000000e+00
  br i1 %6, label %7, label %8

7:                                                ; preds = %5
  tail call void @_Z9thirdCondi(i32 noundef 0)
  br label %8

8:                                                ; preds = %4, %7, %5
  %9 = load ptr, ptr @edges, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = fcmp oeq double %11, 2.000000e+00
  br i1 %12, label %16, label %13

13:                                               ; preds = %8
  %14 = fcmp oeq double %11, 3.000000e+00
  br i1 %14, label %15, label %17

15:                                               ; preds = %13
  tail call void @_Z9thirdCondi(i32 noundef 1)
  br label %17

16:                                               ; preds = %8
  tail call void @_Z10secondCondi(i32 noundef 1)
  br label %17

17:                                               ; preds = %16, %15, %13
  %18 = load ptr, ptr @edges, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = fcmp oeq double %20, 2.000000e+00
  br i1 %21, label %25, label %22

22:                                               ; preds = %17
  %23 = fcmp oeq double %20, 3.000000e+00
  br i1 %23, label %24, label %26

24:                                               ; preds = %22
  tail call void @_Z9thirdCondi(i32 noundef 2)
  br label %26

25:                                               ; preds = %17
  tail call void @_Z10secondCondi(i32 noundef 2)
  br label %26

26:                                               ; preds = %25, %24, %22
  %27 = load ptr, ptr @edges, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = fcmp oeq double %29, 2.000000e+00
  br i1 %30, label %34, label %31

31:                                               ; preds = %26
  %32 = fcmp oeq double %29, 3.000000e+00
  br i1 %32, label %33, label %.preheader.preheader

33:                                               ; preds = %31
  tail call void @_Z9thirdCondi(i32 noundef 3)
  br label %.preheader.preheader

34:                                               ; preds = %26
  tail call void @_Z10secondCondi(i32 noundef 3)
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %34, %33, %31
  %35 = load ptr, ptr @edges, align 8, !tbaa !5
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = fcmp oeq double %36, 1.000000e+00
  br i1 %37, label %38, label %.preheader.1

38:                                               ; preds = %.preheader.preheader
  tail call void @_Z9firstCondi(i32 noundef 0)
  %.pre = load ptr, ptr @edges, align 8, !tbaa !5
  br label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader, %38
  %39 = phi ptr [ %35, %.preheader.preheader ], [ %.pre, %38 ]
  %40 = getelementptr inbounds i8, ptr %39, i64 8
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = fcmp oeq double %41, 1.000000e+00
  br i1 %42, label %43, label %.preheader.2

43:                                               ; preds = %.preheader.1
  tail call void @_Z9firstCondi(i32 noundef 1)
  %.pre15 = load ptr, ptr @edges, align 8, !tbaa !5
  br label %.preheader.2

.preheader.2:                                     ; preds = %43, %.preheader.1
  %44 = phi ptr [ %.pre15, %43 ], [ %39, %.preheader.1 ]
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %46 = load double, ptr %45, align 8, !tbaa !9
  %47 = fcmp oeq double %46, 1.000000e+00
  br i1 %47, label %48, label %.preheader.3

48:                                               ; preds = %.preheader.2
  tail call void @_Z9firstCondi(i32 noundef 2)
  %.pre16 = load ptr, ptr @edges, align 8, !tbaa !5
  br label %.preheader.3

.preheader.3:                                     ; preds = %48, %.preheader.2
  %49 = phi ptr [ %.pre16, %48 ], [ %44, %.preheader.2 ]
  %50 = getelementptr inbounds i8, ptr %49, i64 24
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = fcmp oeq double %51, 1.000000e+00
  br i1 %52, label %53, label %54

53:                                               ; preds = %.preheader.3
  tail call void @_Z9firstCondi(i32 noundef 3)
  br label %54

54:                                               ; preds = %53, %.preheader.3
  ret void
}

declare void @_Z9readEdgesv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10secondCondi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9thirdCondi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9firstCondi(i32 noundef) local_unnamed_addr #0

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 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass