; LLVM IR from dmalyuta/FlyARocket_GNC :: imu_funcs (Calibrate_IMU)

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

@psi_av = external dso_local global float, align 4
@theta_av = external dso_local global float, align 4
@phi_av = external dso_local global float, align 4
@num_av_vars = external dso_local global i32, align 4
@time_imu = external dso_local global i64, align 8
@psi_save = external dso_local global float, align 4
@theta_save = external dso_local global float, align 4
@phi_save = external dso_local global float, align 4
@R_MATRIX = external dso_local global %struct.MATRIX, align 8
@before_loop = external dso_local global %struct.timeval, align 8
@before_imu = external dso_local global %struct.timeval, align 8
@now_loop = external dso_local global %struct.timeval, align 8
@elapsed_loop = external dso_local global %struct.timeval, align 8
@time_loop = external dso_local global i64, align 8
@now_imu = external dso_local global %struct.timeval, align 8
@elapsed_imu = external dso_local global %struct.timeval, align 8
@IMU__READ_TIMESTEP = external global i64, align 8
@psi = external dso_local global float, align 4
@theta = external dso_local global float, align 4
@phi = external dso_local global float, align 4
@.str.8 = external hidden unnamed_addr constant [54 x i8], align 1
@CALIB__TIME = external global i64, align 8

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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local float @TO_DEG(float noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @Calibrate_IMU() #3 {
  %1 = call i32 @gettimeofday(ptr noundef @before_loop, ptr noundef null) #4
  %2 = call i32 @gettimeofday(ptr noundef @before_imu, ptr noundef null) #4
  br label %3

3:                                                ; preds = %34, %0
  %4 = load i64, ptr @before_loop, align 8
  %5 = load i64, ptr getelementptr inbounds ({ i64, i64 }, ptr @before_loop, i32 0, i32 1), align 8
  %6 = load i64, ptr @elapsed_loop, align 8
  %7 = load i64, ptr getelementptr inbounds ({ i64, i64 }, ptr @elapsed_loop, i32 0, i32 1), align 8
  call void @check_time(ptr noundef @now_loop, i64 %4, i64 %5, i64 %6, i64 %7, ptr noundef @time_loop)
  %8 = load i64, ptr @IMU__READ_TIMESTEP, align 8, !tbaa !5
  call void @passive_wait(ptr noundef @now_imu, ptr noundef @before_imu, ptr noundef @elapsed_imu, ptr noundef @time_imu, i64 noundef %8)
  %9 = load float, ptr @psi, align 4, !tbaa !9
  store float %9, ptr @psi_save, align 4, !tbaa !9
  %10 = load float, ptr @theta, align 4, !tbaa !9
  store float %10, ptr @theta_save, align 4, !tbaa !9
  %11 = load float, ptr @phi, align 4, !tbaa !9
  store float %11, ptr @phi_save, align 4, !tbaa !9
  %12 = load float, ptr @psi_av, align 4, !tbaa !9
  %13 = load float, ptr @psi_save, align 4, !tbaa !9
  %14 = fadd float %12, %13
  store float %14, ptr @psi_av, align 4, !tbaa !9
  %15 = load float, ptr @theta_av, align 4, !tbaa !9
  %16 = load float, ptr @theta_save, align 4, !tbaa !9
  %17 = fadd float %15, %16
  store float %17, ptr @theta_av, align 4, !tbaa !9
  %18 = load float, ptr @phi_av, align 4, !tbaa !9
  %19 = load float, ptr @phi_save, align 4, !tbaa !9
  %20 = fadd float %18, %19
  store float %20, ptr @phi_av, align 4, !tbaa !9
  %21 = load i32, ptr @num_av_vars, align 4, !tbaa !11
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr @num_av_vars, align 4, !tbaa !11
  %23 = load i64, ptr @time_imu, align 8, !tbaa !5
  %24 = load float, ptr @psi, align 4, !tbaa !9
  %25 = call float @TO_DEG(float noundef %24)
  %26 = fpext float %25 to double
  %27 = load float, ptr @theta, align 4, !tbaa !9
  %28 = call float @TO_DEG(float noundef %27)
  %29 = fpext float %28 to double
  %30 = load float, ptr @phi, align 4, !tbaa !9
  %31 = call float @TO_DEG(float noundef %30)
  %32 = fpext float %31 to double
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i64 noundef %23, double noundef %26, double noundef %29, double noundef %32)
  br label %34

34:                                               ; preds = %3
  %35 = load i64, ptr @time_loop, align 8, !tbaa !5
  %36 = load i64, ptr @CALIB__TIME, align 8, !tbaa !13
  %37 = icmp ule i64 %35, %36
  br i1 %37, label %3, label %38, !llvm.loop !15

38:                                               ; preds = %34
  %39 = load float, ptr @psi_av, align 4, !tbaa !9
  %40 = load i32, ptr @num_av_vars, align 4, !tbaa !11
  %41 = sitofp i32 %40 to float
  %42 = fdiv float %39, %41
  store float %42, ptr @psi_av, align 4, !tbaa !9
  %43 = load float, ptr @theta_av, align 4, !tbaa !9
  %44 = load i32, ptr @num_av_vars, align 4, !tbaa !11
  %45 = sitofp i32 %44 to float
  %46 = fdiv float %43, %45
  store float %46, ptr @theta_av, align 4, !tbaa !9
  %47 = load float, ptr @phi_av, align 4, !tbaa !9
  %48 = load i32, ptr @num_av_vars, align 4, !tbaa !11
  %49 = sitofp i32 %48 to float
  %50 = fdiv float %47, %49
  store float %50, ptr @phi_av, align 4, !tbaa !9
  %51 = load float, ptr @theta_av, align 4, !tbaa !9
  %52 = fpext float %51 to double
  %53 = call double @cos(double noundef %52) #4
  %54 = load float, ptr @psi_av, align 4, !tbaa !9
  %55 = fpext float %54 to double
  %56 = call double @cos(double noundef %55) #4
  %57 = fmul double %53, %56
  %58 = fptrunc double %57 to float
  %59 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %60 = getelementptr inbounds ptr, ptr %59, i64 0
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = getelementptr inbounds float, ptr %61, i64 0
  store float %58, ptr %62, align 4, !tbaa !9
  %63 = load float, ptr @theta_av, align 4, !tbaa !9
  %64 = fpext float %63 to double
  %65 = call double @cos(double noundef %64) #4
  %66 = load float, ptr @psi_av, align 4, !tbaa !9
  %67 = fpext float %66 to double
  %68 = call double @sin(double noundef %67) #4
  %69 = fmul double %65, %68
  %70 = fptrunc double %69 to float
  %71 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %72 = getelementptr inbounds ptr, ptr %71, i64 0
  %73 = load ptr, ptr %72, align 8, !tbaa !20
  %74 = getelementptr inbounds float, ptr %73, i64 1
  store float %70, ptr %74, align 4, !tbaa !9
  %75 = load float, ptr @theta_av, align 4, !tbaa !9
  %76 = fpext float %75 to double
  %77 = call double @sin(double noundef %76) #4
  %78 = fneg double %77
  %79 = fptrunc double %78 to float
  %80 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %81 = getelementptr inbounds ptr, ptr %80, i64 0
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  %83 = getelementptr inbounds float, ptr %82, i64 2
  store float %79, ptr %83, align 4, !tbaa !9
  %84 = load float, ptr @phi_av, align 4, !tbaa !9
  %85 = fpext float %84 to double
  %86 = call double @sin(double noundef %85) #4
  %87 = load float, ptr @theta_av, align 4, !tbaa !9
  %88 = fpext float %87 to double
  %89 = call double @sin(double noundef %88) #4
  %90 = fmul double %86, %89
  %91 = load float, ptr @psi_av, align 4, !tbaa !9
  %92 = fpext float %91 to double
  %93 = call double @cos(double noundef %92) #4
  %94 = load float, ptr @phi_av, align 4, !tbaa !9
  %95 = fpext float %94 to double
  %96 = call double @cos(double noundef %95) #4
  %97 = load float, ptr @psi_av, align 4, !tbaa !9
  %98 = fpext float %97 to double
  %99 = call double @sin(double noundef %98) #4
  %100 = fmul double %96, %99
  %101 = fneg double %100
  %102 = call double @llvm.fmuladd.f64(double %90, double %93, double %101)
  %103 = fptrunc double %102 to float
  %104 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %105 = getelementptr inbounds ptr, ptr %104, i64 1
  %106 = load ptr, ptr %105, align 8, !tbaa !20
  %107 = getelementptr inbounds float, ptr %106, i64 0
  store float %103, ptr %107, align 4, !tbaa !9
  %108 = load float, ptr @phi_av, align 4, !tbaa !9
  %109 = fpext float %108 to double
  %110 = call double @sin(double noundef %109) #4
  %111 = load float, ptr @theta_av, align 4, !tbaa !9
  %112 = fpext float %111 to double
  %113 = call double @sin(double noundef %112) #4
  %114 = fmul double %110, %113
  %115 = load float, ptr @psi_av, align 4, !tbaa !9
  %116 = fpext float %115 to double
  %117 = call double @sin(double noundef %116) #4
  %118 = load float, ptr @phi_av, align 4, !tbaa !9
  %119 = fpext float %118 to double
  %120 = call double @cos(double noundef %119) #4
  %121 = load float, ptr @psi_av, align 4, !tbaa !9
  %122 = fpext float %121 to double
  %123 = call double @cos(double noundef %122) #4
  %124 = fmul double %120, %123
  %125 = call double @llvm.fmuladd.f64(double %114, double %117, double %124)
  %126 = fptrunc double %125 to float
  %127 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %128 = getelementptr inbounds ptr, ptr %127, i64 1
  %129 = load ptr, ptr %128, align 8, !tbaa !20
  %130 = getelementptr inbounds float, ptr %129, i64 1
  store float %126, ptr %130, align 4, !tbaa !9
  %131 = load float, ptr @phi_av, align 4, !tbaa !9
  %132 = fpext float %131 to double
  %133 = call double @sin(double noundef %132) #4
  %134 = load float, ptr @theta_av, align 4, !tbaa !9
  %135 = fpext float %134 to double
  %136 = call double @cos(double noundef %135) #4
  %137 = fmul double %133, %136
  %138 = fptrunc double %137 to float
  %139 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %140 = getelementptr inbounds ptr, ptr %139, i64 1
  %141 = load ptr, ptr %140, align 8, !tbaa !20
  %142 = getelementptr inbounds float, ptr %141, i64 2
  store float %138, ptr %142, align 4, !tbaa !9
  %143 = load float, ptr @phi_av, align 4, !tbaa !9
  %144 = fpext float %143 to double
  %145 = call double @cos(double noundef %144) #4
  %146 = load float, ptr @theta_av, align 4, !tbaa !9
  %147 = fpext float %146 to double
  %148 = call double @sin(double noundef %147) #4
  %149 = fmul double %145, %148
  %150 = load float, ptr @psi_av, align 4, !tbaa !9
  %151 = fpext float %150 to double
  %152 = call double @cos(double noundef %151) #4
  %153 = load float, ptr @phi_av, align 4, !tbaa !9
  %154 = fpext float %153 to double
  %155 = call double @sin(double noundef %154) #4
  %156 = load float, ptr @psi_av, align 4, !tbaa !9
  %157 = fpext float %156 to double
  %158 = call double @sin(double noundef %157) #4
  %159 = fmul double %155, %158
  %160 = call double @llvm.fmuladd.f64(double %149, double %152, double %159)
  %161 = fptrunc double %160 to float
  %162 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %163 = getelementptr inbounds ptr, ptr %162, i64 2
  %164 = load ptr, ptr %163, align 8, !tbaa !20
  %165 = getelementptr inbounds float, ptr %164, i64 0
  store float %161, ptr %165, align 4, !tbaa !9
  %166 = load float, ptr @phi_av, align 4, !tbaa !9
  %167 = fpext float %166 to double
  %168 = call double @cos(double noundef %167) #4
  %169 = load float, ptr @theta_av, align 4, !tbaa !9
  %170 = fpext float %169 to double
  %171 = call double @sin(double noundef %170) #4
  %172 = fmul double %168, %171
  %173 = load float, ptr @psi_av, align 4, !tbaa !9
  %174 = fpext float %173 to double
  %175 = call double @sin(double noundef %174) #4
  %176 = load float, ptr @phi_av, align 4, !tbaa !9
  %177 = fpext float %176 to double
  %178 = call double @sin(double noundef %177) #4
  %179 = load float, ptr @psi_av, align 4, !tbaa !9
  %180 = fpext float %179 to double
  %181 = call double @cos(double noundef %180) #4
  %182 = fmul double %178, %181
  %183 = fneg double %182
  %184 = call double @llvm.fmuladd.f64(double %172, double %175, double %183)
  %185 = fptrunc double %184 to float
  %186 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %187 = getelementptr inbounds ptr, ptr %186, i64 2
  %188 = load ptr, ptr %187, align 8, !tbaa !20
  %189 = getelementptr inbounds float, ptr %188, i64 1
  store float %185, ptr %189, align 4, !tbaa !9
  %190 = load float, ptr @phi_av, align 4, !tbaa !9
  %191 = fpext float %190 to double
  %192 = call double @cos(double noundef %191) #4
  %193 = load float, ptr @theta_av, align 4, !tbaa !9
  %194 = fpext float %193 to double
  %195 = call double @cos(double noundef %194) #4
  %196 = fmul double %192, %195
  %197 = fptrunc double %196 to float
  %198 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @R_MATRIX, i32 0, i32 2), align 8, !tbaa !17
  %199 = getelementptr inbounds ptr, ptr %198, i64 2
  %200 = load ptr, ptr %199, align 8, !tbaa !20
  %201 = getelementptr inbounds float, ptr %200, i64 2
  store float %197, ptr %201, align 4, !tbaa !9
  ret void
}

; Function Attrs: nounwind
declare i32 @gettimeofday(ptr noundef, ptr noundef) #2

declare void @check_time(ptr noundef, i64, i64, i64, i64, ptr noundef) #1

declare void @passive_wait(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nounwind "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 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 #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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !19, i64 16}
!18 = !{!"MATRIX", !14, i64 0, !14, i64 8, !19, i64 16}
!19 = !{!"any pointer", !7, i64 0}
!20 = !{!19, !19, i64 0}


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

@psi_av = external dso_local local_unnamed_addr global float, align 4
@theta_av = external dso_local local_unnamed_addr global float, align 4
@phi_av = external dso_local local_unnamed_addr global float, align 4
@num_av_vars = external dso_local local_unnamed_addr global i32, align 4
@time_imu = external dso_local global i64, align 8
@psi_save = external dso_local local_unnamed_addr global float, align 4
@theta_save = external dso_local local_unnamed_addr global float, align 4
@phi_save = external dso_local local_unnamed_addr global float, align 4
@R_MATRIX = external dso_local local_unnamed_addr global %struct.MATRIX, align 8
@before_loop = external dso_local global %struct.timeval, align 8
@before_imu = external dso_local global %struct.timeval, align 8
@now_loop = external dso_local global %struct.timeval, align 8
@elapsed_loop = external dso_local local_unnamed_addr global %struct.timeval, align 8
@time_loop = external dso_local global i64, align 8
@now_imu = external dso_local global %struct.timeval, align 8
@elapsed_imu = external dso_local global %struct.timeval, align 8
@IMU__READ_TIMESTEP = external local_unnamed_addr global i64, align 8
@psi = external dso_local local_unnamed_addr global float, align 4
@theta = external dso_local local_unnamed_addr global float, align 4
@phi = external dso_local local_unnamed_addr global float, align 4
@.str.8 = external hidden unnamed_addr constant [54 x i8], align 1
@CALIB__TIME = external local_unnamed_addr global i64, align 8

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local float @TO_DEG(float noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @Calibrate_IMU() local_unnamed_addr #3 {
  %1 = tail call i32 @gettimeofday(ptr noundef nonnull @before_loop, ptr noundef null) #5
  %2 = tail call i32 @gettimeofday(ptr noundef nonnull @before_imu, ptr noundef null) #5
  br label %3

3:                                                ; preds = %3, %0
  %4 = load i64, ptr @before_loop, align 8
  %5 = load i64, ptr getelementptr inbounds (i8, ptr @before_loop, i64 8), align 8
  %6 = load i64, ptr @elapsed_loop, align 8
  %7 = load i64, ptr getelementptr inbounds (i8, ptr @elapsed_loop, i64 8), align 8
  tail call void @check_time(ptr noundef nonnull @now_loop, i64 %4, i64 %5, i64 %6, i64 %7, ptr noundef nonnull @time_loop) #5
  %8 = load i64, ptr @IMU__READ_TIMESTEP, align 8, !tbaa !5
  tail call void @passive_wait(ptr noundef nonnull @now_imu, ptr noundef nonnull @before_imu, ptr noundef nonnull @elapsed_imu, ptr noundef nonnull @time_imu, i64 noundef %8) #5
  %9 = load float, ptr @psi, align 4, !tbaa !9
  store float %9, ptr @psi_save, align 4, !tbaa !9
  %10 = load float, ptr @theta, align 4, !tbaa !9
  store float %10, ptr @theta_save, align 4, !tbaa !9
  %11 = load float, ptr @phi, align 4, !tbaa !9
  store float %11, ptr @phi_save, align 4, !tbaa !9
  %12 = load float, ptr @psi_av, align 4, !tbaa !9
  %13 = fadd float %9, %12
  store float %13, ptr @psi_av, align 4, !tbaa !9
  %14 = load float, ptr @theta_av, align 4, !tbaa !9
  %15 = fadd float %10, %14
  store float %15, ptr @theta_av, align 4, !tbaa !9
  %16 = load float, ptr @phi_av, align 4, !tbaa !9
  %17 = fadd float %11, %16
  store float %17, ptr @phi_av, align 4, !tbaa !9
  %18 = load i32, ptr @num_av_vars, align 4, !tbaa !11
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr @num_av_vars, align 4, !tbaa !11
  %20 = load i64, ptr @time_imu, align 8, !tbaa !5
  %21 = tail call float @TO_DEG(float noundef %9)
  %22 = fpext float %21 to double
  %23 = load float, ptr @theta, align 4, !tbaa !9
  %24 = tail call float @TO_DEG(float noundef %23)
  %25 = fpext float %24 to double
  %26 = load float, ptr @phi, align 4, !tbaa !9
  %27 = tail call float @TO_DEG(float noundef %26)
  %28 = fpext float %27 to double
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %20, double noundef %22, double noundef %25, double noundef %28)
  %30 = load i64, ptr @time_loop, align 8, !tbaa !5
  %31 = load i64, ptr @CALIB__TIME, align 8, !tbaa !13
  %.not = icmp ugt i64 %30, %31
  br i1 %.not, label %32, label %3, !llvm.loop !15

32:                                               ; preds = %3
  %33 = load float, ptr @psi_av, align 4, !tbaa !9
  %34 = load i32, ptr @num_av_vars, align 4, !tbaa !11
  %35 = sitofp i32 %34 to float
  %36 = fdiv float %33, %35
  store float %36, ptr @psi_av, align 4, !tbaa !9
  %37 = load float, ptr @theta_av, align 4, !tbaa !9
  %38 = fdiv float %37, %35
  store float %38, ptr @theta_av, align 4, !tbaa !9
  %39 = load float, ptr @phi_av, align 4, !tbaa !9
  %40 = fdiv float %39, %35
  store float %40, ptr @phi_av, align 4, !tbaa !9
  %41 = fpext float %38 to double
  %42 = tail call double @cos(double noundef %41) #5
  %43 = load float, ptr @psi_av, align 4, !tbaa !9
  %44 = fpext float %43 to double
  %45 = tail call double @cos(double noundef %44) #5
  %46 = fmul double %42, %45
  %47 = fptrunc double %46 to float
  %48 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  store float %47, ptr %49, align 4, !tbaa !9
  %50 = load float, ptr @theta_av, align 4, !tbaa !9
  %51 = fpext float %50 to double
  %52 = tail call double @cos(double noundef %51) #5
  %53 = load float, ptr @psi_av, align 4, !tbaa !9
  %54 = fpext float %53 to double
  %55 = tail call double @sin(double noundef %54) #5
  %56 = fmul double %52, %55
  %57 = fptrunc double %56 to float
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %59 = load ptr, ptr %58, align 8, !tbaa !20
  %60 = getelementptr inbounds i8, ptr %59, i64 4
  store float %57, ptr %60, align 4, !tbaa !9
  %61 = load float, ptr @theta_av, align 4, !tbaa !9
  %62 = fpext float %61 to double
  %63 = tail call double @sin(double noundef %62) #5
  %64 = fptrunc double %63 to float
  %65 = fneg float %64
  %66 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %67 = load ptr, ptr %66, align 8, !tbaa !20
  %68 = getelementptr inbounds i8, ptr %67, i64 8
  store float %65, ptr %68, align 4, !tbaa !9
  %69 = load float, ptr @phi_av, align 4, !tbaa !9
  %70 = fpext float %69 to double
  %71 = tail call double @sin(double noundef %70) #5
  %72 = load float, ptr @theta_av, align 4, !tbaa !9
  %73 = fpext float %72 to double
  %74 = tail call double @sin(double noundef %73) #5
  %75 = fmul double %71, %74
  %76 = load float, ptr @psi_av, align 4, !tbaa !9
  %77 = fpext float %76 to double
  %78 = tail call double @cos(double noundef %77) #5
  %79 = load float, ptr @phi_av, align 4, !tbaa !9
  %80 = fpext float %79 to double
  %81 = tail call double @cos(double noundef %80) #5
  %82 = load float, ptr @psi_av, align 4, !tbaa !9
  %83 = fpext float %82 to double
  %84 = tail call double @sin(double noundef %83) #5
  %85 = fneg double %81
  %86 = fmul double %84, %85
  %87 = tail call double @llvm.fmuladd.f64(double %75, double %78, double %86)
  %88 = fptrunc double %87 to float
  %89 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %90 = getelementptr inbounds i8, ptr %89, i64 8
  %91 = load ptr, ptr %90, align 8, !tbaa !20
  store float %88, ptr %91, align 4, !tbaa !9
  %92 = load float, ptr @phi_av, align 4, !tbaa !9
  %93 = fpext float %92 to double
  %94 = tail call double @sin(double noundef %93) #5
  %95 = load float, ptr @theta_av, align 4, !tbaa !9
  %96 = fpext float %95 to double
  %97 = tail call double @sin(double noundef %96) #5
  %98 = fmul double %94, %97
  %99 = load float, ptr @psi_av, align 4, !tbaa !9
  %100 = fpext float %99 to double
  %101 = tail call double @sin(double noundef %100) #5
  %102 = load float, ptr @phi_av, align 4, !tbaa !9
  %103 = fpext float %102 to double
  %104 = tail call double @cos(double noundef %103) #5
  %105 = load float, ptr @psi_av, align 4, !tbaa !9
  %106 = fpext float %105 to double
  %107 = tail call double @cos(double noundef %106) #5
  %108 = fmul double %104, %107
  %109 = tail call double @llvm.fmuladd.f64(double %98, double %101, double %108)
  %110 = fptrunc double %109 to float
  %111 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %112 = getelementptr inbounds i8, ptr %111, i64 8
  %113 = load ptr, ptr %112, align 8, !tbaa !20
  %114 = getelementptr inbounds i8, ptr %113, i64 4
  store float %110, ptr %114, align 4, !tbaa !9
  %115 = load float, ptr @phi_av, align 4, !tbaa !9
  %116 = fpext float %115 to double
  %117 = tail call double @sin(double noundef %116) #5
  %118 = load float, ptr @theta_av, align 4, !tbaa !9
  %119 = fpext float %118 to double
  %120 = tail call double @cos(double noundef %119) #5
  %121 = fmul double %117, %120
  %122 = fptrunc double %121 to float
  %123 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %124 = getelementptr inbounds i8, ptr %123, i64 8
  %125 = load ptr, ptr %124, align 8, !tbaa !20
  %126 = getelementptr inbounds i8, ptr %125, i64 8
  store float %122, ptr %126, align 4, !tbaa !9
  %127 = load float, ptr @phi_av, align 4, !tbaa !9
  %128 = fpext float %127 to double
  %129 = tail call double @cos(double noundef %128) #5
  %130 = load float, ptr @theta_av, align 4, !tbaa !9
  %131 = fpext float %130 to double
  %132 = tail call double @sin(double noundef %131) #5
  %133 = fmul double %129, %132
  %134 = load float, ptr @psi_av, align 4, !tbaa !9
  %135 = fpext float %134 to double
  %136 = tail call double @cos(double noundef %135) #5
  %137 = load float, ptr @phi_av, align 4, !tbaa !9
  %138 = fpext float %137 to double
  %139 = tail call double @sin(double noundef %138) #5
  %140 = load float, ptr @psi_av, align 4, !tbaa !9
  %141 = fpext float %140 to double
  %142 = tail call double @sin(double noundef %141) #5
  %143 = fmul double %139, %142
  %144 = tail call double @llvm.fmuladd.f64(double %133, double %136, double %143)
  %145 = fptrunc double %144 to float
  %146 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %147 = getelementptr inbounds i8, ptr %146, i64 16
  %148 = load ptr, ptr %147, align 8, !tbaa !20
  store float %145, ptr %148, align 4, !tbaa !9
  %149 = load float, ptr @phi_av, align 4, !tbaa !9
  %150 = fpext float %149 to double
  %151 = tail call double @cos(double noundef %150) #5
  %152 = load float, ptr @theta_av, align 4, !tbaa !9
  %153 = fpext float %152 to double
  %154 = tail call double @sin(double noundef %153) #5
  %155 = fmul double %151, %154
  %156 = load float, ptr @psi_av, align 4, !tbaa !9
  %157 = fpext float %156 to double
  %158 = tail call double @sin(double noundef %157) #5
  %159 = load float, ptr @phi_av, align 4, !tbaa !9
  %160 = fpext float %159 to double
  %161 = tail call double @sin(double noundef %160) #5
  %162 = load float, ptr @psi_av, align 4, !tbaa !9
  %163 = fpext float %162 to double
  %164 = tail call double @cos(double noundef %163) #5
  %165 = fneg double %161
  %166 = fmul double %164, %165
  %167 = tail call double @llvm.fmuladd.f64(double %155, double %158, double %166)
  %168 = fptrunc double %167 to float
  %169 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %170 = getelementptr inbounds i8, ptr %169, i64 16
  %171 = load ptr, ptr %170, align 8, !tbaa !20
  %172 = getelementptr inbounds i8, ptr %171, i64 4
  store float %168, ptr %172, align 4, !tbaa !9
  %173 = load float, ptr @phi_av, align 4, !tbaa !9
  %174 = fpext float %173 to double
  %175 = tail call double @cos(double noundef %174) #5
  %176 = load float, ptr @theta_av, align 4, !tbaa !9
  %177 = fpext float %176 to double
  %178 = tail call double @cos(double noundef %177) #5
  %179 = fmul double %175, %178
  %180 = fptrunc double %179 to float
  %181 = load ptr, ptr getelementptr inbounds (i8, ptr @R_MATRIX, i64 16), align 8, !tbaa !17
  %182 = getelementptr inbounds i8, ptr %181, i64 16
  %183 = load ptr, ptr %182, align 8, !tbaa !20
  %184 = getelementptr inbounds i8, ptr %183, i64 8
  store float %180, ptr %184, align 4, !tbaa !9
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @gettimeofday(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

declare void @check_time(ptr noundef, i64, i64, i64, i64, ptr noundef) local_unnamed_addr #4

declare void @passive_wait(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree nounwind "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 nofree nounwind willreturn memory(write) "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 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 #4 = { "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 #5 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !19, i64 16}
!18 = !{!"MATRIX", !14, i64 0, !14, i64 8, !19, i64 16}
!19 = !{!"any pointer", !7, i64 0}
!20 = !{!19, !19, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SimplifyCFGPass,TailCallElimPass