; LLVM IR from tangjz/acm-icpc :: codeforces (559A)

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

@x = external dso_local global [6 x i32], align 16
@y = external dso_local global [6 x i32], align 16
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 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 i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

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

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

10:                                               ; preds = %6
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i32, ptr @x, i64 %12
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %13)
  br label %15

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !9

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

19:                                               ; preds = %51, %18
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 6
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %19
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [6 x i32], ptr @x, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = load i32, ptr @y, align 16, !tbaa !5
  %29 = icmp sgt i32 %27, %28
  br i1 %29, label %30, label %50

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %46, %30
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 6
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %31
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = add nsw i32 %36, %37
  %39 = srem i32 %38, 6
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [6 x i32], ptr @x, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [6 x i32], ptr @y, i64 0, i64 %44
  store i32 %42, ptr %45, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %35
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %5, align 4, !tbaa !5
  br label %31, !llvm.loop !11

49:                                               ; preds = %34
  br label %50

50:                                               ; preds = %49, %23
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %3, align 4, !tbaa !5
  br label %19, !llvm.loop !12

54:                                               ; preds = %22
  %55 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 1), align 4, !tbaa !5
  %56 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 1), align 4, !tbaa !5
  %57 = add nsw i32 %55, %56
  %58 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 2), align 8, !tbaa !5
  %59 = add nsw i32 %57, %58
  %60 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 2), align 8, !tbaa !5
  %61 = mul nsw i32 %59, %60
  %62 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 5), align 4, !tbaa !5
  %63 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 5), align 4, !tbaa !5
  %64 = add nsw i32 %62, %63
  %65 = load i32, ptr @y, align 16, !tbaa !5
  %66 = add nsw i32 %64, %65
  %67 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 2), align 8, !tbaa !5
  %68 = sub nsw i32 %66, %67
  %69 = load i32, ptr @y, align 16, !tbaa !5
  %70 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 2), align 8, !tbaa !5
  %71 = sub nsw i32 %69, %70
  %72 = mul nsw i32 %68, %71
  %73 = add nsw i32 %61, %72
  %74 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 4), align 16, !tbaa !5
  %75 = load i32, ptr @y, align 16, !tbaa !5
  %76 = sub nsw i32 %74, %75
  %77 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 2), align 8, !tbaa !5
  %78 = add nsw i32 %76, %77
  %79 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 1), align 4, !tbaa !5
  %80 = add nsw i32 %78, %79
  %81 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 2), align 8, !tbaa !5
  %82 = add nsw i32 %80, %81
  %83 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @y, i64 0, i64 3), align 4, !tbaa !5
  %84 = mul nsw i32 %82, %83
  %85 = add nsw i32 %73, %84
  store i32 %85, ptr @ans, align 4, !tbaa !5
  %86 = load i32, ptr @ans, align 4, !tbaa !5
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %86)
  ret i32 0
}

; 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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @printf(ptr noundef, ...) #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 = { 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 = { 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"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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

@x = external dso_local global [6 x i32], align 16
@y = external dso_local local_unnamed_addr global [6 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader14.preheader:
  %0 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @x, i64 4))
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @x, i64 8))
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @x, i64 12))
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @x, i64 16))
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @x, i64 20))
  %6 = load i32, ptr @y, align 16, !tbaa !5
  %7 = load <2 x i32>, ptr @x, align 16, !tbaa !5
  %8 = extractelement <2 x i32> %7, i64 0
  %9 = icmp sgt i32 %8, %6
  %.pre21.pre = load i32, ptr getelementptr inbounds (i8, ptr @x, i64 8), align 8, !tbaa !5
  %.pre22.pre.pre = load i32, ptr getelementptr inbounds (i8, ptr @x, i64 12), align 4, !tbaa !5
  %10 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @x, i64 16), align 16, !tbaa !5
  br i1 %9, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %.preheader14.preheader
  store <2 x i32> %7, ptr @y, align 16, !tbaa !5
  store i32 %.pre21.pre, ptr getelementptr inbounds (i8, ptr @y, i64 8), align 8, !tbaa !5
  store i32 %.pre22.pre.pre, ptr getelementptr inbounds (i8, ptr @y, i64 12), align 4, !tbaa !5
  store <2 x i32> %10, ptr getelementptr inbounds (i8, ptr @y, i64 16), align 16, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.preheader, %.preheader14.preheader
  %11 = phi i32 [ %8, %.preheader.preheader ], [ %6, %.preheader14.preheader ]
  %12 = extractelement <2 x i32> %7, i64 1
  %13 = icmp sgt i32 %12, %11
  br i1 %13, label %.preheader.preheader.1, label %.loopexit.1

.preheader.preheader.1:                           ; preds = %.loopexit
  store i32 %12, ptr @y, align 16, !tbaa !5
  store i32 %.pre21.pre, ptr getelementptr inbounds (i8, ptr @y, i64 4), align 4, !tbaa !5
  store i32 %.pre22.pre.pre, ptr getelementptr inbounds (i8, ptr @y, i64 8), align 8, !tbaa !5
  store <2 x i32> %10, ptr getelementptr inbounds (i8, ptr @y, i64 12), align 4, !tbaa !5
  store i32 %8, ptr getelementptr inbounds (i8, ptr @y, i64 20), align 4, !tbaa !5
  br label %.loopexit.1

.loopexit.1:                                      ; preds = %.preheader.preheader.1, %.loopexit
  %14 = phi i32 [ %12, %.preheader.preheader.1 ], [ %11, %.loopexit ]
  %15 = icmp sgt i32 %.pre21.pre, %14
  br i1 %15, label %.preheader.preheader.2, label %.loopexit.2

.preheader.preheader.2:                           ; preds = %.loopexit.1
  store i32 %.pre21.pre, ptr @y, align 16, !tbaa !5
  store i32 %.pre22.pre.pre, ptr getelementptr inbounds (i8, ptr @y, i64 4), align 4, !tbaa !5
  %16 = shufflevector <2 x i32> %10, <2 x i32> %7, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  store <4 x i32> %16, ptr getelementptr inbounds (i8, ptr @y, i64 8), align 8, !tbaa !5
  br label %.loopexit.2

.loopexit.2:                                      ; preds = %.preheader.preheader.2, %.loopexit.1
  %17 = phi i32 [ %.pre21.pre, %.preheader.preheader.2 ], [ %14, %.loopexit.1 ]
  %18 = icmp sgt i32 %.pre22.pre.pre, %17
  br i1 %18, label %.preheader.preheader.3, label %.loopexit.3

.preheader.preheader.3:                           ; preds = %.loopexit.2
  store i32 %.pre22.pre.pre, ptr @y, align 16, !tbaa !5
  %19 = shufflevector <2 x i32> %10, <2 x i32> %7, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  store <4 x i32> %19, ptr getelementptr inbounds (i8, ptr @y, i64 4), align 4, !tbaa !5
  store i32 %.pre21.pre, ptr getelementptr inbounds (i8, ptr @y, i64 20), align 4, !tbaa !5
  br label %.loopexit.3

.loopexit.3:                                      ; preds = %.preheader.preheader.3, %.loopexit.2
  %20 = phi i32 [ %.pre22.pre.pre, %.preheader.preheader.3 ], [ %17, %.loopexit.2 ]
  %21 = extractelement <2 x i32> %10, i64 0
  %22 = icmp sgt i32 %21, %20
  br i1 %22, label %.preheader.preheader.4, label %.loopexit.4

.preheader.preheader.4:                           ; preds = %.loopexit.3
  %23 = shufflevector <2 x i32> %10, <2 x i32> %7, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  store <4 x i32> %23, ptr @y, align 16, !tbaa !5
  store i32 %.pre21.pre, ptr getelementptr inbounds (i8, ptr @y, i64 16), align 16, !tbaa !5
  store i32 %.pre22.pre.pre, ptr getelementptr inbounds (i8, ptr @y, i64 20), align 4, !tbaa !5
  br label %.loopexit.4

.loopexit.4:                                      ; preds = %.preheader.preheader.4, %.loopexit.3
  %24 = phi i32 [ %21, %.preheader.preheader.4 ], [ %20, %.loopexit.3 ]
  %25 = extractelement <2 x i32> %10, i64 1
  %26 = icmp sgt i32 %25, %24
  br i1 %26, label %.preheader.preheader.5, label %.loopexit.4..loopexit.5_crit_edge

.loopexit.4..loopexit.5_crit_edge:                ; preds = %.loopexit.4
  %.pre25 = load i32, ptr getelementptr inbounds (i8, ptr @y, i64 4), align 4, !tbaa !5
  %.pre26 = load i32, ptr getelementptr inbounds (i8, ptr @y, i64 8), align 8, !tbaa !5
  %.pre27 = load i32, ptr getelementptr inbounds (i8, ptr @y, i64 20), align 4, !tbaa !5
  %.pre28 = load i32, ptr getelementptr inbounds (i8, ptr @y, i64 16), align 16, !tbaa !5
  %.pre29 = load i32, ptr getelementptr inbounds (i8, ptr @y, i64 12), align 4, !tbaa !5
  br label %.loopexit.5

.preheader.preheader.5:                           ; preds = %.loopexit.4
  store i32 %25, ptr @y, align 16, !tbaa !5
  store i32 %8, ptr getelementptr inbounds (i8, ptr @y, i64 4), align 4, !tbaa !5
  store i32 %12, ptr getelementptr inbounds (i8, ptr @y, i64 8), align 8, !tbaa !5
  store i32 %.pre21.pre, ptr getelementptr inbounds (i8, ptr @y, i64 12), align 4, !tbaa !5
  store i32 %.pre22.pre.pre, ptr getelementptr inbounds (i8, ptr @y, i64 16), align 16, !tbaa !5
  store i32 %21, ptr getelementptr inbounds (i8, ptr @y, i64 20), align 4, !tbaa !5
  br label %.loopexit.5

.loopexit.5:                                      ; preds = %.loopexit.4..loopexit.5_crit_edge, %.preheader.preheader.5
  %27 = phi i32 [ %.pre29, %.loopexit.4..loopexit.5_crit_edge ], [ %.pre21.pre, %.preheader.preheader.5 ]
  %28 = phi i32 [ %.pre28, %.loopexit.4..loopexit.5_crit_edge ], [ %.pre22.pre.pre, %.preheader.preheader.5 ]
  %29 = phi i32 [ %24, %.loopexit.4..loopexit.5_crit_edge ], [ %25, %.preheader.preheader.5 ]
  %30 = phi i32 [ %.pre27, %.loopexit.4..loopexit.5_crit_edge ], [ %21, %.preheader.preheader.5 ]
  %31 = phi i32 [ %.pre26, %.loopexit.4..loopexit.5_crit_edge ], [ %12, %.preheader.preheader.5 ]
  %32 = phi i32 [ %.pre25, %.loopexit.4..loopexit.5_crit_edge ], [ %8, %.preheader.preheader.5 ]
  %33 = shl nsw i32 %32, 1
  %34 = add nsw i32 %33, %31
  %35 = mul nsw i32 %34, %31
  %36 = shl nsw i32 %30, 1
  %37 = sub i32 %29, %31
  %38 = add i32 %37, %36
  %39 = mul nsw i32 %38, %37
  %40 = add nsw i32 %39, %35
  %factor = shl i32 %31, 1
  %41 = add i32 %factor, %32
  %42 = sub i32 %41, %29
  %43 = add i32 %42, %28
  %44 = mul nsw i32 %43, %27
  %45 = add nsw i32 %40, %44
  store i32 %45, ptr @ans, align 4, !tbaa !5
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %45)
  ret i32 0
}

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

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass