; LLVM IR from Dev-XYS/Algorithms :: Complex-Number (main)

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

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZplRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZmiRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZmlRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZdvRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.complex, align 8
  %3 = alloca %struct.complex, align 8
  %4 = alloca %struct.complex, align 8
  %5 = alloca i8, align 1
  %6 = alloca %struct.complex, align 8
  %7 = alloca %struct.complex, align 8
  %8 = alloca %struct.complex, align 8
  %9 = alloca %struct.complex, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #6
  call void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %2, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  call void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %3, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #6
  call void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %4, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #6
  br label %10

10:                                               ; preds = %44, %43, %0
  br label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds %struct.complex, ptr %2, i32 0, i32 0
  %13 = getelementptr inbounds %struct.complex, ptr %2, i32 0, i32 1
  %14 = getelementptr inbounds %struct.complex, ptr %3, i32 0, i32 0
  %15 = getelementptr inbounds %struct.complex, ptr %3, i32 0, i32 1
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %12, ptr noundef %13, ptr noundef %5, ptr noundef %14, ptr noundef %15)
  %17 = load i8, ptr %5, align 1, !tbaa !5
  %18 = sext i8 %17 to i32
  switch i32 %18, label %43 [
    i32 43, label %19
    i32 45, label %25
    i32 42, label %31
    i32 47, label %37
  ]

19:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  %20 = call { double, double } @_ZplRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %21 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %22 = extractvalue { double, double } %20, 0
  store double %22, ptr %21, align 8
  %23 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %24 = extractvalue { double, double } %20, 1
  store double %24, ptr %23, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !8
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  br label %44

25:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  %26 = call { double, double } @_ZmiRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %27 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %28 = extractvalue { double, double } %26, 0
  store double %28, ptr %27, align 8
  %29 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  %30 = extractvalue { double, double } %26, 1
  store double %30, ptr %29, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !8
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  br label %44

31:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %32 = call { double, double } @_ZmlRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %33 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %34 = extractvalue { double, double } %32, 0
  store double %34, ptr %33, align 8
  %35 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %36 = extractvalue { double, double } %32, 1
  store double %36, ptr %35, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !8
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  br label %44

37:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  %38 = call { double, double } @_ZdvRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %39 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  %40 = extractvalue { double, double } %38, 0
  store double %40, ptr %39, align 8
  %41 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  %42 = extractvalue { double, double } %38, 1
  store double %42, ptr %41, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !8
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  br label %44

43:                                               ; preds = %11
  br label %10, !llvm.loop !11

44:                                               ; preds = %37, %31, %25, %19
  %45 = getelementptr inbounds %struct.complex, ptr %2, i32 0, i32 0
  %46 = load double, ptr %45, align 8, !tbaa !13
  %47 = getelementptr inbounds %struct.complex, ptr %2, i32 0, i32 1
  %48 = load double, ptr %47, align 8, !tbaa !15
  %49 = load i8, ptr %5, align 1, !tbaa !5
  %50 = sext i8 %49 to i32
  %51 = getelementptr inbounds %struct.complex, ptr %3, i32 0, i32 0
  %52 = load double, ptr %51, align 8, !tbaa !13
  %53 = getelementptr inbounds %struct.complex, ptr %3, i32 0, i32 1
  %54 = load double, ptr %53, align 8, !tbaa !15
  %55 = getelementptr inbounds %struct.complex, ptr %4, i32 0, i32 0
  %56 = load double, ptr %55, align 8, !tbaa !13
  %57 = getelementptr inbounds %struct.complex, ptr %4, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !15
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %46, double noundef %48, i32 noundef %50, double noundef %52, double noundef %54, double noundef %56, double noundef %58)
  br label %10, !llvm.loop !11
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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

attributes #0 = { mustprogress 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 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 #2 = { mustprogress norecurse 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{i64 0, i64 8, !9, i64 8, i64 8, !9}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !6, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS7complex", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}


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

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZplRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZmiRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZmlRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZdvRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse noreturn uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca %struct.complex, align 8
  %2 = alloca %struct.complex, align 8
  %3 = alloca %struct.complex, align 8
  %4 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #5
  call void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %1, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %2, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  call void @_ZN7complexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %3, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %0
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %5, ptr noundef nonnull %4, ptr noundef nonnull %2, ptr noundef nonnull %6)
  %8 = load i8, ptr %4, align 1, !tbaa !5
  switch i8 %8, label %.backedge.backedge [
    i8 43, label %9
    i8 45, label %12
    i8 42, label %15
    i8 47, label %18
  ]

9:                                                ; preds = %.backedge
  %10 = call { double, double } @_ZplRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %11 = extractvalue { double, double } %10, 0
  store double %11, ptr %3, align 8, !tbaa !8
  br label %21

12:                                               ; preds = %.backedge
  %13 = call { double, double } @_ZmiRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %14 = extractvalue { double, double } %13, 0
  store double %14, ptr %3, align 8, !tbaa !8
  br label %21

15:                                               ; preds = %.backedge
  %16 = call { double, double } @_ZmlRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %17 = extractvalue { double, double } %16, 0
  store double %17, ptr %3, align 8, !tbaa !8
  br label %21

18:                                               ; preds = %.backedge
  %19 = call { double, double } @_ZdvRK7complexS1_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %20 = extractvalue { double, double } %19, 0
  store double %20, ptr %3, align 8, !tbaa !8
  br label %21

21:                                               ; preds = %18, %15, %12, %9
  %.pn = phi { double, double } [ %19, %18 ], [ %16, %15 ], [ %13, %12 ], [ %10, %9 ]
  %22 = phi double [ %20, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %9 ]
  %.sink = extractvalue { double, double } %.pn, 1
  store double %.sink, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !8
  %23 = load double, ptr %1, align 8, !tbaa !10
  %24 = load double, ptr %5, align 8, !tbaa !12
  %25 = load i8, ptr %4, align 1, !tbaa !5
  %26 = sext i8 %25 to i32
  %27 = load double, ptr %2, align 8, !tbaa !10
  %28 = load double, ptr %6, align 8, !tbaa !12
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %23, double noundef %24, i32 noundef %26, double noundef %27, double noundef %28, double noundef %22, double noundef %.sink)
  br label %.backedge.backedge

.backedge.backedge:                               ; preds = %21, %.backedge
  br label %.backedge, !llvm.loop !13
}

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

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

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

attributes #0 = { mustprogress 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 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 #2 = { mustprogress norecurse noreturn 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !6, i64 0}
!10 = !{!11, !9, i64 0}
!11 = !{!"_ZTS7complex", !9, i64 0, !9, i64 8}
!12 = !{!11, !9, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass