; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LIBF2C/libf2c (z_log)

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

@gcc_bug_bypass_diff_F2C = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @z_log(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.doublecomplex, ptr %14, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !9
  store double %16, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.doublecomplex, ptr %17, i32 0, i32 0
  %19 = load double, ptr %18, align 8, !tbaa !13
  store double %19, ptr %12, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %20 = load double, ptr %11, align 8, !tbaa !12
  %21 = load double, ptr %12, align 8, !tbaa !12
  %22 = call double @atan2(double noundef %20, double noundef %21) #4
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.doublecomplex, ptr %23, i32 0, i32 1
  store double %22, ptr %24, align 8, !tbaa !9
  %25 = load double, ptr %11, align 8, !tbaa !12
  %26 = fcmp olt double %25, 0.000000e+00
  br i1 %26, label %27, label %30

27:                                               ; preds = %2
  %28 = load double, ptr %11, align 8, !tbaa !12
  %29 = fneg double %28
  store double %29, ptr %11, align 8, !tbaa !12
  br label %30

30:                                               ; preds = %27, %2
  %31 = load double, ptr %12, align 8, !tbaa !12
  %32 = fcmp olt double %31, 0.000000e+00
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load double, ptr %12, align 8, !tbaa !12
  %35 = fneg double %34
  store double %35, ptr %12, align 8, !tbaa !12
  br label %36

36:                                               ; preds = %33, %30
  %37 = load double, ptr %12, align 8, !tbaa !12
  %38 = load double, ptr %11, align 8, !tbaa !12
  %39 = fcmp olt double %37, %38
  br i1 %39, label %40, label %44

40:                                               ; preds = %36
  %41 = load double, ptr %11, align 8, !tbaa !12
  store double %41, ptr %7, align 8, !tbaa !12
  %42 = load double, ptr %12, align 8, !tbaa !12
  store double %42, ptr %11, align 8, !tbaa !12
  %43 = load double, ptr %7, align 8, !tbaa !12
  store double %43, ptr %12, align 8, !tbaa !12
  br label %44

44:                                               ; preds = %40, %36
  %45 = load double, ptr %11, align 8, !tbaa !12
  %46 = load double, ptr %12, align 8, !tbaa !12
  %47 = fdiv double %45, %46
  store double %47, ptr %7, align 8, !tbaa !12
  %48 = load double, ptr %12, align 8, !tbaa !12
  %49 = load double, ptr %7, align 8, !tbaa !12
  %50 = load double, ptr %7, align 8, !tbaa !12
  %51 = call double @llvm.fmuladd.f64(double %49, double %50, double 1.000000e+00)
  %52 = call double @sqrt(double noundef %51) #4
  %53 = fmul double %48, %52
  store double %53, ptr %5, align 8, !tbaa !12
  %54 = load double, ptr %5, align 8, !tbaa !12
  %55 = fsub double %54, 1.000000e+00
  store double %55, ptr %7, align 8, !tbaa !12
  %56 = fcmp olt double %55, 0.000000e+00
  br i1 %56, label %57, label %60

57:                                               ; preds = %44
  %58 = load double, ptr %7, align 8, !tbaa !12
  %59 = fneg double %58
  store double %59, ptr %7, align 8, !tbaa !12
  br label %60

60:                                               ; preds = %57, %44
  %61 = load double, ptr %7, align 8, !tbaa !12
  %62 = fcmp ogt double %61, 1.000000e-02
  br i1 %62, label %63, label %68

63:                                               ; preds = %60
  %64 = load double, ptr %5, align 8, !tbaa !12
  %65 = call double @log(double noundef %64) #4
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.doublecomplex, ptr %66, i32 0, i32 0
  store double %65, ptr %67, align 8, !tbaa !13
  br label %123

68:                                               ; preds = %60
  %69 = load ptr, ptr @gcc_bug_bypass_diff_F2C, align 8, !tbaa !5
  store ptr %69, ptr %13, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %72, label %71

71:                                               ; preds = %68
  store ptr @diff1, ptr %13, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %71, %68
  %73 = load double, ptr %12, align 8, !tbaa !12
  %74 = load double, ptr %12, align 8, !tbaa !12
  %75 = call double @llvm.fmuladd.f64(double %73, double %74, double -1.000000e+00)
  %76 = load double, ptr %11, align 8, !tbaa !12
  %77 = load double, ptr %11, align 8, !tbaa !12
  %78 = call double @llvm.fmuladd.f64(double %76, double %77, double %75)
  %79 = load double, ptr %5, align 8, !tbaa !12
  %80 = fadd double %79, 1.000000e+00
  %81 = fdiv double %78, %80
  store double %81, ptr %7, align 8, !tbaa !12
  %82 = load double, ptr %7, align 8, !tbaa !12
  %83 = load double, ptr %7, align 8, !tbaa !12
  %84 = fmul double %82, %83
  store double %84, ptr %8, align 8, !tbaa !12
  %85 = load double, ptr %7, align 8, !tbaa !12
  %86 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %85, double 1.000000e+00)
  store double %86, ptr %5, align 8, !tbaa !12
  store double 1.000000e+00, ptr %10, align 8, !tbaa !12
  store double 1.000000e+00, ptr %9, align 8, !tbaa !12
  br label %87

