; LLVM IR from freakout42/macrocalc :: mc/src (mcomplex)

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

; Function Attrs: nounwind uwtable
define dso_local void @cpxmult(ptr dead_on_unwind noalias writable sret(%struct.CELLVALUE) align 8 %0, ptr noundef byval(%struct.CELLVALUE) align 8 %1, ptr noundef byval(%struct.CELLVALUE) align 8 %2) #0 {
  %4 = alloca { double, double }, align 8
  %5 = alloca { double, double }, align 8
  %6 = alloca { double, double }, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #2
  %7 = getelementptr inbounds %struct.CELLVALUE, ptr %1, i32 0, i32 0
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.CELLVALUE, ptr %1, i32 0, i32 1
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fmul double %10, 0.000000e+00
  %12 = fmul double %10, 1.000000e+00
  %13 = fadd double %8, %11
  %14 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 0
  %15 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 1
  store double %13, ptr %14, align 8
  store double %12, ptr %15, align 8
  %16 = getelementptr inbounds %struct.CELLVALUE, ptr %2, i32 0, i32 0
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.CELLVALUE, ptr %2, i32 0, i32 1
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = fmul double %19, 0.000000e+00
  %21 = fmul double %19, 1.000000e+00
  %22 = fadd double %17, %20
  %23 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  %24 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  store double %22, ptr %23, align 8
  store double %21, ptr %24, align 8
  %25 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 0
  %26 = load double, ptr %25, align 8
  %27 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 1
  %28 = load double, ptr %27, align 8
  %29 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  %30 = load double, ptr %29, align 8
  %31 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  %32 = load double, ptr %31, align 8
  %33 = fmul double %26, %30
  %34 = fmul double %28, %32
  %35 = fmul double %26, %32
  %36 = fmul double %28, %30
  %37 = fsub double %33, %34
  %38 = fadd double %35, %36
  %39 = fcmp uno double %37, %37
  br i1 %39, label %40, label %46, !prof !12

40:                                               ; preds = %3
  %41 = fcmp uno double %38, %38
  br i1 %41, label %42, label %46, !prof !12

42:                                               ; preds = %40
  %43 = call { double, double } @__muldc3(double noundef %26, double noundef %28, double noundef %30, double noundef %32) #2
  %44 = extractvalue { double, double } %43, 0
  %45 = extractvalue { double, double } %43, 1
  br label %46

46:                                               ; preds = %42, %40, %3
  %47 = phi double [ %37, %3 ], [ %37, %40 ], [ %44, %42 ]
  %48 = phi double [ %38, %3 ], [ %38, %40 ], [ %45, %42 ]
  %49 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %50 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  store double %47, ptr %49, align 8
  store double %48, ptr %50, align 8
  %51 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %52 = load double, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %54 = load double, ptr %53, align 8
  %55 = getelementptr inbounds %struct.CELLVALUE, ptr %0, i32 0, i32 0
  store double %52, ptr %55, align 8, !tbaa !5
  %56 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %57 = load double, ptr %56, align 8
  %58 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %59 = load double, ptr %58, align 8
  %60 = getelementptr inbounds %struct.CELLVALUE, ptr %0, i32 0, i32 1
  store double %59, ptr %60, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.CELLVALUE, ptr %0, i32 0, i32 2
  store ptr null, ptr %61, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #2
  ret void
}

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

declare { double, double } @__muldc3(double, double, double, double)

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

!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 0}
!6 = !{!"CELLVALUE", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!"branch_weights", i32 1, i32 1048575}
!13 = !{!6, !10, 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.CELLVALUE = type { double, double, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @cpxmult(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.CELLVALUE) align 8 %0, ptr nocapture noundef readonly byval(%struct.CELLVALUE) align 8 %1, ptr nocapture noundef readonly byval(%struct.CELLVALUE) align 8 %2) local_unnamed_addr #0 {
  %4 = load <2 x double>, ptr %1, align 8
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = insertelement <2 x double> poison, double %6, i64 0
  %11 = insertelement <2 x double> %10, double %9, i64 1
  %12 = fmul <2 x double> %11, zeroinitializer
  %13 = insertelement <2 x double> %4, double %7, i64 1
  %14 = fadd <2 x double> %13, %12
  %15 = extractelement <2 x double> %14, i64 0
  %16 = extractelement <2 x double> %14, i64 1
  %17 = fmul double %15, %16
  %18 = fmul double %6, %9
  %19 = fmul double %15, %9
  %20 = fmul double %6, %16
  %21 = fsub double %17, %18
  %22 = fadd double %19, %20
  %23 = fcmp uno double %21, 0.000000e+00
  br i1 %23, label %24, label %30, !prof !12

24:                                               ; preds = %3
  %25 = fcmp uno double %22, 0.000000e+00
  br i1 %25, label %26, label %30, !prof !12

26:                                               ; preds = %24
  %27 = tail call { double, double } @__muldc3(double noundef %15, double noundef %6, double noundef %16, double noundef %9) #1
  %28 = extractvalue { double, double } %27, 0
  %29 = extractvalue { double, double } %27, 1
  br label %30

30:                                               ; preds = %26, %24, %3
  %31 = phi double [ %21, %3 ], [ %21, %24 ], [ %28, %26 ]
  %32 = phi double [ %22, %3 ], [ %22, %24 ], [ %29, %26 ]
  store double %31, ptr %0, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  store double %32, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %34, align 8, !tbaa !13
  ret void
}

declare { double, double } @__muldc3(double, double, double, double) local_unnamed_addr

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 = { 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 8}
!6 = !{!"CELLVALUE", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!"branch_weights", i32 1, i32 1048575}
!13 = !{!6, !10, i64 16}


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