; LLVM IR from paroj/gltut :: glsdk/freeglut/progs/demos/Lorenz (lorenz)

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

; Function Attrs: nounwind uwtable
declare dso_local void @calc_deriv(ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @advance_in_time(double noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [3 x double], align 16
  %8 = alloca [3 x double], align 16
  %9 = alloca [3 x double], align 16
  %10 = alloca [3 x double], align 16
  %11 = alloca i32, align 4
  store double %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %12 = load ptr, ptr %6, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %13, i64 24, i1 false)
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  call void @calc_deriv(ptr noundef %14, ptr noundef %15)
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %36, %3
  %17 = load i32, ptr %11, align 4, !tbaa !11
  %18 = icmp slt i32 %17, 3
  br i1 %18, label %19, label %39

19:                                               ; preds = %16
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = load i32, ptr %11, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %20, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = load double, ptr %4, align 8, !tbaa !5
  %26 = fmul double 5.000000e-01, %25
  %27 = load i32, ptr %11, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = call double @llvm.fmuladd.f64(double %26, double %30, double %24)
  %32 = load ptr, ptr %6, align 8, !tbaa !9
  %33 = load i32, ptr %11, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  store double %31, ptr %35, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %19
  %37 = load i32, ptr %11, align 4, !tbaa !11
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %11, align 4, !tbaa !11
  br label %16, !llvm.loop !13

39:                                               ; preds = %16
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds [3 x double], ptr %8, i64 0, i64 0
  call void @calc_deriv(ptr noundef %40, ptr noundef %41)
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %62, %39
  %43 = load i32, ptr %11, align 4, !tbaa !11
  %44 = icmp slt i32 %43, 3
  br i1 %44, label %45, label %65

45:                                               ; preds = %42
  %46 = load ptr, ptr %5, align 8, !tbaa !9
  %47 = load i32, ptr %11, align 4, !tbaa !11
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %46, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !5
  %51 = load double, ptr %4, align 8, !tbaa !5
  %52 = fmul double 5.000000e-01, %51
  %53 = load i32, ptr %11, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [3 x double], ptr %8, i64 0, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !5
  %57 = call double @llvm.fmuladd.f64(double %52, double %56, double %50)
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = load i32, ptr %11, align 4, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %58, i64 %60
  store double %57, ptr %61, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %45
  %63 = load i32, ptr %11, align 4, !tbaa !11
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %11, align 4, !tbaa !11
  br label %42, !llvm.loop !15

65:                                               ; preds = %42
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  call void @calc_deriv(ptr noundef %66, ptr noundef %67)
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %87, %65
  %69 = load i32, ptr %11, align 4, !tbaa !11
  %70 = icmp slt i32 %69, 3
  br i1 %70, label %71, label %90

71:                                               ; preds = %68
  %72 = load ptr, ptr %5, align 8, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !11
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %72, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !5
  %77 = load double, ptr %4, align 8, !tbaa !5
  %78 = load i32, ptr %11, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !5
  %82 = call double @llvm.fmuladd.f64(double %77, double %81, double %76)
  %83 = load ptr, ptr %6, align 8, !tbaa !9
  %84 = load i32, ptr %11, align 4, !tbaa !11
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %83, i64 %85
  store double %82, ptr %86, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %71
  %88 = load i32, ptr %11, align 4, !tbaa !11
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %11, align 4, !tbaa !11
  br label %68, !llvm.loop !16

90:                                               ; preds = %68
  %91 = load ptr, ptr %6, align 8, !tbaa !9
  %92 = getelementptr inbounds [3 x double], ptr %10, i64 0, i64 0
  call void @calc_deriv(ptr noundef %91, ptr noundef %92)
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %93

93:                                               ; preds = %128, %90
  %94 = load i32, ptr %11, align 4, !tbaa !11
  %95 = icmp slt i32 %94, 3
  br i1 %95, label %96, label %131

96:                                               ; preds = %93
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = load i32, ptr %11, align 4, !tbaa !11
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds double, ptr %97, i64 %99
  %101 = load double, ptr %100, align 8, !tbaa !5
  %102 = load double, ptr %4, align 8, !tbaa !5
  %103 = fmul double 0x3FC5555555555555, %102
  %104 = load i32, ptr %11, align 4, !tbaa !11
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !5
  %108 = load i32, ptr %11, align 4, !tbaa !11
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [3 x double], ptr %8, i64 0, i64 %109
  %111 = load double, ptr %110, align 8, !tbaa !5
  %112 = load i32, ptr %11, align 4, !tbaa !11
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 %113
  %115 = load double, ptr %114, align 8, !tbaa !5
  %116 = fadd double %111, %115
  %117 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %116, double %107)
  %118 = load i32, ptr %11, align 4, !tbaa !11
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [3 x double], ptr %10, i64 0, i64 %119
  %121 = load double, ptr %120, align 8, !tbaa !5
  %122 = fadd double %117, %121
  %123 = call double @llvm.fmuladd.f64(double %103, double %122, double %101)
  %124 = load ptr, ptr %6, align 8, !tbaa !9
  %125 = load i32, ptr %11, align 4, !tbaa !11
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds double, ptr %124, i64 %126
  store double %123, ptr %127, align 8, !tbaa !5
  br label %128

128:                                              ; preds = %96
  %129 = load i32, ptr %11, align 4, !tbaa !11
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %11, align 4, !tbaa !11
  br label %93, !llvm.loop !17

131:                                              ; preds = %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !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"

; Function Attrs: nounwind uwtable
declare dso_local void @calc_deriv(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @advance_in_time(double noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [3 x double], align 16
  %5 = alloca [3 x double], align 16
  %6 = alloca [3 x double], align 16
  %7 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %1, i64 24, i1 false)
  call void @calc_deriv(ptr noundef %1, ptr noundef nonnull %4)
  %8 = fmul double %0, 5.000000e-01
  %9 = load double, ptr %1, align 8, !tbaa !5
  %10 = load double, ptr %4, align 16, !tbaa !5
  %11 = call double @llvm.fmuladd.f64(double %8, double %10, double %9)
  store double %11, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %4, i64 8
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = call double @llvm.fmuladd.f64(double %8, double %15, double %13)
  %17 = getelementptr inbounds i8, ptr %2, i64 8
  store double %16, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %4, i64 16
  %21 = load double, ptr %20, align 16, !tbaa !5
  %22 = call double @llvm.fmuladd.f64(double %8, double %21, double %19)
  %23 = getelementptr inbounds i8, ptr %2, i64 16
  store double %22, ptr %23, align 8, !tbaa !5
  call void @calc_deriv(ptr noundef nonnull %2, ptr noundef nonnull %5)
  %24 = load double, ptr %1, align 8, !tbaa !5
  %25 = load double, ptr %5, align 16, !tbaa !5
  %26 = call double @llvm.fmuladd.f64(double %8, double %25, double %24)
  store double %26, ptr %2, align 8, !tbaa !5
  %27 = load double, ptr %12, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %5, i64 8
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = call double @llvm.fmuladd.f64(double %8, double %29, double %27)
  store double %30, ptr %17, align 8, !tbaa !5
  %31 = load double, ptr %18, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %5, i64 16
  %33 = load double, ptr %32, align 16, !tbaa !5
  %34 = call double @llvm.fmuladd.f64(double %8, double %33, double %31)
  store double %34, ptr %23, align 8, !tbaa !5
  call void @calc_deriv(ptr noundef nonnull %1, ptr noundef nonnull %6)
  %35 = load double, ptr %1, align 8, !tbaa !5
  %36 = load double, ptr %6, align 16, !tbaa !5
  %37 = call double @llvm.fmuladd.f64(double %0, double %36, double %35)
  store double %37, ptr %2, align 8, !tbaa !5
  %38 = load double, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %6, i64 8
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = call double @llvm.fmuladd.f64(double %0, double %40, double %38)
  store double %41, ptr %17, align 8, !tbaa !5
  %42 = load double, ptr %18, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %6, i64 16
  %44 = load double, ptr %43, align 16, !tbaa !5
  %45 = call double @llvm.fmuladd.f64(double %0, double %44, double %42)
  store double %45, ptr %23, align 8, !tbaa !5
  call void @calc_deriv(ptr noundef nonnull %2, ptr noundef nonnull %7)
  %46 = fmul double %0, 0x3FC5555555555555
  %47 = load double, ptr %1, align 8, !tbaa !5
  %48 = load double, ptr %4, align 16, !tbaa !5
  %49 = load double, ptr %5, align 16, !tbaa !5
  %50 = load double, ptr %6, align 16, !tbaa !5
  %51 = fadd double %49, %50
  %52 = call double @llvm.fmuladd.f64(double %51, double 2.000000e+00, double %48)
  %53 = load double, ptr %7, align 16, !tbaa !5
  %54 = fadd double %53, %52
  %55 = call double @llvm.fmuladd.f64(double %46, double %54, double %47)
  store double %55, ptr %2, align 8, !tbaa !5
  %56 = load double, ptr %12, align 8, !tbaa !5
  %57 = load double, ptr %14, align 8, !tbaa !5
  %58 = load double, ptr %28, align 8, !tbaa !5
  %59 = load double, ptr %39, align 8, !tbaa !5
  %60 = fadd double %58, %59
  %61 = call double @llvm.fmuladd.f64(double %60, double 2.000000e+00, double %57)
  %62 = getelementptr inbounds i8, ptr %7, i64 8
  %63 = load double, ptr %62, align 8, !tbaa !5
  %64 = fadd double %63, %61
  %65 = call double @llvm.fmuladd.f64(double %46, double %64, double %56)
  store double %65, ptr %17, align 8, !tbaa !5
  %66 = load double, ptr %18, align 8, !tbaa !5
  %67 = load double, ptr %20, align 16, !tbaa !5
  %68 = load double, ptr %32, align 16, !tbaa !5
  %69 = load double, ptr %43, align 16, !tbaa !5
  %70 = fadd double %68, %69
  %71 = call double @llvm.fmuladd.f64(double %70, double 2.000000e+00, double %67)
  %72 = getelementptr inbounds i8, ptr %7, i64 16
  %73 = load double, ptr %72, align 16, !tbaa !5
  %74 = fadd double %73, %71
  %75 = call double @llvm.fmuladd.f64(double %46, double %74, double %66)
  store double %75, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  ret void
}

; 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 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 speculatable willreturn memory(none) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass