; LLVM IR from hanzohasashi33/Competetive_programming :: hackerrank/problem_solving (plusminus)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store float 0.000000e+00, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store float 0.000000e+00, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store float 0.000000e+00, ptr %5, align 4, !tbaa !5
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %10 = load i32, ptr %2, align 4, !tbaa !9
  %11 = zext i32 %10 to i64
  %12 = call ptr @llvm.stacksave.p0()
  store ptr %12, ptr %7, align 8
  %13 = alloca i32, i64 %11, align 16
  store i64 %11, ptr %8, align 8
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %23, %0
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = load i32, ptr %2, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %26

18:                                               ; preds = %14
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %13, i64 %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %21)
  br label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %6, align 4, !tbaa !9
  br label %14, !llvm.loop !11

26:                                               ; preds = %14
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %54, %26
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr %2, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %57

31:                                               ; preds = %27
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %13, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %31
  %38 = load float, ptr %3, align 4, !tbaa !5
  %39 = fadd float %38, 1.000000e+00
  store float %39, ptr %3, align 4, !tbaa !5
  br label %53

40:                                               ; preds = %31
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %13, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %49

46:                                               ; preds = %40
  %47 = load float, ptr %4, align 4, !tbaa !5
  %48 = fadd float %47, 1.000000e+00
  store float %48, ptr %4, align 4, !tbaa !5
  br label %52

49:                                               ; preds = %40
  %50 = load float, ptr %5, align 4, !tbaa !5
  %51 = fadd float %50, 1.000000e+00
  store float %51, ptr %5, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %49, %46
  br label %53

53:                                               ; preds = %52, %37
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !9
  br label %27, !llvm.loop !13

57:                                               ; preds = %27
  %58 = load float, ptr %3, align 4, !tbaa !5
  %59 = load i32, ptr %2, align 4, !tbaa !9
  %60 = sitofp i32 %59 to float
  %61 = fdiv float %58, %60
  %62 = fpext float %61 to double
  %63 = load float, ptr %4, align 4, !tbaa !5
  %64 = load i32, ptr %2, align 4, !tbaa !9
  %65 = sitofp i32 %64 to float
  %66 = fdiv float %63, %65
  %67 = fpext float %66 to double
  %68 = load float, ptr %5, align 4, !tbaa !5
  %69 = load i32, ptr %2, align 4, !tbaa !9
  %70 = sitofp i32 %69 to float
  %71 = fdiv float %68, %70
  %72 = fpext float %71 to double
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %62, double noundef %67, double noundef %72)
  store i32 0, ptr %1, align 4
  %74 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %74)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %75 = load i32, ptr %1, align 4
  ret i32 %75
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

; 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 = { "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 }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = zext i32 %3 to i64
  %5 = call ptr @llvm.stacksave.p0()
  %6 = alloca i32, i64 %4, align 16
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %9 = icmp sgt i32 %13, 0
  br i1 %9, label %.lr.ph27.preheader, label %._crit_edge

.lr.ph27.preheader:                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %13 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %10 = icmp eq i32 %13, 1
  br i1 %10, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph27.preheader.new

.lr.ph27.preheader.new:                           ; preds = %.lr.ph27.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph27

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %11 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %11)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %.preheader, !llvm.loop !9

.lr.ph27:                                         ; preds = %38, %.lr.ph27.preheader.new
  %indvars.iv33 = phi i64 [ 0, %.lr.ph27.preheader.new ], [ %indvars.iv.next34.1, %38 ]
  %.026 = phi float [ 0.000000e+00, %.lr.ph27.preheader.new ], [ %.1.1, %38 ]
  %.01624 = phi float [ 0.000000e+00, %.lr.ph27.preheader.new ], [ %.117.1, %38 ]
  %.01823 = phi float [ 0.000000e+00, %.lr.ph27.preheader.new ], [ %.119.1, %38 ]
  %niter = phi i64 [ 0, %.lr.ph27.preheader.new ], [ %niter.next.1, %38 ]
  %16 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv33
  %17 = load i32, ptr %16, align 8, !tbaa !5
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %.lr.ph27
  %20 = fadd float %.026, 1.000000e+00
  br label %.lr.ph27.1

21:                                               ; preds = %.lr.ph27
  %22 = icmp slt i32 %17, 0
  br i1 %22, label %23, label %25

23:                                               ; preds = %21
  %24 = fadd float %.01823, 1.000000e+00
  br label %.lr.ph27.1

25:                                               ; preds = %21
  %26 = fadd float %.01624, 1.000000e+00
  br label %.lr.ph27.1

.lr.ph27.1:                                       ; preds = %19, %25, %23
  %.119 = phi float [ %.01823, %19 ], [ %24, %23 ], [ %.01823, %25 ]
  %.117 = phi float [ %.01624, %19 ], [ %.01624, %23 ], [ %26, %25 ]
  %.1 = phi float [ %20, %19 ], [ %.026, %23 ], [ %.026, %25 ]
  %indvars.iv.next34 = or disjoint i64 %indvars.iv33, 1
  %27 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv.next34
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %36, label %30

30:                                               ; preds = %.lr.ph27.1
  %31 = icmp slt i32 %28, 0
  br i1 %31, label %34, label %32

32:                                               ; preds = %30
  %33 = fadd float %.117, 1.000000e+00
  br label %38

34:                                               ; preds = %30
  %35 = fadd float %.119, 1.000000e+00
  br label %38

36:                                               ; preds = %.lr.ph27.1
  %37 = fadd float %.1, 1.000000e+00
  br label %38

38:                                               ; preds = %36, %34, %32
  %.119.1 = phi float [ %.119, %36 ], [ %35, %34 ], [ %.119, %32 ]
  %.117.1 = phi float [ %.117, %36 ], [ %.117, %34 ], [ %33, %32 ]
  %.1.1 = phi float [ %37, %36 ], [ %.1, %34 ], [ %.1, %32 ]
  %indvars.iv.next34.1 = add nuw nsw i64 %indvars.iv33, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph27, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %38, %.lr.ph27.preheader
  %.119.lcssa.ph = phi float [ poison, %.lr.ph27.preheader ], [ %.119.1, %38 ]
  %.117.lcssa.ph = phi float [ poison, %.lr.ph27.preheader ], [ %.117.1, %38 ]
  %.1.lcssa.ph = phi float [ poison, %.lr.ph27.preheader ], [ %.1.1, %38 ]
  %indvars.iv33.unr = phi i64 [ 0, %.lr.ph27.preheader ], [ %indvars.iv.next34.1, %38 ]
  %.026.unr = phi float [ 0.000000e+00, %.lr.ph27.preheader ], [ %.1.1, %38 ]
  %.01624.unr = phi float [ 0.000000e+00, %.lr.ph27.preheader ], [ %.117.1, %38 ]
  %.01823.unr = phi float [ 0.000000e+00, %.lr.ph27.preheader ], [ %.119.1, %38 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph27.epil

.lr.ph27.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa
  %39 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv33.unr
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %48, label %42

42:                                               ; preds = %.lr.ph27.epil
  %43 = icmp slt i32 %40, 0
  br i1 %43, label %46, label %44

44:                                               ; preds = %42
  %45 = fadd float %.01624.unr, 1.000000e+00
  br label %._crit_edge

46:                                               ; preds = %42
  %47 = fadd float %.01823.unr, 1.000000e+00
  br label %._crit_edge

48:                                               ; preds = %.lr.ph27.epil
  %49 = fadd float %.026.unr, 1.000000e+00
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %48, %46, %44, %0, %.preheader
  %.lcssa37 = phi i32 [ %13, %.preheader ], [ %7, %0 ], [ %13, %44 ], [ %13, %46 ], [ %13, %48 ], [ %13, %._crit_edge.loopexit.unr-lcssa ]
  %.018.lcssa = phi float [ 0.000000e+00, %.preheader ], [ 0.000000e+00, %0 ], [ %.119.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.01823.unr, %48 ], [ %47, %46 ], [ %.01823.unr, %44 ]
  %.016.lcssa = phi float [ 0.000000e+00, %.preheader ], [ 0.000000e+00, %0 ], [ %.117.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.01624.unr, %48 ], [ %.01624.unr, %46 ], [ %45, %44 ]
  %.0.lcssa = phi float [ 0.000000e+00, %.preheader ], [ 0.000000e+00, %0 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %49, %48 ], [ %.026.unr, %46 ], [ %.026.unr, %44 ]
  %50 = sitofp i32 %.lcssa37 to float
  %51 = fdiv float %.0.lcssa, %50
  %52 = fpext float %51 to double
  %53 = fdiv float %.018.lcssa, %50
  %54 = fpext float %53 to double
  %55 = fdiv float %.016.lcssa, %50
  %56 = fpext float %55 to double
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %52, double noundef %54, double noundef %56)
  call void @llvm.stackrestore.p0(ptr %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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

attributes #0 = { nofree 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass