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

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

@constinit = external hidden constant [2 x x86_fp80], align 16
@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca x86_fp80, align 16
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [2 x x86_fp80], align 16
  %10 = alloca %struct.__matrix_t, align 8
  %11 = alloca %struct.__matrix_t, align 8
  %12 = alloca %struct.__matrix_t, align 8
  %13 = alloca %struct.__matrix_t, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  store x86_fp80 0xK4002F000000000000000, ptr %6, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 100, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @constinit, i64 32, i1 false), !tbaa.struct !15
  %14 = call ptr @vector_copy(ptr noundef %9)
  store ptr %14, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  %15 = load x86_fp80, ptr %6, align 16, !tbaa !11
  %16 = load i64, ptr %7, align 8, !tbaa !13
  %17 = load ptr, ptr %8, align 8, !tbaa !9
  call void @solve_middle_point(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8 %10, x86_fp80 noundef %15, i64 noundef %16, ptr noundef %17)
  call void @matrix_save_csv(ptr noundef @.str, ptr noundef byval(%struct.__matrix_t) align 8 %10)
  call void @matrix_free(ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  %18 = load x86_fp80, ptr %6, align 16, !tbaa !11
  %19 = load i64, ptr %7, align 8, !tbaa !13
  %20 = load ptr, ptr %8, align 8, !tbaa !9
  call void @solve_runge_kutta_4(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8 %11, x86_fp80 noundef %18, i64 noundef %19, ptr noundef %20)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %11, i64 24, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @matrix_save_csv(ptr noundef @.str.1, ptr noundef byval(%struct.__matrix_t) align 8 %10)
  call void @matrix_free(ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #4
  %21 = load x86_fp80, ptr %6, align 16, !tbaa !11
  %22 = load i64, ptr %7, align 8, !tbaa !13
  %23 = load ptr, ptr %8, align 8, !tbaa !9
  call void @solve_adams_bashforth(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8 %12, x86_fp80 noundef %21, i64 noundef %22, ptr noundef %23)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %12, i64 24, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  call void @matrix_save_csv(ptr noundef @.str.2, ptr noundef byval(%struct.__matrix_t) align 8 %10)
  call void @matrix_free(ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #4
  %24 = load x86_fp80, ptr %6, align 16, !tbaa !11
  %25 = load i64, ptr %7, align 8, !tbaa !13
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  call void @solve_adams_moulton(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8 %13, x86_fp80 noundef %24, i64 noundef %25, ptr noundef %26, x86_fp80 noundef 0xK3FF8A3D70A3D70A3D800, i64 noundef 10000)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %13, i64 24, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #4
  call void @matrix_save_csv(ptr noundef @.str.3, ptr noundef byval(%struct.__matrix_t) align 8 %10)
  call void @matrix_free(ptr noundef %10)
  call void @vector_free(ptr noundef %8)
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  ret i32 0
}

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

declare ptr @vector_copy(ptr noundef) #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

declare void @solve_middle_point(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8, x86_fp80 noundef, i64 noundef, ptr noundef) #2

declare void @matrix_save_csv(ptr noundef, ptr noundef byval(%struct.__matrix_t) align 8) #2

declare void @matrix_free(ptr noundef) #2

declare void @solve_runge_kutta_4(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8, x86_fp80 noundef, i64 noundef, ptr noundef) #2

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

declare void @solve_adams_bashforth(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8, x86_fp80 noundef, i64 noundef, ptr noundef) #2

declare void @solve_adams_moulton(ptr dead_on_unwind writable sret(%struct.__matrix_t) align 8, x86_fp80 noundef, i64 noundef, ptr noundef, x86_fp80 noundef, i64 noundef) #2

declare void @vector_free(ptr noundef) #2

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{i64 0, i64 32, !16}
!16 = !{!7, !7, i64 0}
!17 = !{i64 0, i64 8, !9, i64 8, i64 8, !13, i64 16, i64 8, !13}


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

@constinit = external hidden local_unnamed_addr constant [2 x x86_fp80], align 16
@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca [2 x x86_fp80], align 16
  %5 = alloca %struct.__matrix_t, align 8
  %6 = alloca %struct.__matrix_t, align 8
  %7 = alloca %struct.__matrix_t, align 8
  %8 = alloca %struct.__matrix_t, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %4, ptr noundef nonnull align 16 dereferenceable(32) @constinit, i64 32, i1 false), !tbaa.struct !5
  %9 = call ptr @vector_copy(ptr noundef nonnull %4) #4
  store ptr %9, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #4
  call void @solve_middle_point(ptr dead_on_unwind nonnull writable sret(%struct.__matrix_t) align 8 %5, x86_fp80 noundef 0xK4002F000000000000000, i64 noundef 100, ptr noundef %9) #4
  call void @matrix_save_csv(ptr noundef nonnull @.str, ptr noundef nonnull byval(%struct.__matrix_t) align 8 %5) #4
  call void @matrix_free(ptr noundef nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  call void @solve_runge_kutta_4(ptr dead_on_unwind nonnull writable sret(%struct.__matrix_t) align 8 %6, x86_fp80 noundef 0xK4002F000000000000000, i64 noundef 100, ptr noundef %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %6, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  call void @matrix_save_csv(ptr noundef nonnull @.str.1, ptr noundef nonnull byval(%struct.__matrix_t) align 8 %5) #4
  call void @matrix_free(ptr noundef nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #4
  call void @solve_adams_bashforth(ptr dead_on_unwind nonnull writable sret(%struct.__matrix_t) align 8 %7, x86_fp80 noundef 0xK4002F000000000000000, i64 noundef 100, ptr noundef %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %7, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  call void @matrix_save_csv(ptr noundef nonnull @.str.2, ptr noundef nonnull byval(%struct.__matrix_t) align 8 %5) #4
  call void @matrix_free(ptr noundef nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #4
  call void @solve_adams_moulton(ptr dead_on_unwind nonnull writable sret(%struct.__matrix_t) align 8 %8, x86_fp80 noundef 0xK4002F000000000000000, i64 noundef 100, ptr noundef %9, x86_fp80 noundef 0xK3FF8A3D70A3D70A3D800, i64 noundef 10000) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #4
  call void @matrix_save_csv(ptr noundef nonnull @.str.3, ptr noundef nonnull byval(%struct.__matrix_t) align 8 %5) #4
  call void @matrix_free(ptr noundef nonnull %5) #4
  call void @vector_free(ptr noundef nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret i32 0
}

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

declare ptr @vector_copy(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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

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

declare void @matrix_save_csv(ptr noundef, ptr noundef byval(%struct.__matrix_t) align 8) local_unnamed_addr #2

declare void @matrix_free(ptr noundef) local_unnamed_addr #2

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

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

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

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

declare void @vector_free(ptr noundef) local_unnamed_addr #2

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 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 32, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{i64 0, i64 8, !9, i64 8, i64 8, !12, i64 16, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass