; LLVM IR from tangjz/acm-icpc :: TDL_training/2016-07-08 (D - Housing payments - tjz)

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

@n = external dso_local global i32, align 4
@s = external dso_local global [100010 x i32], align 16
@x = external dso_local global [100010 x i32], align 16
@p = external dso_local global [100010 x i32], align 16
@f = external dso_local global [100010 x double], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 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
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = load ptr, ptr @stdin, align 8, !tbaa !5
  %8 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %7)
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  %10 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %9)
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %31, %0
  %13 = load i32, ptr %2, align 4, !tbaa !9
  %14 = load i32, ptr @n, align 4, !tbaa !9
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %34

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @s, i64 %19
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @x, i64 %22
  %24 = load i32, ptr %2, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr @p, i64 %25
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %20, ptr noundef %23, ptr noundef %26)
  %28 = load i32, ptr %2, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %29
  store double 1.000000e+10, ptr %30, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %17
  %32 = load i32, ptr %2, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !9
  br label %12, !llvm.loop !13

34:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %97, %34
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = load i32, ptr @n, align 4, !tbaa !9
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %93, %40
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 66
  br i1 %43, label %44, label %50

44:                                               ; preds = %41
  %45 = load i32, ptr %3, align 4, !tbaa !9
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = add nsw i32 %45, %46
  %48 = load i32, ptr @n, align 4, !tbaa !9
  %49 = icmp sle i32 %47, %48
  br label %50

50:                                               ; preds = %44, %41
  %51 = phi i1 [ false, %41 ], [ %49, %44 ]
  br i1 %51, label %53, label %52

52:                                               ; preds = %50
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %96

53:                                               ; preds = %50
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = add nsw i32 %54, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100010 x i32], ptr @s, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = sitofp i32 %59 to double
  %61 = load double, ptr %5, align 8, !tbaa !11
  %62 = fadd double %61, %60
  store double %62, ptr %5, align 8, !tbaa !11
  %63 = load i32, ptr %3, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = add nsw i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %66
  %68 = load i32, ptr %3, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = load double, ptr %5, align 8, !tbaa !11
  %73 = fadd double %71, %72
  %74 = load i32, ptr %3, align 4, !tbaa !9
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = add nsw i32 %74, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = sitofp i32 %79 to double
  %81 = fadd double %73, %80
  call void @_Z3updRdd(ptr noundef nonnull align 8 dereferenceable(8) %67, double noundef %81)
  %82 = load i32, ptr %3, align 4, !tbaa !9
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = add nsw i32 %82, %83
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !9
  %88 = add nsw i32 100, %87
  %89 = sitofp i32 %88 to double
  %90 = fdiv double %89, 1.000000e+02
  %91 = load double, ptr %5, align 8, !tbaa !11
  %92 = fmul double %91, %90
  store double %92, ptr %5, align 8, !tbaa !11
  br label %93

93:                                               ; preds = %53
  %94 = load i32, ptr %6, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %6, align 4, !tbaa !9
  br label %41, !llvm.loop !15

96:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %3, align 4, !tbaa !9
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %3, align 4, !tbaa !9
  br label %35, !llvm.loop !16

100:                                              ; preds = %39
  %101 = load i32, ptr @n, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %102
  %104 = load double, ptr %103, align 8, !tbaa !11
  %105 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, double noundef %104)
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRdd(ptr noundef nonnull align 8 dereferenceable(8), double noundef) #3

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

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

@n = external dso_local global i32, align 4
@s = external dso_local global [100010 x i32], align 16
@x = external dso_local global [100010 x i32], align 16
@p = external dso_local global [100010 x i32], align 16
@f = external dso_local global [100010 x double], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = load ptr, ptr @stdin, align 8, !tbaa !5
  %2 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %1)
  %3 = load ptr, ptr @stdout, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %3)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @n)
  %6 = load i32, ptr @n, align 4, !tbaa !9
  %.not30 = icmp slt i32 %6, 1
  br i1 %.not30, label %.preheader29.._crit_edge_crit_edge, label %.lr.ph

.preheader29:                                     ; preds = %.lr.ph
  %7 = icmp sgt i32 %14, 0
  br i1 %7, label %.preheader, label %.preheader29.._crit_edge_crit_edge

.preheader29.._crit_edge_crit_edge:               ; preds = %0, %.preheader29
  %8 = phi i32 [ %14, %.preheader29 ], [ %6, %0 ]
  %.pre44 = sext i32 %8 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %9 = getelementptr inbounds i32, ptr @s, i64 %indvars.iv
  %10 = getelementptr inbounds i32, ptr @x, i64 %indvars.iv
  %11 = getelementptr inbounds i32, ptr @p, i64 %indvars.iv
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11)
  %13 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %indvars.iv
  store double 1.000000e+10, ptr %13, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @n, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %.not.not = icmp slt i64 %indvars.iv, %15
  br i1 %.not.not, label %.lr.ph, label %.preheader29, !llvm.loop !13

.preheader:                                       ; preds = %.preheader29, %.critedge
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %.critedge ], [ 0, %.preheader29 ]
  %16 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %indvars.iv40
  br label %20

._crit_edge:                                      ; preds = %.critedge, %.preheader29.._crit_edge_crit_edge
  %.pre-phi45 = phi i64 [ %.pre44, %.preheader29.._crit_edge_crit_edge ], [ %.pre-phi, %.critedge ]
  %17 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %.pre-phi45
  %18 = load double, ptr %17, align 8, !tbaa !11
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, double noundef %18)
  ret i32 0

20:                                               ; preds = %.preheader, %25
  %indvars.iv37 = phi i64 [ 1, %.preheader ], [ %indvars.iv.next38, %25 ]
  %.02332 = phi double [ 0.000000e+00, %.preheader ], [ %42, %25 ]
  %21 = add nuw nsw i64 %indvars.iv37, %indvars.iv40
  %22 = load i32, ptr @n, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %.not28 = icmp sgt i64 %21, %23
  br i1 %.not28, label %.critedge, label %25

.critedge:                                        ; preds = %20, %..critedge_crit_edge
  %.pre-phi = phi i64 [ %.pre43, %..critedge_crit_edge ], [ %23, %20 ]
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %24 = icmp slt i64 %indvars.iv.next41, %.pre-phi
  br i1 %24, label %.preheader, label %._crit_edge, !llvm.loop !15

25:                                               ; preds = %20
  %26 = getelementptr inbounds [100010 x i32], ptr @s, i64 0, i64 %21
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = sitofp i32 %27 to double
  %29 = fadd double %.02332, %28
  %30 = getelementptr inbounds [100010 x double], ptr @f, i64 0, i64 %21
  %31 = load double, ptr %16, align 8, !tbaa !11
  %32 = fadd double %31, %29
  %33 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %21
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = sitofp i32 %34 to double
  %36 = fadd double %32, %35
  tail call void @_Z3updRdd(ptr noundef nonnull align 8 dereferenceable(8) %30, double noundef %36)
  %37 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %21
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = add nsw i32 %38, 100
  %40 = sitofp i32 %39 to double
  %41 = fdiv double %40, 1.000000e+02
  %42 = fmul double %29, %41
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next38, 66
  br i1 %exitcond.not, label %..critedge_crit_edge, label %20, !llvm.loop !16

..critedge_crit_edge:                             ; preds = %25
  %.pre = load i32, ptr @n, align 4, !tbaa !9
  %.pre43 = sext i32 %.pre to i64
  br label %.critedge
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRdd(ptr noundef nonnull align 8 dereferenceable(8), double noundef) local_unnamed_addr #3

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

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 = { "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 = { 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 #3 = { inlinehint 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" }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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