; LLVM IR from tangjz/acm-icpc :: projecteuler (595)

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

@f = external dso_local global [53 x double], align 16
@g = external dso_local global [53 x double], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store double 1.000000e+00, ptr getelementptr inbounds ([53 x double], ptr @f, i64 0, i64 1), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 2, ptr %2, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %120, %0
  %6 = load i32, ptr %2, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 53
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %123

9:                                                ; preds = %5
  %10 = load i32, ptr %2, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %11
  store double 1.000000e+00, ptr %12, align 8, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %14
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = sub nsw i32 %17, 1
  %19 = sitofp i32 %18 to double
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = call double @llvm.fmuladd.f64(double %19, double %24, double %16)
  %26 = load i32, ptr %2, align 4, !tbaa !9
  %27 = sub nsw i32 %26, 2
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = fadd double %25, %30
  %32 = load i32, ptr %2, align 4, !tbaa !9
  %33 = sitofp i32 %32 to double
  %34 = fdiv double %31, %33
  %35 = load i32, ptr %2, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %36
  store double %34, ptr %37, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %38 = load i32, ptr %2, align 4, !tbaa !9
  %39 = sub nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %95, %9
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = icmp sge i32 %41, 1
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %98

44:                                               ; preds = %40
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = sub nsw i32 %49, 1
  %51 = sitofp i32 %50 to double
  %52 = load i32, ptr %4, align 4, !tbaa !9
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !5
  %57 = call double @llvm.fmuladd.f64(double %51, double %56, double %48)
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = icmp sgt i32 %58, 1
  br i1 %59, label %60, label %72

60:                                               ; preds = %44
  %61 = load i32, ptr %2, align 4, !tbaa !9
  %62 = load i32, ptr %4, align 4, !tbaa !9
  %63 = sub nsw i32 %61, %62
  %64 = add nsw i32 %63, 1
  %65 = sitofp i32 %64 to double
  %66 = load i32, ptr %4, align 4, !tbaa !9
  %67 = sub nsw i32 %66, 2
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !5
  %71 = fmul double %65, %70
  br label %73

72:                                               ; preds = %44
  br label %73

73:                                               ; preds = %72, %60
  %74 = phi double [ %71, %60 ], [ 0.000000e+00, %72 ]
  %75 = fadd double %57, %74
  %76 = load i32, ptr %2, align 4, !tbaa !9
  %77 = sitofp i32 %76 to double
  %78 = fdiv double %75, %77
  %79 = load i32, ptr %4, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %80
  store double %78, ptr %81, align 8, !tbaa !5
  %82 = load i32, ptr %4, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %83
  %85 = load double, ptr %84, align 8, !tbaa !5
  %86 = load i32, ptr %4, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %87
  %89 = load double, ptr %88, align 8, !tbaa !5
  %90 = load i32, ptr %2, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %91
  %93 = load double, ptr %92, align 8, !tbaa !5
  %94 = call double @llvm.fmuladd.f64(double %85, double %89, double %93)
  store double %94, ptr %92, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %73
  %96 = load i32, ptr %4, align 4, !tbaa !9
  %97 = add nsw i32 %96, -1
  store i32 %97, ptr %4, align 4, !tbaa !9
  br label %40, !llvm.loop !11

98:                                               ; preds = %43
  %99 = load i32, ptr %2, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %100
  %102 = load double, ptr %101, align 8, !tbaa !5
  %103 = fsub double 1.000000e+00, %102
  %104 = load i32, ptr %2, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !5
  %108 = fdiv double %107, %103
  store double %108, ptr %106, align 8, !tbaa !5
  %109 = load i32, ptr %2, align 4, !tbaa !9
  %110 = load i32, ptr %2, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %111
  %113 = load double, ptr %112, align 8, !tbaa !5
  %114 = load i32, ptr %2, align 4, !tbaa !9
  %115 = icmp sgt i32 %114, 0
  %116 = zext i1 %115 to i32
  %117 = sitofp i32 %116 to double
  %118 = fsub double %113, %117
  %119 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %109, double noundef %118)
  br label %120

120:                                              ; preds = %98
  %121 = load i32, ptr %2, align 4, !tbaa !9
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %2, align 4, !tbaa !9
  br label %5, !llvm.loop !13

123:                                              ; preds = %8
  ret i32 0
}

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

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

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

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

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


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

@f = external dso_local local_unnamed_addr global [53 x double], align 16
@g = external dso_local local_unnamed_addr global [53 x double], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  store double 1.000000e+00, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !5
  br label %.lr.ph

1:                                                ; preds = %._crit_edge
  ret i32 0

.lr.ph:                                           ; preds = %._crit_edge, %0
  %indvars.iv37 = phi i64 [ 2, %0 ], [ %18, %._crit_edge ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %._crit_edge ]
  %2 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %indvars.iv37
  store double 1.000000e+00, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %indvars.iv37
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = add nsw i64 %indvars.iv37, -1
  %6 = trunc nuw nsw i64 %5 to i32
  %7 = uitofp nneg i32 %6 to double
  %8 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %5
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = tail call double @llvm.fmuladd.f64(double %7, double %9, double %4)
  %11 = add nsw i64 %indvars.iv37, -2
  %12 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %11
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fadd double %10, %13
  %15 = trunc nuw nsw i64 %indvars.iv37 to i32
  %16 = uitofp nneg i32 %15 to double
  %17 = fdiv double %14, %16
  store double %17, ptr %3, align 8, !tbaa !5
  %18 = add nuw nsw i64 %indvars.iv37, 1
  %.phi.trans.insert = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %indvars.iv
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %23

._crit_edge:                                      ; preds = %41
  %.pre40 = load double, ptr %3, align 8, !tbaa !5
  %19 = fsub double 1.000000e+00, %.pre40
  %20 = fdiv double %47, %19
  store double %20, ptr %2, align 8, !tbaa !5
  %21 = fadd double %20, -1.000000e+00
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %15, double noundef %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %18, 53
  br i1 %exitcond.not, label %1, label %.lr.ph, !llvm.loop !9

23:                                               ; preds = %.lr.ph, %41
  %24 = phi double [ %.pre, %.lr.ph ], [ %30, %41 ]
  %indvars.iv34 = phi i64 [ %indvars.iv, %.lr.ph ], [ %indvars.iv.next35, %41 ]
  %25 = phi double [ 1.000000e+00, %.lr.ph ], [ %47, %41 ]
  %26 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %indvars.iv34
  %indvars.iv.next35 = add nsw i64 %indvars.iv34, -1
  %27 = trunc nuw i64 %indvars.iv.next35 to i32
  %28 = uitofp nneg i32 %27 to double
  %29 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %indvars.iv.next35
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = tail call double @llvm.fmuladd.f64(double %28, double %30, double %24)
  %.not = icmp eq i64 %indvars.iv34, 1
  br i1 %.not, label %41, label %32

32:                                               ; preds = %23
  %33 = sub nuw nsw i64 %18, %indvars.iv34
  %34 = trunc nuw nsw i64 %33 to i32
  %35 = sitofp i32 %34 to double
  %36 = add i64 %indvars.iv34, 4294967294
  %37 = and i64 %36, 4294967295
  %38 = getelementptr inbounds [53 x double], ptr @f, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fmul double %39, %35
  br label %41

41:                                               ; preds = %23, %32
  %42 = phi double [ %40, %32 ], [ 0.000000e+00, %23 ]
  %43 = fadd double %31, %42
  %44 = fdiv double %43, %16
  store double %44, ptr %26, align 8, !tbaa !5
  %45 = getelementptr inbounds [53 x double], ptr @g, i64 0, i64 %indvars.iv34
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %25)
  store double %47, ptr %2, align 8, !tbaa !5
  %.not30 = icmp eq i64 %indvars.iv.next35, 0
  br i1 %.not30, label %._crit_edge, label %23, !llvm.loop !11
}

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

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

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

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass