; LLVM IR from imeplusplus/icpc-notebook :: misc/stanford_latlong.ll (Z7convertR2ll)

; 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.rect = type { double, double, double }
%struct.ll = type { double, double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7convertR2ll(ptr dead_on_unwind noalias writable sret(%struct.rect) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #0 {
  %3 = alloca ptr, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.ll, ptr %4, i32 0, i32 0
  %6 = load double, ptr %5, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ll, ptr %7, i32 0, i32 2
  %9 = load double, ptr %8, align 8, !tbaa !12
  %10 = fmul double %9, 0x400921FB54442D18
  %11 = fdiv double %10, 1.800000e+02
  %12 = call double @cos(double noundef %11) #2
  %13 = fmul double %6, %12
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ll, ptr %14, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !13
  %17 = fmul double %16, 0x400921FB54442D18
  %18 = fdiv double %17, 1.800000e+02
  %19 = call double @cos(double noundef %18) #2
  %20 = fmul double %13, %19
  %21 = getelementptr inbounds %struct.rect, ptr %0, i32 0, i32 0
  store double %20, ptr %21, align 8, !tbaa !14
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ll, ptr %22, i32 0, i32 0
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ll, ptr %25, i32 0, i32 2
  %27 = load double, ptr %26, align 8, !tbaa !12
  %28 = fmul double %27, 0x400921FB54442D18
  %29 = fdiv double %28, 1.800000e+02
  %30 = call double @sin(double noundef %29) #2
  %31 = fmul double %24, %30
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ll, ptr %32, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = fmul double %34, 0x400921FB54442D18
  %36 = fdiv double %35, 1.800000e+02
  %37 = call double @cos(double noundef %36) #2
  %38 = fmul double %31, %37
  %39 = getelementptr inbounds %struct.rect, ptr %0, i32 0, i32 1
  store double %38, ptr %39, align 8, !tbaa !16
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ll, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ll, ptr %43, i32 0, i32 1
  %45 = load double, ptr %44, align 8, !tbaa !13
  %46 = fmul double %45, 0x400921FB54442D18
  %47 = fdiv double %46, 1.800000e+02
  %48 = call double @sin(double noundef %47) #2
  %49 = fmul double %42, %48
  %50 = getelementptr inbounds %struct.rect, ptr %0, i32 0, i32 2
  store double %49, ptr %50, align 8, !tbaa !17
  ret void
}

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

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

attributes #0 = { mustprogress 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 = { 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 = { 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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS2ll", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!10, !11, i64 8}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTS4rect", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!15, !11, i64 8}
!17 = !{!15, !11, i64 16}


; 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.rect = type { double, double, double }

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @_Z7convertR2ll(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.rect) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %1) local_unnamed_addr #0 {
  %3 = load <2 x double>, ptr %1, align 8
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fmul double %5, 0x400921FB54442D18
  %7 = fdiv double %6, 1.800000e+02
  %8 = tail call double @cos(double noundef %7) #2
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !10
  %11 = fmul double %10, 0x400921FB54442D18
  %12 = fdiv double %11, 1.800000e+02
  %13 = tail call double @cos(double noundef %12) #2
  %14 = load double, ptr %1, align 8, !tbaa !11
  %15 = load double, ptr %4, align 8, !tbaa !5
  %16 = fmul double %15, 0x400921FB54442D18
  %17 = fdiv double %16, 1.800000e+02
  %18 = tail call double @sin(double noundef %17) #2
  %19 = load double, ptr %9, align 8, !tbaa !10
  %20 = fmul double %19, 0x400921FB54442D18
  %21 = fdiv double %20, 1.800000e+02
  %22 = tail call double @cos(double noundef %21) #2
  %23 = insertelement <2 x double> %3, double %14, i64 1
  %24 = insertelement <2 x double> poison, double %8, i64 0
  %25 = insertelement <2 x double> %24, double %18, i64 1
  %26 = fmul <2 x double> %23, %25
  %27 = insertelement <2 x double> poison, double %13, i64 0
  %28 = insertelement <2 x double> %27, double %22, i64 1
  %29 = fmul <2 x double> %26, %28
  store <2 x double> %29, ptr %0, align 8, !tbaa !12
  %30 = load double, ptr %1, align 8, !tbaa !11
  %31 = load double, ptr %9, align 8, !tbaa !10
  %32 = fmul double %31, 0x400921FB54442D18
  %33 = fdiv double %32, 1.800000e+02
  %34 = tail call double @sin(double noundef %33) #2
  %35 = fmul double %30, %34
  %36 = getelementptr inbounds i8, ptr %0, i64 16
  store double %35, ptr %36, align 8, !tbaa !13
  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

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 = { 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, !7, i64 16}
!6 = !{!"_ZTS2ll", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !7, i64 16}
!14 = !{!"_ZTS4rect", !7, i64 0, !7, i64 8, !7, i64 16}


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