87:                                               ; preds = %115, %72
  %88 = load double, ptr %5, align 8, !tbaa !12
  store double %88, ptr %6, align 8, !tbaa !12
  %89 = load double, ptr %8, align 8, !tbaa !12
  %90 = load double, ptr %9, align 8, !tbaa !12
  %91 = fmul double %90, %89
  store double %91, ptr %9, align 8, !tbaa !12
  %92 = load double, ptr %10, align 8, !tbaa !12
  %93 = fadd double %92, 2.000000e+00
  store double %93, ptr %10, align 8, !tbaa !12
  %94 = load double, ptr %9, align 8, !tbaa !12
  %95 = load double, ptr %10, align 8, !tbaa !12
  %96 = fdiv double %94, %95
  %97 = load double, ptr %7, align 8, !tbaa !12
  %98 = load double, ptr %9, align 8, !tbaa !12
  %99 = fmul double %97, %98
  %100 = load double, ptr %10, align 8, !tbaa !12
  %101 = fadd double %100, 1.000000e+00
  %102 = fdiv double %99, %101
  %103 = fsub double %96, %102
  %104 = load double, ptr %5, align 8, !tbaa !12
  %105 = fadd double %104, %103
  store double %105, ptr %5, align 8, !tbaa !12
  br label %106

106:                                              ; preds = %87
  %107 = load double, ptr %5, align 8, !tbaa !12
  %108 = load double, ptr %6, align 8, !tbaa !12
  %109 = fsub double %107, %108
  %110 = fcmp ogt double %109, 1.000000e-18
  br i1 %110, label %115, label %111

111:                                              ; preds = %106
  %112 = load ptr, ptr %13, align 8, !tbaa !5
  %113 = call double %112(ptr noundef %5, ptr noundef %6)
  %114 = fcmp ogt double %113, 0.000000e+00
  br label %115

115:                                              ; preds = %111, %106
  %116 = phi i1 [ true, %106 ], [ %114, %111 ]
  br i1 %116, label %87, label %117, !llvm.loop !14

117:                                              ; preds = %115
  %118 = load double, ptr %5, align 8, !tbaa !12
  %119 = load double, ptr %7, align 8, !tbaa !12
  %120 = fmul double %118, %119
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.doublecomplex, ptr %121, i32 0, i32 0
  store double %120, ptr %122, align 8, !tbaa !13
  br label %123

123:                                              ; preds = %117, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  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 @atan2(double noundef, double noundef) #2

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

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

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

; Function Attrs: nounwind uwtable
declare hidden double @diff1(ptr noundef, ptr noundef) #0

; 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 = { 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, !11, i64 8}
!10 = !{!"", !11, i64 0, !11, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@gcc_bug_bypass_diff_F2C = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @z_log(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %7 = extractelement <2 x double> %6, i64 0
  %8 = extractelement <2 x double> %6, i64 1
  %9 = tail call double @atan2(double noundef %8, double noundef %7) #5
  store double %9, ptr %5, align 8, !tbaa !9
  %10 = fcmp olt <2 x double> %6, zeroinitializer
  %11 = fneg <2 x double> %6
  %12 = select <2 x i1> %10, <2 x double> %11, <2 x double> %6
  %13 = extractelement <2 x double> %12, i64 0
  %14 = extractelement <2 x double> %12, i64 1
  %15 = fcmp olt double %13, %14
  %.141 = select i1 %15, double %13, double %14
  %.1 = select i1 %15, double %14, double %13
  %16 = fdiv double %.141, %.1
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double 1.000000e+00)
  %sqrt = tail call double @llvm.sqrt.f64(double %17)
  %18 = fmul double %.1, %sqrt
  %19 = fadd double %18, -1.000000e+00
  %20 = fcmp olt double %19, 0.000000e+00
  %21 = fneg double %19
  %.044 = select i1 %20, double %21, double %19
  %22 = fcmp ogt double %.044, 1.000000e-02
  br i1 %22, label %23, label %25

23:                                               ; preds = %2
  %24 = tail call double @log(double noundef %18) #5
  br label %53

25:                                               ; preds = %2
  %26 = load ptr, ptr @gcc_bug_bypass_diff_F2C, align 8, !tbaa !11
  %.not = icmp eq ptr %26, null
  %spec.store.select = select i1 %.not, ptr @diff1, ptr %26
  %27 = tail call double @llvm.fmuladd.f64(double %.1, double %.1, double -1.000000e+00)
  %28 = tail call double @llvm.fmuladd.f64(double %.141, double %.141, double %27)
  %29 = fadd double %18, 1.000000e+00
  %30 = fdiv double %28, %29
  %31 = fmul double %30, %30
  %32 = tail call double @llvm.fmuladd.f64(double %30, double -5.000000e-01, double 1.000000e+00)
  br label %.critedge

.critedge:                                        ; preds = %.critedge.backedge, %25
  %33 = phi double [ %32, %25 ], [ %.be, %.critedge.backedge ]
  %.043 = phi double [ 1.000000e+00, %25 ], [ %34, %.critedge.backedge ]
  %.042 = phi double [ 1.000000e+00, %25 ], [ %35, %.critedge.backedge ]
  store double %33, ptr %4, align 8, !tbaa !5
  %34 = fmul double %31, %.043
  %35 = fadd double %.042, 2.000000e+00
  %36 = fmul double %30, %34
  %37 = fadd double %35, 1.000000e+00
  %38 = insertelement <2 x double> poison, double %34, i64 0
  %39 = insertelement <2 x double> %38, double %36, i64 1
  %40 = insertelement <2 x double> poison, double %35, i64 0
  %41 = insertelement <2 x double> %40, double %37, i64 1
  %42 = fdiv <2 x double> %39, %41
  %shift = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %43 = fsub <2 x double> %42, %shift
  %44 = extractelement <2 x double> %43, i64 0
  %45 = fadd double %33, %44
  store double %45, ptr %3, align 8, !tbaa !5
  %46 = fsub double %45, %33
  %47 = fcmp ogt double %46, 1.000000e-18
  br i1 %47, label %.critedge.backedge, label %48

48:                                               ; preds = %.critedge
  %49 = call double %spec.store.select(ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %50 = fcmp ogt double %49, 0.000000e+00
  %.pre.pre = load double, ptr %3, align 8, !tbaa !5
  br i1 %50, label %.critedge.backedge, label %51

.critedge.backedge:                               ; preds = %48, %.critedge
  %.be = phi double [ %.pre.pre, %48 ], [ %45, %.critedge ]
  br label %.critedge, !llvm.loop !13

51:                                               ; preds = %48
  %52 = fmul double %30, %.pre.pre
  br label %53

53:                                               ; preds = %51, %23
  %storemerge = phi double [ %52, %51 ], [ %24, %23 ]
  store double %storemerge, ptr %0, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret void
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare hidden double @diff1(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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


; Effective O3 passes: AggressiveInstCombinePass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass