; LLVM IR from josselinonduty/2022-numerical-methods-for-solving-differential-equations :: src/methods (middle_point)

; 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.__matrix_t = type { ptr, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @solve_middle_point(ptr dead_on_unwind noalias writable sret(%struct.__matrix_t) align 8 %0, x86_fp80 noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca x86_fp80, align 16
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca x86_fp80, align 16
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store x86_fp80 %1, ptr %5, align 16, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  store ptr %3, ptr %7, align 8, !tbaa !11
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = add nsw i64 %18, 1
  call void @matrix_create(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8 %0, i64 noundef %19)
  %20 = load ptr, ptr %7, align 8, !tbaa !11
  %21 = call ptr @vector_copy(ptr noundef %20)
  call void @matrix_append(ptr noundef %0, ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = load ptr, ptr %7, align 8, !tbaa !11
  %23 = call ptr @vector_copy(ptr noundef %22)
  store ptr %23, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %24 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = sitofp i64 %25 to x86_fp80
  %27 = fdiv x86_fp80 %24, %26
  store x86_fp80 %27, ptr %12, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %102, %4
  %29 = load i64, ptr %13, align 8, !tbaa !9
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %105

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %34 = load i64, ptr %13, align 8, !tbaa !9
  %35 = sitofp i64 %34 to x86_fp80
  %36 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %37 = fmul x86_fp80 %35, %36
  %38 = fptosi x86_fp80 %37 to i64
  store i64 %38, ptr %15, align 8, !tbaa !9
  %39 = load i64, ptr %15, align 8, !tbaa !9
  %40 = sitofp i64 %39 to x86_fp80
  %41 = load ptr, ptr %8, align 8, !tbaa !11
  %42 = call ptr @van_der_pol(x86_fp80 noundef %40, ptr noundef %41)
  store ptr %42, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !13
  br label %43

43:                                               ; preds = %66, %33
  %44 = load i32, ptr %16, align 4, !tbaa !13
  %45 = sext i32 %44 to i64
  %46 = icmp ult i64 %45, 2
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %69

48:                                               ; preds = %43
  %49 = load ptr, ptr %8, align 8, !tbaa !11
  %50 = load i32, ptr %16, align 4, !tbaa !13
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds x86_fp80, ptr %49, i64 %51
  %53 = load x86_fp80, ptr %52, align 16, !tbaa !5
  %54 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %55 = fdiv x86_fp80 %54, 0xK40008000000000000000
  %56 = load ptr, ptr %10, align 8, !tbaa !11
  %57 = load i32, ptr %16, align 4, !tbaa !13
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds x86_fp80, ptr %56, i64 %58
  %60 = load x86_fp80, ptr %59, align 16, !tbaa !5
  %61 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %55, x86_fp80 %60, x86_fp80 %53)
  %62 = load ptr, ptr %10, align 8, !tbaa !11
  %63 = load i32, ptr %16, align 4, !tbaa !13
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds x86_fp80, ptr %62, i64 %64
  store x86_fp80 %61, ptr %65, align 16, !tbaa !5
  br label %66

66:                                               ; preds = %48
  %67 = load i32, ptr %16, align 4, !tbaa !13
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %16, align 4, !tbaa !13
  br label %43, !llvm.loop !15

69:                                               ; preds = %47
  %70 = load i64, ptr %15, align 8, !tbaa !9
  %71 = sitofp i64 %70 to x86_fp80
  %72 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %73 = fdiv x86_fp80 %72, 0xK40008000000000000000
  %74 = fadd x86_fp80 %71, %73
  %75 = load ptr, ptr %10, align 8, !tbaa !11
  %76 = call ptr @van_der_pol(x86_fp80 noundef %74, ptr noundef %75)
  store ptr %76, ptr %11, align 8, !tbaa !11
  %77 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %77, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !13
  br label %78

78:                                               ; preds = %96, %69
  %79 = load i32, ptr %17, align 4, !tbaa !13
  %80 = sext i32 %79 to i64
  %81 = icmp ult i64 %80, 2
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %99

83:                                               ; preds = %78
  %84 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %85 = load ptr, ptr %11, align 8, !tbaa !11
  %86 = load i32, ptr %17, align 4, !tbaa !13
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds x86_fp80, ptr %85, i64 %87
  %89 = load x86_fp80, ptr %88, align 16, !tbaa !5
  %90 = load ptr, ptr %9, align 8, !tbaa !11
  %91 = load i32, ptr %17, align 4, !tbaa !13
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds x86_fp80, ptr %90, i64 %92
  %94 = load x86_fp80, ptr %93, align 16, !tbaa !5
  %95 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %84, x86_fp80 %89, x86_fp80 %94)
  store x86_fp80 %95, ptr %93, align 16, !tbaa !5
  br label %96

96:                                               ; preds = %83
  %97 = load i32, ptr %17, align 4, !tbaa !13
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %17, align 4, !tbaa !13
  br label %78, !llvm.loop !17

99:                                               ; preds = %82
  %100 = load ptr, ptr %9, align 8, !tbaa !11
  %101 = call ptr @vector_copy(ptr noundef %100)
  call void @matrix_append(ptr noundef %0, ptr noundef %101)
  call void @vector_free(ptr noundef %10)
  call void @vector_free(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %102

102:                                              ; preds = %99
  %103 = load i64, ptr %13, align 8, !tbaa !9
  %104 = add nsw i64 %103, 1
  store i64 %104, ptr %13, align 8, !tbaa !9
  br label %28, !llvm.loop !18

105:                                              ; preds = %32
  call void @vector_free(ptr noundef %8)
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  ret void
}

declare void @matrix_create(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8, i64 noundef) #1

declare void @matrix_append(ptr noundef, ptr noundef) #1

declare ptr @vector_copy(ptr noundef) #1

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

declare ptr @van_der_pol(x86_fp80 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

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

declare void @vector_free(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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.__matrix_t = type { ptr, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @solve_middle_point(ptr dead_on_unwind noalias writable sret(%struct.__matrix_t) align 8 %0, x86_fp80 noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = add nsw i64 %2, 1
  tail call void @matrix_create(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8 %0, i64 noundef %8) #4
  %9 = tail call ptr @vector_copy(ptr noundef %3) #4
  tail call void @matrix_append(ptr noundef %0, ptr noundef %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %10 = tail call ptr @vector_copy(ptr noundef %3) #4
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %11 = sitofp i64 %2 to x86_fp80
  %12 = fdiv x86_fp80 %1, %11
  %13 = icmp sgt i64 %2, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %14 = fmul x86_fp80 %12, 0xK3FFE8000000000000000
  %15 = getelementptr inbounds i8, ptr %10, i64 16
  br label %16

._crit_edge:                                      ; preds = %16, %4
  call void @vector_free(ptr noundef nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret void

16:                                               ; preds = %.lr.ph, %16
  %.02631 = phi i64 [ 0, %.lr.ph ], [ %39, %16 ]
  %17 = uitofp nneg i64 %.02631 to x86_fp80
  %18 = fmul x86_fp80 %12, %17
  %19 = fptosi x86_fp80 %18 to i64
  %20 = sitofp i64 %19 to x86_fp80
  %21 = call ptr @van_der_pol(x86_fp80 noundef %20, ptr noundef %10) #4
  store ptr %21, ptr %6, align 8, !tbaa !5
  %22 = load x86_fp80, ptr %10, align 16, !tbaa !9
  %23 = load x86_fp80, ptr %21, align 16, !tbaa !9
  %24 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %23, x86_fp80 %22)
  store x86_fp80 %24, ptr %21, align 16, !tbaa !9
  %25 = load x86_fp80, ptr %15, align 16, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %21, i64 16
  %27 = load x86_fp80, ptr %26, align 16, !tbaa !9
  %28 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %27, x86_fp80 %25)
  store x86_fp80 %28, ptr %26, align 16, !tbaa !9
  %29 = fadd x86_fp80 %14, %20
  %30 = call ptr @van_der_pol(x86_fp80 noundef %29, ptr noundef nonnull %21) #4
  store ptr %30, ptr %7, align 8, !tbaa !5
  %31 = load x86_fp80, ptr %30, align 16, !tbaa !9
  %32 = load x86_fp80, ptr %10, align 16, !tbaa !9
  %33 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %31, x86_fp80 %32)
  store x86_fp80 %33, ptr %10, align 16, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %30, i64 16
  %35 = load x86_fp80, ptr %34, align 16, !tbaa !9
  %36 = load x86_fp80, ptr %15, align 16, !tbaa !9
  %37 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %35, x86_fp80 %36)
  store x86_fp80 %37, ptr %15, align 16, !tbaa !9
  %38 = call ptr @vector_copy(ptr noundef nonnull %10) #4
  call void @matrix_append(ptr noundef %0, ptr noundef %38) #4
  call void @vector_free(ptr noundef nonnull %6) #4
  call void @vector_free(ptr noundef nonnull %7) #4
  %39 = add nuw nsw i64 %.02631, 1
  %exitcond.not = icmp eq i64 %39, %2
  br i1 %exitcond.not, label %._crit_edge, label %16, !llvm.loop !11
}

declare void @matrix_create(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8, i64 noundef) local_unnamed_addr #1

declare void @matrix_append(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @vector_copy(ptr noundef) local_unnamed_addr #1

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

declare ptr @van_der_pol(x86_fp80 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

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

declare void @vector_free(ptr noundef) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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