; LLVM IR from acm-clan/algorithm-stone :: user/codeforces/10A.Power Consumption Calculation (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"

@n = external dso_local global i32, align 4
@p1 = external dso_local global i32, align 4
@p2 = external dso_local global i32, align 4
@p3 = external dso_local global i32, align 4
@t1 = external dso_local global i32, align 4
@t2 = external dso_local global i32, align 4
@l = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@s = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 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
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @p1, ptr noundef @p2, ptr noundef @p3, ptr noundef @t1, ptr noundef @t2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %72, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp sle i32 %7, %8
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %75

11:                                               ; preds = %6
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @l, ptr noundef @r)
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 1
  br i1 %14, label %15, label %63

15:                                               ; preds = %11
  %16 = load i32, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %17 = load i32, ptr @l, align 4, !tbaa !5
  %18 = load i32, ptr @s, align 4, !tbaa !5
  %19 = sub nsw i32 %17, %18
  store i32 %19, ptr %3, align 4, !tbaa !5
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @t1, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = load i32, ptr @p1, align 4, !tbaa !5
  %23 = mul nsw i32 %21, %22
  %24 = add nsw i32 %16, %23
  store i32 %24, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %25 = load i32, ptr @l, align 4, !tbaa !5
  %26 = load i32, ptr @s, align 4, !tbaa !5
  %27 = sub nsw i32 %25, %26
  %28 = load i32, ptr @t1, align 4, !tbaa !5
  %29 = icmp sgt i32 %27, %28
  br i1 %29, label %30, label %62

30:                                               ; preds = %15
  %31 = load i32, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %32 = load i32, ptr @l, align 4, !tbaa !5
  %33 = load i32, ptr @s, align 4, !tbaa !5
  %34 = sub nsw i32 %32, %33
  %35 = load i32, ptr @t1, align 4, !tbaa !5
  %36 = sub nsw i32 %34, %35
  store i32 %36, ptr %4, align 4, !tbaa !5
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) @t2)
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr @p2, align 4, !tbaa !5
  %40 = mul nsw i32 %38, %39
  %41 = add nsw i32 %31, %40
  store i32 %41, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %42 = load i32, ptr @l, align 4, !tbaa !5
  %43 = load i32, ptr @s, align 4, !tbaa !5
  %44 = sub nsw i32 %42, %43
  %45 = load i32, ptr @t1, align 4, !tbaa !5
  %46 = load i32, ptr @t2, align 4, !tbaa !5
  %47 = add nsw i32 %45, %46
  %48 = icmp sgt i32 %44, %47
  br i1 %48, label %49, label %61

49:                                               ; preds = %30
  %50 = load i32, ptr @ans, align 4, !tbaa !5
  %51 = load i32, ptr @l, align 4, !tbaa !5
  %52 = load i32, ptr @s, align 4, !tbaa !5
  %53 = sub nsw i32 %51, %52
  %54 = load i32, ptr @t1, align 4, !tbaa !5
  %55 = sub nsw i32 %53, %54
  %56 = load i32, ptr @t2, align 4, !tbaa !5
  %57 = sub nsw i32 %55, %56
  %58 = load i32, ptr @p3, align 4, !tbaa !5
  %59 = mul nsw i32 %57, %58
  %60 = add nsw i32 %50, %59
  store i32 %60, ptr @ans, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %49, %30
  br label %62

62:                                               ; preds = %61, %15
  br label %63

63:                                               ; preds = %62, %11
  %64 = load i32, ptr @ans, align 4, !tbaa !5
  %65 = load i32, ptr @r, align 4, !tbaa !5
  %66 = load i32, ptr @l, align 4, !tbaa !5
  %67 = sub nsw i32 %65, %66
  %68 = load i32, ptr @p1, align 4, !tbaa !5
  %69 = mul nsw i32 %67, %68
  %70 = add nsw i32 %64, %69
  store i32 %70, ptr @ans, align 4, !tbaa !5
  %71 = load i32, ptr @r, align 4, !tbaa !5
  store i32 %71, ptr @s, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %63
  %73 = load i32, ptr %2, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !9

75:                                               ; preds = %10
  %76 = load i32, ptr @ans, align 4, !tbaa !5
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %76)
  ret i32 0
}

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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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"

@n = external dso_local global i32, align 4
@p1 = external dso_local global i32, align 4
@p2 = external dso_local global i32, align 4
@p3 = external dso_local global i32, align 4
@t1 = external dso_local global i32, align 4
@t2 = external dso_local global i32, align 4
@l = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@s = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @p1, ptr noundef nonnull @p2, ptr noundef nonnull @p3, ptr noundef nonnull @t1, ptr noundef nonnull @t2)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not6 = icmp slt i32 %4, 1
  br i1 %.not6, label %.._crit_edge_crit_edge, label %5

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre17 = load i32, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge

5:                                                ; preds = %0
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @l, ptr noundef nonnull @r)
  %.pre = load i32, ptr @ans, align 4, !tbaa !5
  %.pre14 = load i32, ptr @n, align 4, !tbaa !5
  %.pre13 = load i32, ptr @p1, align 4, !tbaa !5
  %.pre12 = load i32, ptr @l, align 4, !tbaa !5
  %.pre11 = load i32, ptr @r, align 4, !tbaa !5
  %7 = sub nsw i32 %.pre11, %.pre12
  %8 = mul nsw i32 %7, %.pre13
  %9 = add nsw i32 %8, %.pre
  store i32 %9, ptr @ans, align 4, !tbaa !5
  store i32 %.pre11, ptr @s, align 4, !tbaa !5
  %.not.not.peel = icmp sgt i32 %.pre14, 1
  br i1 %.not.not.peel, label %.lr.ph.peel.next, label %._crit_edge

._crit_edge:                                      ; preds = %47, %5, %.._crit_edge_crit_edge
  %10 = phi i32 [ %.pre17, %.._crit_edge_crit_edge ], [ %9, %5 ], [ %54, %47 ]
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %10)
  ret i32 0

.lr.ph.peel.next:                                 ; preds = %5, %47
  %.07 = phi i32 [ %55, %47 ], [ 2, %5 ]
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @l, ptr noundef nonnull @r)
  %13 = load i32, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %14 = load i32, ptr @l, align 4, !tbaa !5
  %15 = load i32, ptr @s, align 4, !tbaa !5
  %16 = sub nsw i32 %14, %15
  store i32 %16, ptr %1, align 4, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @t1, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = load i32, ptr @p1, align 4, !tbaa !5
  %20 = mul nsw i32 %19, %18
  %21 = add nsw i32 %20, %13
  store i32 %21, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %22 = load i32, ptr @l, align 4, !tbaa !5
  %23 = load i32, ptr @s, align 4, !tbaa !5
  %24 = sub nsw i32 %22, %23
  %25 = load i32, ptr @t1, align 4, !tbaa !5
  %26 = icmp sgt i32 %24, %25
  br i1 %26, label %27, label %47

27:                                               ; preds = %.lr.ph.peel.next
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %28 = add i32 %23, %25
  %29 = sub i32 %22, %28
  store i32 %29, ptr %2, align 4, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) @t2)
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = load i32, ptr @p2, align 4, !tbaa !5
  %33 = mul nsw i32 %32, %31
  %34 = add nsw i32 %33, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  %35 = load i32, ptr @l, align 4, !tbaa !5
  %36 = load i32, ptr @s, align 4, !tbaa !5
  %37 = sub nsw i32 %35, %36
  %38 = load i32, ptr @t1, align 4, !tbaa !5
  %39 = load i32, ptr @t2, align 4, !tbaa !5
  %40 = add nsw i32 %39, %38
  %41 = icmp sgt i32 %37, %40
  br i1 %41, label %42, label %47

42:                                               ; preds = %27
  %43 = sub i32 %37, %40
  %44 = load i32, ptr @p3, align 4, !tbaa !5
  %45 = mul nsw i32 %44, %43
  %46 = add nsw i32 %45, %34
  br label %47

47:                                               ; preds = %.lr.ph.peel.next, %42, %27
  %48 = phi i32 [ %22, %.lr.ph.peel.next ], [ %35, %42 ], [ %35, %27 ]
  %49 = phi i32 [ %21, %.lr.ph.peel.next ], [ %46, %42 ], [ %34, %27 ]
  %50 = load i32, ptr @r, align 4, !tbaa !5
  %51 = sub nsw i32 %50, %48
  %52 = load i32, ptr @p1, align 4, !tbaa !5
  %53 = mul nsw i32 %51, %52
  %54 = add nsw i32 %53, %49
  store i32 %54, ptr @ans, align 4, !tbaa !5
  store i32 %50, ptr @s, align 4, !tbaa !5
  %55 = add nuw nsw i32 %.07, 1
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.07, %56
  br i1 %.not.not, label %.lr.ph.peel.next, label %._crit_edge, !llvm.loop !9
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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

attributes #0 = { mustprogress 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 = { 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 #2 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass