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

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

@psi_save_last = external dso_local global float, align 4
@theta_save_last = external dso_local global float, align 4
@phi_save_last = external dso_local global float, align 4
@time_imu = external dso_local global i64, align 8
@dt = external dso_local global float, align 4
@psi_save = external dso_local global float, align 4
@psi_dot = external dso_local global float, align 4
@theta_save = external dso_local global float, align 4
@theta_dot = external dso_local global float, align 4
@phi_save = external dso_local global float, align 4
@phi_dot = external dso_local global float, align 4
@before_imu = external dso_local global %struct.timeval, 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
@accelX = external dso_local global float, align 4
@accelY = external dso_local global float, align 4
@accelZ = external dso_local global float, align 4
@IMU_quit = external global i8, align 1
@imu_log = external global ptr, align 8
@.str.22 = external hidden unnamed_addr constant [226 x i8], align 1
@error_log = external global ptr, align 8
@now_imu_glob = external dso_local global %struct.timeval, align 8
@GLOBAL__TIME_STARTPOINT = external dso_local global %struct.timeval, align 8
@elapsed_imu_glob = external dso_local global %struct.timeval, align 8
@time_imu_glob = external dso_local global i64, align 8
@accelX_save = external dso_local global float, align 4
@accelY_save = external dso_local global float, align 4
@accelZ_save = external dso_local global float, align 4
@x_psi = external dso_local global %struct.MATRIX, align 8
@P_psi = external dso_local global %struct.MATRIX, align 8
@Q_psi = external dso_local global %struct.MATRIX, align 8
@R_psi = external dso_local global %struct.MATRIX, align 8
@EYE2 = external dso_local global %struct.MATRIX, align 8
@x_psidot = external dso_local global %struct.MATRIX, align 8
@P_psidot = external dso_local global %struct.MATRIX, align 8
@Q_psidot = external dso_local global %struct.MATRIX, align 8
@R_psidot = external dso_local global %struct.MATRIX, align 8
@x_theta = external dso_local global %struct.MATRIX, align 8
@P_theta = external dso_local global %struct.MATRIX, align 8
@Q_theta = external dso_local global %struct.MATRIX, align 8
@R_theta = external dso_local global %struct.MATRIX, align 8
@x_thetadot = external dso_local global %struct.MATRIX, align 8
@P_thetadot = external dso_local global %struct.MATRIX, align 8
@Q_thetadot = external dso_local global %struct.MATRIX, align 8
@R_thetadot = external dso_local global %struct.MATRIX, align 8
@x_phi = external dso_local global %struct.MATRIX, align 8
@P_phi = external dso_local global %struct.MATRIX, align 8
@Q_phi = external dso_local global %struct.MATRIX, align 8
@R_phi = external dso_local global %struct.MATRIX, align 8
@x_phidot = external dso_local global %struct.MATRIX, align 8
@P_phidot = external dso_local global %struct.MATRIX, align 8
@Q_phidot = external dso_local global %struct.MATRIX, align 8
@R_phidot = external dso_local global %struct.MATRIX, align 8
@psi_filt = external dso_local global float, align 4
@psi_dot_filt = external dso_local global float, align 4
@theta_filt = external dso_local global float, align 4
@theta_dot_filt = external dso_local global float, align 4
@phi_filt = external dso_local global float, align 4
@phi_dot_filt = external dso_local global float, align 4
@wx = external dso_local global float, align 4
@wy = external dso_local global float, align 4
@wz = external dso_local global float, align 4
@.str.23 = external hidden unnamed_addr constant [101 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [29 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Find_raw_Euler_angular_velocities() #2

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @construct_zeroed_DCM() #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @zero_Euler_angles() #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Kalman_filter(ptr noundef, ptr noundef, float noundef, ptr noundef byval(%struct.MATRIX) align 8, ptr noundef byval(%struct.MATRIX) align 8, float noundef, ptr noundef byval(%struct.MATRIX) align 8) #2

; Function Attrs: noreturn
declare void @pthread_exit(ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local ptr @get_filtered_attitude_parallel(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca [200 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 200, ptr %3) #6
  %4 = load ptr, ptr @imu_log, align 8, !tbaa !5
  %5 = load ptr, ptr @error_log, align 8, !tbaa !5
  call void @write_to_file_custom(ptr noundef %4, ptr noundef @.str.22, ptr noundef %5)
  %6 = call i32 @gettimeofday(ptr noundef @before_imu, ptr noundef null) #6
  br label %7

7:                                                ; preds = %153, %1
  %8 = load i64, ptr @GLOBAL__TIME_STARTPOINT, align 8
  %9 = load i64, ptr getelementptr inbounds ({ i64, i64 }, ptr @GLOBAL__TIME_STARTPOINT, i32 0, i32 1), align 8
  %10 = load i64, ptr @elapsed_imu_glob, align 8
  %11 = load i64, ptr getelementptr inbounds ({ i64, i64 }, ptr @elapsed_imu_glob, i32 0, i32 1), align 8
  call void @check_time(ptr noundef @now_imu_glob, i64 %8, i64 %9, i64 %10, i64 %11, ptr noundef @time_imu_glob)
  %12 = load i64, ptr @IMU__READ_TIMESTEP, align 8, !tbaa !9
  call void @passive_wait(ptr noundef @now_imu, ptr noundef @before_imu, ptr noundef @elapsed_imu, ptr noundef @time_imu, i64 noundef %12)
  %13 = load float, ptr @psi, align 4, !tbaa !11
  store float %13, ptr @psi_save, align 4, !tbaa !11
  %14 = load float, ptr @theta, align 4, !tbaa !11
  store float %14, ptr @theta_save, align 4, !tbaa !11
  %15 = load float, ptr @phi, align 4, !tbaa !11
  store float %15, ptr @phi_save, align 4, !tbaa !11
  %16 = load float, ptr @accelX, align 4, !tbaa !11
  store float %16, ptr @accelX_save, align 4, !tbaa !11
  %17 = load float, ptr @accelY, align 4, !tbaa !11
  store float %17, ptr @accelY_save, align 4, !tbaa !11
  %18 = load float, ptr @accelZ, align 4, !tbaa !11
  store float %18, ptr @accelZ_save, align 4, !tbaa !11
  call void @construct_zeroed_DCM()
  call void @zero_Euler_angles()
  call void @Find_raw_Euler_angular_velocities()
  %19 = load float, ptr @psi_save, align 4, !tbaa !11
  store float %19, ptr @psi_save_last, align 4, !tbaa !11
  %20 = load float, ptr @theta_save, align 4, !tbaa !11
  store float %20, ptr @theta_save_last, align 4, !tbaa !11
  %21 = load float, ptr @phi_save, align 4, !tbaa !11
  store float %21, ptr @phi_save_last, align 4, !tbaa !11
  %22 = load float, ptr @psi_save, align 4, !tbaa !11
  %23 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef @x_psi, ptr noundef @P_psi, float noundef %22, ptr noundef byval(%struct.MATRIX) align 8 @Q_psi, ptr noundef byval(%struct.MATRIX) align 8 @R_psi, float noundef %23, ptr noundef byval(%struct.MATRIX) align 8 @EYE2)
  %24 = load float, ptr @psi_dot, align 4, !tbaa !11
  %25 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef @x_psidot, ptr noundef @P_psidot, float noundef %24, ptr noundef byval(%struct.MATRIX) align 8 @Q_psidot, ptr noundef byval(%struct.MATRIX) align 8 @R_psidot, float noundef %25, ptr noundef byval(%struct.MATRIX) align 8 @EYE2)
  %26 = load float, ptr @theta_save, align 4, !tbaa !11
  %27 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef @x_theta, ptr noundef @P_theta, float noundef %26, ptr noundef byval(%struct.MATRIX) align 8 @Q_theta, ptr noundef byval(%struct.MATRIX) align 8 @R_theta, float noundef %27, ptr noundef byval(%struct.MATRIX) align 8 @EYE2)
  %28 = load float, ptr @theta_dot, align 4, !tbaa !11
  %29 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef @x_thetadot, ptr noundef @P_thetadot, float noundef %28, ptr noundef byval(%struct.MATRIX) align 8 @Q_thetadot, ptr noundef byval(%struct.MATRIX) align 8 @R_thetadot, float noundef %29, ptr noundef byval(%struct.MATRIX) align 8 @EYE2)
  %30 = load float, ptr @phi_save, align 4, !tbaa !11
  %31 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef @x_phi, ptr noundef @P_phi, float noundef %30, ptr noundef byval(%struct.MATRIX) align 8 @Q_phi, ptr noundef byval(%struct.MATRIX) align 8 @R_phi, float noundef %31, ptr noundef byval(%struct.MATRIX) align 8 @EYE2)
  %32 = load float, ptr @phi_dot, align 4, !tbaa !11
  %33 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef @x_phidot, ptr noundef @P_phidot, float noundef %32, ptr noundef byval(%struct.MATRIX) align 8 @Q_phidot, ptr noundef byval(%struct.MATRIX) align 8 @R_phidot, float noundef %33, ptr noundef byval(%struct.MATRIX) align 8 @EYE2)
  %34 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @x_psi, i32 0, i32 2), align 8, !tbaa !13
  %35 = getelementptr inbounds ptr, ptr %34, i64 0
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds float, ptr %36, i64 0
  %38 = load float, ptr %37, align 4, !tbaa !11
  store float %38, ptr @psi_filt, align 4, !tbaa !11
  %39 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @x_psidot, i32 0, i32 2), align 8, !tbaa !13
  %40 = getelementptr inbounds ptr, ptr %39, i64 0
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds float, ptr %41, i64 0
  %43 = load float, ptr %42, align 4, !tbaa !11
  store float %43, ptr @psi_dot_filt, align 4, !tbaa !11
  %44 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @x_theta, i32 0, i32 2), align 8, !tbaa !13
  %45 = getelementptr inbounds ptr, ptr %44, i64 0
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds float, ptr %46, i64 0
  %48 = load float, ptr %47, align 4, !tbaa !11
  store float %48, ptr @theta_filt, align 4, !tbaa !11
  %49 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @x_thetadot, i32 0, i32 2), align 8, !tbaa !13
  %50 = getelementptr inbounds ptr, ptr %49, i64 0
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds float, ptr %51, i64 0
  %53 = load float, ptr %52, align 4, !tbaa !11
  store float %53, ptr @theta_dot_filt, align 4, !tbaa !11
  %54 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @x_phi, i32 0, i32 2), align 8, !tbaa !13
  %55 = getelementptr inbounds ptr, ptr %54, i64 0
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds float, ptr %56, i64 0
  %58 = load float, ptr %57, align 4, !tbaa !11
  store float %58, ptr @phi_filt, align 4, !tbaa !11
  %59 = load ptr, ptr getelementptr inbounds (%struct.MATRIX, ptr @x_phidot, i32 0, i32 2), align 8, !tbaa !13
  %60 = getelementptr inbounds ptr, ptr %59, i64 0
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds float, ptr %61, i64 0
  %63 = load float, ptr %62, align 4, !tbaa !11
  store float %63, ptr @phi_dot_filt, align 4, !tbaa !11
  %64 = load float, ptr @phi_dot_filt, align 4, !tbaa !11
  %65 = fpext float %64 to double
  %66 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %67 = fpext float %66 to double
  %68 = load float, ptr @theta_filt, align 4, !tbaa !11
  %69 = fpext float %68 to double
  %70 = call double @sin(double noundef %69) #6
  %71 = fneg double %67
  %72 = call double @llvm.fmuladd.f64(double %71, double %70, double %65)
  %73 = fptrunc double %72 to float
  store float %73, ptr @wx, align 4, !tbaa !11
  %74 = load float, ptr @theta_dot_filt, align 4, !tbaa !11
  %75 = fpext float %74 to double
  %76 = load float, ptr @phi_filt, align 4, !tbaa !11
  %77 = fpext float %76 to double
  %78 = call double @cos(double noundef %77) #6
  %79 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %80 = fpext float %79 to double
  %81 = load float, ptr @theta_filt, align 4, !tbaa !11
  %82 = fpext float %81 to double
  %83 = call double @cos(double noundef %82) #6
  %84 = fmul double %80, %83
  %85 = load float, ptr @phi_filt, align 4, !tbaa !11
  %86 = fpext float %85 to double
  %87 = call double @sin(double noundef %86) #6
  %88 = fmul double %84, %87
  %89 = call double @llvm.fmuladd.f64(double %75, double %78, double %88)
  %90 = fptrunc double %89 to float
  store float %90, ptr @wy, align 4, !tbaa !11
  %91 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %92 = fpext float %91 to double
  %93 = load float, ptr @theta_filt, align 4, !tbaa !11
  %94 = fpext float %93 to double
  %95 = call double @cos(double noundef %94) #6
  %96 = fmul double %92, %95
  %97 = load float, ptr @phi_filt, align 4, !tbaa !11
  %98 = fpext float %97 to double
  %99 = call double @cos(double noundef %98) #6
  %100 = load float, ptr @theta_dot_filt, align 4, !tbaa !11
  %101 = fpext float %100 to double
  %102 = load float, ptr @phi_filt, align 4, !tbaa !11
  %103 = fpext float %102 to double
  %104 = call double @sin(double noundef %103) #6
  %105 = fmul double %101, %104
  %106 = fneg double %105
  %107 = call double @llvm.fmuladd.f64(double %96, double %99, double %106)
  %108 = fptrunc double %107 to float
  store float %108, ptr @wz, align 4, !tbaa !11
  %109 = getelementptr inbounds [200 x i8], ptr %3, i64 0, i64 0
  %110 = load i64, ptr @time_imu_glob, align 8, !tbaa !9
  %111 = load float, ptr @dt, align 4, !tbaa !11
  %112 = fpext float %111 to double
  %113 = load float, ptr @psi_save, align 4, !tbaa !11
  %114 = fpext float %113 to double
  %115 = load float, ptr @theta_save, align 4, !tbaa !11
  %116 = fpext float %115 to double
  %117 = load float, ptr @phi_save, align 4, !tbaa !11
  %118 = fpext float %117 to double
  %119 = load float, ptr @psi_dot, align 4, !tbaa !11
  %120 = fpext float %119 to double
  %121 = load float, ptr @theta_dot, align 4, !tbaa !11
  %122 = fpext float %121 to double
  %123 = load float, ptr @phi_dot, align 4, !tbaa !11
  %124 = fpext float %123 to double
  %125 = load float, ptr @psi_filt, align 4, !tbaa !11
  %126 = fpext float %125 to double
  %127 = load float, ptr @theta_filt, align 4, !tbaa !11
  %128 = fpext float %127 to double
  %129 = load float, ptr @phi_filt, align 4, !tbaa !11
  %130 = fpext float %129 to double
  %131 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %132 = fpext float %131 to double
  %133 = load float, ptr @theta_dot_filt, align 4, !tbaa !11
  %134 = fpext float %133 to double
  %135 = load float, ptr @phi_dot_filt, align 4, !tbaa !11
  %136 = fpext float %135 to double
  %137 = load float, ptr @wx, align 4, !tbaa !11
  %138 = fpext float %137 to double
  %139 = load float, ptr @wy, align 4, !tbaa !11
  %140 = fpext float %139 to double
  %141 = load float, ptr @wz, align 4, !tbaa !11
  %142 = fpext float %141 to double
  %143 = load float, ptr @accelX_save, align 4, !tbaa !11
  %144 = fpext float %143 to double
  %145 = load float, ptr @accelY_save, align 4, !tbaa !11
  %146 = fpext float %145 to double
  %147 = load float, ptr @accelZ_save, align 4, !tbaa !11
  %148 = fpext float %147 to double
  %149 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %109, ptr noundef @.str.23, i64 noundef %110, double noundef %112, double noundef %114, double noundef %116, double noundef %118, double noundef %120, double noundef %122, double noundef %124, double noundef %126, double noundef %128, double noundef %130, double noundef %132, double noundef %134, double noundef %136, double noundef %138, double noundef %140, double noundef %142, double noundef %144, double noundef %146, double noundef %148) #6
  %150 = load ptr, ptr @imu_log, align 8, !tbaa !5
  %151 = getelementptr inbounds [200 x i8], ptr %3, i64 0, i64 0
  %152 = load ptr, ptr @error_log, align 8, !tbaa !5
  call void @write_to_file_custom(ptr noundef %150, ptr noundef %151, ptr noundef %152)
  br label %153

153:                                              ; preds = %7
  %154 = load i8, ptr @IMU_quit, align 1, !tbaa !16
  %155 = icmp ne i8 %154, 0
  %156 = xor i1 %155, true
  br i1 %156, label %7, label %157, !llvm.loop !17

157:                                              ; preds = %153
  %158 = call i32 (ptr, ...) @printf(ptr noundef @.str.24)
  call void @pthread_exit(ptr noundef null) #7
  unreachable
}

declare void @write_to_file_custom(ptr noundef, ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #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 = { noreturn "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 #6 = { nounwind }
attributes #7 = { noreturn }

!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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"MATRIX", !15, i64 0, !15, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

@psi_save_last = external dso_local local_unnamed_addr global float, align 4
@theta_save_last = external dso_local local_unnamed_addr global float, align 4
@phi_save_last = external dso_local local_unnamed_addr global float, align 4
@time_imu = external dso_local global i64, align 8
@dt = external dso_local local_unnamed_addr global float, align 4
@psi_save = external dso_local local_unnamed_addr global float, align 4
@psi_dot = external dso_local local_unnamed_addr global float, align 4
@theta_save = external dso_local local_unnamed_addr global float, align 4
@theta_dot = external dso_local local_unnamed_addr global float, align 4
@phi_save = external dso_local local_unnamed_addr global float, align 4
@phi_dot = external dso_local local_unnamed_addr global float, align 4
@before_imu = external dso_local global %struct.timeval, 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
@accelX = external dso_local local_unnamed_addr global float, align 4
@accelY = external dso_local local_unnamed_addr global float, align 4
@accelZ = external dso_local local_unnamed_addr global float, align 4
@IMU_quit = external local_unnamed_addr global i8, align 1
@imu_log = external local_unnamed_addr global ptr, align 8
@.str.22 = external hidden unnamed_addr constant [226 x i8], align 1
@error_log = external local_unnamed_addr global ptr, align 8
@now_imu_glob = external dso_local global %struct.timeval, align 8
@GLOBAL__TIME_STARTPOINT = external dso_local local_unnamed_addr global %struct.timeval, align 8
@elapsed_imu_glob = external dso_local local_unnamed_addr global %struct.timeval, align 8
@time_imu_glob = external dso_local global i64, align 8
@accelX_save = external dso_local local_unnamed_addr global float, align 4
@accelY_save = external dso_local local_unnamed_addr global float, align 4
@accelZ_save = external dso_local local_unnamed_addr global float, align 4
@x_psi = external dso_local global %struct.MATRIX, align 8
@P_psi = external dso_local global %struct.MATRIX, align 8
@Q_psi = external dso_local global %struct.MATRIX, align 8
@R_psi = external dso_local global %struct.MATRIX, align 8
@EYE2 = external dso_local global %struct.MATRIX, align 8
@x_psidot = external dso_local global %struct.MATRIX, align 8
@P_psidot = external dso_local global %struct.MATRIX, align 8
@Q_psidot = external dso_local global %struct.MATRIX, align 8
@R_psidot = external dso_local global %struct.MATRIX, align 8
@x_theta = external dso_local global %struct.MATRIX, align 8
@P_theta = external dso_local global %struct.MATRIX, align 8
@Q_theta = external dso_local global %struct.MATRIX, align 8
@R_theta = external dso_local global %struct.MATRIX, align 8
@x_thetadot = external dso_local global %struct.MATRIX, align 8
@P_thetadot = external dso_local global %struct.MATRIX, align 8
@Q_thetadot = external dso_local global %struct.MATRIX, align 8
@R_thetadot = external dso_local global %struct.MATRIX, align 8
@x_phi = external dso_local global %struct.MATRIX, align 8
@P_phi = external dso_local global %struct.MATRIX, align 8
@Q_phi = external dso_local global %struct.MATRIX, align 8
@R_phi = external dso_local global %struct.MATRIX, align 8
@x_phidot = external dso_local global %struct.MATRIX, align 8
@P_phidot = external dso_local global %struct.MATRIX, align 8
@Q_phidot = external dso_local global %struct.MATRIX, align 8
@R_phidot = external dso_local global %struct.MATRIX, align 8
@psi_filt = external dso_local local_unnamed_addr global float, align 4
@psi_dot_filt = external dso_local local_unnamed_addr global float, align 4
@theta_filt = external dso_local local_unnamed_addr global float, align 4
@theta_dot_filt = external dso_local local_unnamed_addr global float, align 4
@phi_filt = external dso_local local_unnamed_addr global float, align 4
@phi_dot_filt = external dso_local local_unnamed_addr global float, align 4
@wx = external dso_local local_unnamed_addr global float, align 4
@wy = external dso_local local_unnamed_addr global float, align 4
@wz = external dso_local local_unnamed_addr global float, align 4
@.str.23 = external hidden unnamed_addr constant [101 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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
declare dso_local void @Find_raw_Euler_angular_velocities() local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @construct_zeroed_DCM() local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @zero_Euler_angles() local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Kalman_filter(ptr noundef, ptr noundef, float noundef, ptr noundef byval(%struct.MATRIX) align 8, ptr noundef byval(%struct.MATRIX) align 8, float noundef, ptr noundef byval(%struct.MATRIX) align 8) local_unnamed_addr #2

; Function Attrs: noreturn
declare void @pthread_exit(ptr noundef) local_unnamed_addr #6

; Function Attrs: noreturn nounwind uwtable
define dso_local noalias noundef nonnull ptr @get_filtered_attitude_parallel(ptr nocapture noundef readnone %0) local_unnamed_addr #7 {
  %2 = alloca [200 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %2) #8
  %3 = load ptr, ptr @imu_log, align 8, !tbaa !5
  %4 = load ptr, ptr @error_log, align 8, !tbaa !5
  tail call void @write_to_file_custom(ptr noundef %3, ptr noundef nonnull @.str.22, ptr noundef %4) #8
  %5 = tail call i32 @gettimeofday(ptr noundef nonnull @before_imu, ptr noundef null) #8
  br label %6

6:                                                ; preds = %6, %1
  %7 = load i64, ptr @GLOBAL__TIME_STARTPOINT, align 8
  %8 = load i64, ptr getelementptr inbounds (i8, ptr @GLOBAL__TIME_STARTPOINT, i64 8), align 8
  %9 = load i64, ptr @elapsed_imu_glob, align 8
  %10 = load i64, ptr getelementptr inbounds (i8, ptr @elapsed_imu_glob, i64 8), align 8
  call void @check_time(ptr noundef nonnull @now_imu_glob, i64 %7, i64 %8, i64 %9, i64 %10, ptr noundef nonnull @time_imu_glob) #8
  %11 = load i64, ptr @IMU__READ_TIMESTEP, align 8, !tbaa !9
  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 %11) #8
  %12 = load float, ptr @psi, align 4, !tbaa !11
  store float %12, ptr @psi_save, align 4, !tbaa !11
  %13 = load float, ptr @theta, align 4, !tbaa !11
  store float %13, ptr @theta_save, align 4, !tbaa !11
  %14 = load float, ptr @phi, align 4, !tbaa !11
  store float %14, ptr @phi_save, align 4, !tbaa !11
  %15 = load float, ptr @accelX, align 4, !tbaa !11
  store float %15, ptr @accelX_save, align 4, !tbaa !11
  %16 = load float, ptr @accelY, align 4, !tbaa !11
  store float %16, ptr @accelY_save, align 4, !tbaa !11
  %17 = load float, ptr @accelZ, align 4, !tbaa !11
  store float %17, ptr @accelZ_save, align 4, !tbaa !11
  call void @construct_zeroed_DCM()
  call void @zero_Euler_angles()
  call void @Find_raw_Euler_angular_velocities()
  %18 = load float, ptr @psi_save, align 4, !tbaa !11
  store float %18, ptr @psi_save_last, align 4, !tbaa !11
  %19 = load float, ptr @theta_save, align 4, !tbaa !11
  store float %19, ptr @theta_save_last, align 4, !tbaa !11
  %20 = load float, ptr @phi_save, align 4, !tbaa !11
  store float %20, ptr @phi_save_last, align 4, !tbaa !11
  %21 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef nonnull @x_psi, ptr noundef nonnull @P_psi, float noundef %18, ptr noundef nonnull byval(%struct.MATRIX) align 8 @Q_psi, ptr noundef nonnull byval(%struct.MATRIX) align 8 @R_psi, float noundef %21, ptr noundef nonnull byval(%struct.MATRIX) align 8 @EYE2)
  %22 = load float, ptr @psi_dot, align 4, !tbaa !11
  %23 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef nonnull @x_psidot, ptr noundef nonnull @P_psidot, float noundef %22, ptr noundef nonnull byval(%struct.MATRIX) align 8 @Q_psidot, ptr noundef nonnull byval(%struct.MATRIX) align 8 @R_psidot, float noundef %23, ptr noundef nonnull byval(%struct.MATRIX) align 8 @EYE2)
  %24 = load float, ptr @theta_save, align 4, !tbaa !11
  %25 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef nonnull @x_theta, ptr noundef nonnull @P_theta, float noundef %24, ptr noundef nonnull byval(%struct.MATRIX) align 8 @Q_theta, ptr noundef nonnull byval(%struct.MATRIX) align 8 @R_theta, float noundef %25, ptr noundef nonnull byval(%struct.MATRIX) align 8 @EYE2)
  %26 = load float, ptr @theta_dot, align 4, !tbaa !11
  %27 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef nonnull @x_thetadot, ptr noundef nonnull @P_thetadot, float noundef %26, ptr noundef nonnull byval(%struct.MATRIX) align 8 @Q_thetadot, ptr noundef nonnull byval(%struct.MATRIX) align 8 @R_thetadot, float noundef %27, ptr noundef nonnull byval(%struct.MATRIX) align 8 @EYE2)
  %28 = load float, ptr @phi_save, align 4, !tbaa !11
  %29 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef nonnull @x_phi, ptr noundef nonnull @P_phi, float noundef %28, ptr noundef nonnull byval(%struct.MATRIX) align 8 @Q_phi, ptr noundef nonnull byval(%struct.MATRIX) align 8 @R_phi, float noundef %29, ptr noundef nonnull byval(%struct.MATRIX) align 8 @EYE2)
  %30 = load float, ptr @phi_dot, align 4, !tbaa !11
  %31 = load float, ptr @dt, align 4, !tbaa !11
  call void @Kalman_filter(ptr noundef nonnull @x_phidot, ptr noundef nonnull @P_phidot, float noundef %30, ptr noundef nonnull byval(%struct.MATRIX) align 8 @Q_phidot, ptr noundef nonnull byval(%struct.MATRIX) align 8 @R_phidot, float noundef %31, ptr noundef nonnull byval(%struct.MATRIX) align 8 @EYE2)
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @x_psi, i64 16), align 8, !tbaa !13
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load float, ptr %33, align 4, !tbaa !11
  store float %34, ptr @psi_filt, align 4, !tbaa !11
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @x_psidot, i64 16), align 8, !tbaa !13
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = load float, ptr %36, align 4, !tbaa !11
  store float %37, ptr @psi_dot_filt, align 4, !tbaa !11
  %38 = load ptr, ptr getelementptr inbounds (i8, ptr @x_theta, i64 16), align 8, !tbaa !13
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load float, ptr %39, align 4, !tbaa !11
  store float %40, ptr @theta_filt, align 4, !tbaa !11
  %41 = load ptr, ptr getelementptr inbounds (i8, ptr @x_thetadot, i64 16), align 8, !tbaa !13
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load float, ptr %42, align 4, !tbaa !11
  store float %43, ptr @theta_dot_filt, align 4, !tbaa !11
  %44 = load ptr, ptr getelementptr inbounds (i8, ptr @x_phi, i64 16), align 8, !tbaa !13
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = load float, ptr %45, align 4, !tbaa !11
  store float %46, ptr @phi_filt, align 4, !tbaa !11
  %47 = load ptr, ptr getelementptr inbounds (i8, ptr @x_phidot, i64 16), align 8, !tbaa !13
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load float, ptr %48, align 4, !tbaa !11
  store float %49, ptr @phi_dot_filt, align 4, !tbaa !11
  %50 = fpext float %49 to double
  %51 = fpext float %37 to double
  %52 = fpext float %40 to double
  %53 = call double @sin(double noundef %52) #8
  %54 = fneg double %51
  %55 = call double @llvm.fmuladd.f64(double %54, double %53, double %50)
  %56 = fptrunc double %55 to float
  store float %56, ptr @wx, align 4, !tbaa !11
  %57 = load float, ptr @theta_dot_filt, align 4, !tbaa !11
  %58 = fpext float %57 to double
  %59 = load float, ptr @phi_filt, align 4, !tbaa !11
  %60 = fpext float %59 to double
  %61 = call double @cos(double noundef %60) #8
  %62 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %63 = fpext float %62 to double
  %64 = load float, ptr @theta_filt, align 4, !tbaa !11
  %65 = fpext float %64 to double
  %66 = call double @cos(double noundef %65) #8
  %67 = fmul double %66, %63
  %68 = load float, ptr @phi_filt, align 4, !tbaa !11
  %69 = fpext float %68 to double
  %70 = call double @sin(double noundef %69) #8
  %71 = fmul double %67, %70
  %72 = call double @llvm.fmuladd.f64(double %58, double %61, double %71)
  %73 = fptrunc double %72 to float
  store float %73, ptr @wy, align 4, !tbaa !11
  %74 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %75 = fpext float %74 to double
  %76 = load float, ptr @theta_filt, align 4, !tbaa !11
  %77 = fpext float %76 to double
  %78 = call double @cos(double noundef %77) #8
  %79 = fmul double %78, %75
  %80 = load float, ptr @phi_filt, align 4, !tbaa !11
  %81 = fpext float %80 to double
  %82 = call double @cos(double noundef %81) #8
  %83 = load float, ptr @theta_dot_filt, align 4, !tbaa !11
  %84 = fpext float %83 to double
  %85 = load float, ptr @phi_filt, align 4, !tbaa !11
  %86 = fpext float %85 to double
  %87 = call double @sin(double noundef %86) #8
  %88 = fneg double %87
  %89 = fmul double %84, %88
  %90 = call double @llvm.fmuladd.f64(double %79, double %82, double %89)
  %91 = fptrunc double %90 to float
  store float %91, ptr @wz, align 4, !tbaa !11
  %92 = load i64, ptr @time_imu_glob, align 8, !tbaa !9
  %93 = load float, ptr @dt, align 4, !tbaa !11
  %94 = fpext float %93 to double
  %95 = load float, ptr @psi_save, align 4, !tbaa !11
  %96 = fpext float %95 to double
  %97 = load float, ptr @theta_save, align 4, !tbaa !11
  %98 = fpext float %97 to double
  %99 = load float, ptr @phi_save, align 4, !tbaa !11
  %100 = fpext float %99 to double
  %101 = load float, ptr @psi_dot, align 4, !tbaa !11
  %102 = fpext float %101 to double
  %103 = load float, ptr @theta_dot, align 4, !tbaa !11
  %104 = fpext float %103 to double
  %105 = load float, ptr @phi_dot, align 4, !tbaa !11
  %106 = fpext float %105 to double
  %107 = load float, ptr @psi_filt, align 4, !tbaa !11
  %108 = fpext float %107 to double
  %109 = load float, ptr @theta_filt, align 4, !tbaa !11
  %110 = fpext float %109 to double
  %111 = load float, ptr @phi_filt, align 4, !tbaa !11
  %112 = fpext float %111 to double
  %113 = load float, ptr @psi_dot_filt, align 4, !tbaa !11
  %114 = fpext float %113 to double
  %115 = load float, ptr @theta_dot_filt, align 4, !tbaa !11
  %116 = fpext float %115 to double
  %117 = load float, ptr @phi_dot_filt, align 4, !tbaa !11
  %118 = fpext float %117 to double
  %119 = load float, ptr @wx, align 4, !tbaa !11
  %120 = fpext float %119 to double
  %121 = load float, ptr @wy, align 4, !tbaa !11
  %122 = fpext float %121 to double
  %123 = fpext float %91 to double
  %124 = load float, ptr @accelX_save, align 4, !tbaa !11
  %125 = fpext float %124 to double
  %126 = load float, ptr @accelY_save, align 4, !tbaa !11
  %127 = fpext float %126 to double
  %128 = load float, ptr @accelZ_save, align 4, !tbaa !11
  %129 = fpext float %128 to double
  %130 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.23, i64 noundef %92, double noundef %94, double noundef %96, double noundef %98, double noundef %100, double noundef %102, double noundef %104, double noundef %106, double noundef %108, double noundef %110, double noundef %112, double noundef %114, double noundef %116, double noundef %118, double noundef %120, double noundef %122, double noundef %123, double noundef %125, double noundef %127, double noundef %129) #8
  %131 = load ptr, ptr @imu_log, align 8, !tbaa !5
  %132 = load ptr, ptr @error_log, align 8, !tbaa !5
  call void @write_to_file_custom(ptr noundef %131, ptr noundef nonnull %2, ptr noundef %132) #8
  %133 = load i8, ptr @IMU_quit, align 1, !tbaa !16
  %.not = icmp eq i8 %133, 0
  br i1 %.not, label %6, label %134, !llvm.loop !17

134:                                              ; preds = %6
  %135 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24)
  call void @pthread_exit(ptr noundef null) #9
  unreachable
}

declare void @write_to_file_custom(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { "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 #6 = { noreturn "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 #7 = { noreturn 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 #8 = { nounwind }
attributes #9 = { noreturn 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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"MATRIX", !15, i64 0, !15, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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