; LLVM IR from robinrodricks/InspiritImage :: Inspirit.Assurf/clib/rpp (rpp)

; 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.vec3_t = type { [3 x double] }

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

declare double @_abs(double noundef) #1

declare void @vec3_assign(ptr noundef, double noundef, double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @rpyAng_X(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  call void @rpyAng(ptr noundef %5, ptr noundef %6)
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.vec3_t, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds [3 x double], ptr %8, i64 0, i64 0
  %10 = load double, ptr %9, align 8, !tbaa !9
  %11 = call double @_abs(double noundef %10)
  %12 = fcmp ogt double %11, 0x3FF921FB54442D18
  br i1 %12, label %13, label %64

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %62, %13
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.vec3_t, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = call double @_abs(double noundef %18)
  %20 = fcmp ogt double %19, 0x3FF921FB54442D18
  br i1 %20, label %21, label %63

21:                                               ; preds = %14
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.vec3_t, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [3 x double], ptr %23, i64 0, i64 0
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = fcmp ogt double %25, 0.000000e+00
  br i1 %26, label %27, label %45

27:                                               ; preds = %21
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.vec3_t, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds [3 x double], ptr %30, i64 0, i64 0
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = fadd double %32, 0x400921FB54442D18
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.vec3_t, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds [3 x double], ptr %35, i64 0, i64 1
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = fsub double 0x4022D97C7F3321D2, %37
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.vec3_t, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds [3 x double], ptr %40, i64 0, i64 2
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = fadd double %42, 0x400921FB54442D18
  call void @vec3_assign(ptr noundef %28, double noundef %33, double noundef %38, double noundef %43)
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  call void @vec3_sub(ptr noundef %44, double noundef 0x4018EEC82110F9E5)
  br label %62

45:                                               ; preds = %21
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.vec3_t, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds [3 x double], ptr %48, i64 0, i64 0
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = fadd double %50, 0x400921FB54442D18
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.vec3_t, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds [3 x double], ptr %53, i64 0, i64 1
  %55 = load double, ptr %54, align 8, !tbaa !9
  %56 = fsub double 0x4022D97C7F3321D2, %55
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.vec3_t, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [3 x double], ptr %58, i64 0, i64 2
  %60 = load double, ptr %59, align 8, !tbaa !9
  %61 = fadd double %60, 0x400921FB54442D18
  call void @vec3_assign(ptr noundef %46, double noundef %51, double noundef %56, double noundef %61)
  br label %62

62:                                               ; preds = %45, %27
  br label %14, !llvm.loop !11

63:                                               ; preds = %14
  br label %64

64:                                               ; preds = %63, %2
  ret void
}

declare void @vec3_sub(ptr noundef, double noundef) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

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

declare double @_abs(double noundef) local_unnamed_addr #1

declare void @vec3_assign(ptr noundef, double noundef, double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @rpyAng_X(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @rpyAng(ptr noundef %0, ptr noundef %1)
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = tail call double @_abs(double noundef %3) #2
  %5 = fcmp ogt double %4, 0x3FF921FB54442D18
  br i1 %5, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %6 = load double, ptr %0, align 8, !tbaa !5
  %7 = tail call double @_abs(double noundef %6) #2
  %8 = fcmp ogt double %7, 0x3FF921FB54442D18
  br i1 %8, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  br label %11

11:                                               ; preds = %.lr.ph, %20
  %12 = load double, ptr %0, align 8, !tbaa !5
  %13 = fcmp ogt double %12, 0.000000e+00
  %14 = fadd double %12, 0x400921FB54442D18
  %15 = load double, ptr %9, align 8, !tbaa !5
  %16 = fsub double 0x4022D97C7F3321D2, %15
  %17 = load double, ptr %10, align 8, !tbaa !5
  %18 = fadd double %17, 0x400921FB54442D18
  tail call void @vec3_assign(ptr noundef nonnull %0, double noundef %14, double noundef %16, double noundef %18) #2
  br i1 %13, label %19, label %20

19:                                               ; preds = %11
  tail call void @vec3_sub(ptr noundef nonnull %0, double noundef 0x4018EEC82110F9E5) #2
  br label %20

20:                                               ; preds = %11, %19
  %21 = load double, ptr %0, align 8, !tbaa !5
  %22 = tail call double @_abs(double noundef %21) #2
  %23 = fcmp ogt double %22, 0x3FF921FB54442D18
  br i1 %23, label %11, label %.loopexit, !llvm.loop !9

.loopexit:                                        ; preds = %20, %.preheader, %2
  ret void
}

declare void @vec3_sub(ptr noundef, double noundef) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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