; LLVM IR from AlgoGenesis/C :: Geometric Transformation Algorithm/3D Rotation (About X, Y, or Z Axis) (program)

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

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @rotate(ptr noundef %0, ptr noundef %1, ptr noundef %2, float noundef %3, i8 noundef signext %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca i8, align 1
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store float %3, ptr %9, align 4, !tbaa !9
  store i8 %4, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %15 = load float, ptr %9, align 4, !tbaa !9
  %16 = fpext float %15 to double
  %17 = fmul double %16, 0x3F91DF46A2529D39
  %18 = fptrunc double %17 to float
  store float %18, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 4, !tbaa !12
  store i32 %20, ptr %12, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = load i32, ptr %21, align 4, !tbaa !12
  store i32 %22, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load i32, ptr %23, align 4, !tbaa !12
  store i32 %24, ptr %14, align 4, !tbaa !12
  %25 = load i8, ptr %10, align 1, !tbaa !11
  %26 = sext i8 %25 to i32
  %27 = icmp eq i32 %26, 88
  br i1 %27, label %28, label %62

28:                                               ; preds = %5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = sitofp i32 %30 to double
  %32 = load float, ptr %11, align 4, !tbaa !9
  %33 = fpext float %32 to double
  %34 = call double @cos(double noundef %33) #5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = sitofp i32 %36 to double
  %38 = load float, ptr %11, align 4, !tbaa !9
  %39 = fpext float %38 to double
  %40 = call double @sin(double noundef %39) #5
  %41 = fmul double %37, %40
  %42 = fneg double %41
  %43 = call double @llvm.fmuladd.f64(double %31, double %34, double %42)
  %44 = call double @llvm.round.f64(double %43)
  %45 = fptosi double %44 to i32
  store i32 %45, ptr %13, align 4, !tbaa !12
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !12
  %48 = sitofp i32 %47 to double
  %49 = load float, ptr %11, align 4, !tbaa !9
  %50 = fpext float %49 to double
  %51 = call double @sin(double noundef %50) #5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %52, align 4, !tbaa !12
  %54 = sitofp i32 %53 to double
  %55 = load float, ptr %11, align 4, !tbaa !9
  %56 = fpext float %55 to double
  %57 = call double @cos(double noundef %56) #5
  %58 = fmul double %54, %57
  %59 = call double @llvm.fmuladd.f64(double %48, double %51, double %58)
  %60 = call double @llvm.round.f64(double %59)
  %61 = fptosi double %60 to i32
  store i32 %61, ptr %14, align 4, !tbaa !12
  br label %140

62:                                               ; preds = %5
  %63 = load i8, ptr %10, align 1, !tbaa !11
  %64 = sext i8 %63 to i32
  %65 = icmp eq i32 %64, 89
  br i1 %65, label %66, label %100

66:                                               ; preds = %62
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load i32, ptr %67, align 4, !tbaa !12
  %69 = sitofp i32 %68 to double
  %70 = load float, ptr %11, align 4, !tbaa !9
  %71 = fpext float %70 to double
  %72 = call double @cos(double noundef %71) #5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load i32, ptr %73, align 4, !tbaa !12
  %75 = sitofp i32 %74 to double
  %76 = load float, ptr %11, align 4, !tbaa !9
  %77 = fpext float %76 to double
  %78 = call double @sin(double noundef %77) #5
  %79 = fmul double %75, %78
  %80 = call double @llvm.fmuladd.f64(double %69, double %72, double %79)
  %81 = call double @llvm.round.f64(double %80)
  %82 = fptosi double %81 to i32
  store i32 %82, ptr %12, align 4, !tbaa !12
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load i32, ptr %83, align 4, !tbaa !12
  %85 = sub nsw i32 0, %84
  %86 = sitofp i32 %85 to double
  %87 = load float, ptr %11, align 4, !tbaa !9
  %88 = fpext float %87 to double
  %89 = call double @sin(double noundef %88) #5
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = load i32, ptr %90, align 4, !tbaa !12
  %92 = sitofp i32 %91 to double
  %93 = load float, ptr %11, align 4, !tbaa !9
  %94 = fpext float %93 to double
  %95 = call double @cos(double noundef %94) #5
  %96 = fmul double %92, %95
  %97 = call double @llvm.fmuladd.f64(double %86, double %89, double %96)
  %98 = call double @llvm.round.f64(double %97)
  %99 = fptosi double %98 to i32
  store i32 %99, ptr %14, align 4, !tbaa !12
  br label %139

100:                                              ; preds = %62
  %101 = load i8, ptr %10, align 1, !tbaa !11
  %102 = sext i8 %101 to i32
  %103 = icmp eq i32 %102, 90
  br i1 %103, label %104, label %138

104:                                              ; preds = %100
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = load i32, ptr %105, align 4, !tbaa !12
  %107 = sitofp i32 %106 to double
  %108 = load float, ptr %11, align 4, !tbaa !9
  %109 = fpext float %108 to double
  %110 = call double @cos(double noundef %109) #5
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = load i32, ptr %111, align 4, !tbaa !12
  %113 = sitofp i32 %112 to double
  %114 = load float, ptr %11, align 4, !tbaa !9
  %115 = fpext float %114 to double
  %116 = call double @sin(double noundef %115) #5
  %117 = fmul double %113, %116
  %118 = fneg double %117
  %119 = call double @llvm.fmuladd.f64(double %107, double %110, double %118)
  %120 = call double @llvm.round.f64(double %119)
  %121 = fptosi double %120 to i32
  store i32 %121, ptr %12, align 4, !tbaa !12
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = load i32, ptr %122, align 4, !tbaa !12
  %124 = sitofp i32 %123 to double
  %125 = load float, ptr %11, align 4, !tbaa !9
  %126 = fpext float %125 to double
  %127 = call double @sin(double noundef %126) #5
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = load i32, ptr %128, align 4, !tbaa !12
  %130 = sitofp i32 %129 to double
  %131 = load float, ptr %11, align 4, !tbaa !9
  %132 = fpext float %131 to double
  %133 = call double @cos(double noundef %132) #5
  %134 = fmul double %130, %133
  %135 = call double @llvm.fmuladd.f64(double %124, double %127, double %134)
  %136 = call double @llvm.round.f64(double %135)
  %137 = fptosi double %136 to i32
  store i32 %137, ptr %13, align 4, !tbaa !12
  br label %138

138:                                              ; preds = %104, %100
  br label %139

139:                                              ; preds = %138, %66
  br label %140

140:                                              ; preds = %139, %28
  %141 = load i8, ptr %10, align 1, !tbaa !11
  %142 = sext i8 %141 to i32
  %143 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %142)
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = load i32, ptr %144, align 4, !tbaa !12
  %146 = load ptr, ptr %7, align 8, !tbaa !5
  %147 = load i32, ptr %146, align 4, !tbaa !12
  %148 = load ptr, ptr %8, align 8, !tbaa !5
  %149 = load i32, ptr %148, align 4, !tbaa !12
  %150 = load i32, ptr %12, align 4, !tbaa !12
  %151 = load i32, ptr %13, align 4, !tbaa !12
  %152 = load i32, ptr %14, align 4, !tbaa !12
  %153 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %145, i32 noundef %147, i32 noundef %149, i32 noundef %150, i32 noundef %151, i32 noundef %152)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret void
}

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

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, 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"

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @rotate(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, float noundef %3, i8 noundef signext %4) local_unnamed_addr #0 {
  %6 = fpext float %3 to double
  %7 = fmul double %6, 0x3F91DF46A2529D39
  %8 = fptrunc double %7 to float
  %9 = load i32, ptr %0, align 4, !tbaa !5
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  switch i8 %4, label %78 [
    i8 88, label %12
    i8 89, label %34
    i8 90, label %56
  ]

12:                                               ; preds = %5
  %13 = sitofp i32 %10 to double
  %14 = fpext float %8 to double
  %15 = tail call double @cos(double noundef %14) #4
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sitofp i32 %16 to double
  %18 = tail call double @sin(double noundef %14) #4
  %19 = fneg double %18
  %20 = fmul double %19, %17
  %21 = tail call double @llvm.fmuladd.f64(double %13, double %15, double %20)
  %22 = tail call double @llvm.round.f64(double %21)
  %23 = fptosi double %22 to i32
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = sitofp i32 %24 to double
  %26 = tail call double @sin(double noundef %14) #4
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sitofp i32 %27 to double
  %29 = tail call double @cos(double noundef %14) #4
  %30 = fmul double %29, %28
  %31 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %30)
  %32 = tail call double @llvm.round.f64(double %31)
  %33 = fptosi double %32 to i32
  br label %78

34:                                               ; preds = %5
  %35 = sitofp i32 %9 to double
  %36 = fpext float %8 to double
  %37 = tail call double @cos(double noundef %36) #4
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sitofp i32 %38 to double
  %40 = tail call double @sin(double noundef %36) #4
  %41 = fmul double %40, %39
  %42 = tail call double @llvm.fmuladd.f64(double %35, double %37, double %41)
  %43 = tail call double @llvm.round.f64(double %42)
  %44 = fptosi double %43 to i32
  %45 = load i32, ptr %0, align 4, !tbaa !5
  %46 = sub nsw i32 0, %45
  %47 = sitofp i32 %46 to double
  %48 = tail call double @sin(double noundef %36) #4
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sitofp i32 %49 to double
  %51 = tail call double @cos(double noundef %36) #4
  %52 = fmul double %51, %50
  %53 = tail call double @llvm.fmuladd.f64(double %47, double %48, double %52)
  %54 = tail call double @llvm.round.f64(double %53)
  %55 = fptosi double %54 to i32
  br label %78

56:                                               ; preds = %5
  %57 = sitofp i32 %9 to double
  %58 = fpext float %8 to double
  %59 = tail call double @cos(double noundef %58) #4
  %60 = load i32, ptr %1, align 4, !tbaa !5
  %61 = sitofp i32 %60 to double
  %62 = tail call double @sin(double noundef %58) #4
  %63 = fneg double %62
  %64 = fmul double %63, %61
  %65 = tail call double @llvm.fmuladd.f64(double %57, double %59, double %64)
  %66 = tail call double @llvm.round.f64(double %65)
  %67 = fptosi double %66 to i32
  %68 = load i32, ptr %0, align 4, !tbaa !5
  %69 = sitofp i32 %68 to double
  %70 = tail call double @sin(double noundef %58) #4
  %71 = load i32, ptr %1, align 4, !tbaa !5
  %72 = sitofp i32 %71 to double
  %73 = tail call double @cos(double noundef %58) #4
  %74 = fmul double %73, %72
  %75 = tail call double @llvm.fmuladd.f64(double %69, double %70, double %74)
  %76 = tail call double @llvm.round.f64(double %75)
  %77 = fptosi double %76 to i32
  br label %78

78:                                               ; preds = %5, %34, %56, %12
  %.038 = phi i32 [ %9, %12 ], [ %44, %34 ], [ %67, %56 ], [ %9, %5 ]
  %.037 = phi i32 [ %23, %12 ], [ %10, %34 ], [ %77, %56 ], [ %10, %5 ]
  %.0 = phi i32 [ %33, %12 ], [ %55, %34 ], [ %11, %56 ], [ %11, %5 ]
  %79 = sext i8 %4 to i32
  %80 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %79)
  %81 = load i32, ptr %0, align 4, !tbaa !5
  %82 = load i32, ptr %1, align 4, !tbaa !5
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %81, i32 noundef %82, i32 noundef %83, i32 noundef %.038, i32 noundef %.037, i32 noundef %.0)
  ret void
}

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

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

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

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

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

attributes #0 = { nofree 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 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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