; LLVM IR from DionysiosB/CodeForces :: 0100-0199 (131B-OppositesAttract)

; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca [21 x i64], align 16
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 10, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 168, ptr %4) #4
  call void @llvm.memset.p0.i64(ptr align 16 %4, i8 0, i64 168, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  br label %9

9:                                                ; preds = %13, %0
  %10 = load i64, ptr %2, align 8, !tbaa !9
  %11 = add nsw i64 %10, -1
  store i64 %11, ptr %2, align 8, !tbaa !9
  %12 = icmp ne i64 %10, 0
  br i1 %12, label %13, label %21

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %5)
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = add nsw i32 10, %15
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [21 x i64], ptr %4, i64 0, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !11
  %20 = add nsw i64 %19, 1
  store i64 %20, ptr %18, align 8, !tbaa !11
  br label %9, !llvm.loop !13

21:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %39, %21
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 10
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %42

26:                                               ; preds = %22
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [21 x i64], ptr %4, i64 0, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !11
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = sub nsw i32 20, %31
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [21 x i64], ptr %4, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = mul nsw i64 %30, %35
  %37 = load i64, ptr %6, align 8, !tbaa !11
  %38 = add nsw i64 %37, %36
  store i64 %38, ptr %6, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %26
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !5
  br label %22, !llvm.loop !15

42:                                               ; preds = %25
  %43 = getelementptr inbounds [21 x i64], ptr %4, i64 0, i64 10
  %44 = load i64, ptr %43, align 16, !tbaa !11
  %45 = getelementptr inbounds [21 x i64], ptr %4, i64 0, i64 10
  %46 = load i64, ptr %45, align 16, !tbaa !11
  %47 = sub nsw i64 %46, 1
  %48 = mul nsw i64 %44, %47
  %49 = sdiv i64 %48, 2
  %50 = load i64, ptr %6, align 8, !tbaa !11
  %51 = add nsw i64 %50, %49
  store i64 %51, ptr %6, align 8, !tbaa !11
  %52 = load i64, ptr %6, align 8, !tbaa !11
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 168, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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"

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

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca [21 x i64], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 168, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(168) %2, i8 0, i64 168, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  store i64 %6, ptr %1, align 8, !tbaa !5
  %.not8 = icmp eq i64 %5, 0
  br i1 %.not8, label %.preheader, label %.lr.ph

.preheader.loopexit:                              ; preds = %.lr.ph
  %.pre = load i64, ptr %2, align 16, !tbaa !9
  %.phi.trans.insert = getelementptr inbounds i8, ptr %2, i64 160
  %.pre12 = load i64, ptr %.phi.trans.insert, align 16, !tbaa !9
  %.phi.trans.insert13 = getelementptr inbounds i8, ptr %2, i64 8
  %.pre14 = load i64, ptr %.phi.trans.insert13, align 8, !tbaa !9
  %.phi.trans.insert15 = getelementptr inbounds i8, ptr %2, i64 152
  %.pre16 = load i64, ptr %.phi.trans.insert15, align 8, !tbaa !9
  %.phi.trans.insert17 = getelementptr inbounds i8, ptr %2, i64 16
  %.pre18 = load i64, ptr %.phi.trans.insert17, align 16, !tbaa !9
  %.phi.trans.insert19 = getelementptr inbounds i8, ptr %2, i64 144
  %.pre20 = load i64, ptr %.phi.trans.insert19, align 16, !tbaa !9
  %.phi.trans.insert21 = getelementptr inbounds i8, ptr %2, i64 24
  %.pre22 = load i64, ptr %.phi.trans.insert21, align 8, !tbaa !9
  %.phi.trans.insert23 = getelementptr inbounds i8, ptr %2, i64 136
  %.pre24 = load i64, ptr %.phi.trans.insert23, align 8, !tbaa !9
  %.phi.trans.insert25 = getelementptr inbounds i8, ptr %2, i64 32
  %.pre26 = load i64, ptr %.phi.trans.insert25, align 16, !tbaa !9
  %.phi.trans.insert27 = getelementptr inbounds i8, ptr %2, i64 128
  %.pre28 = load i64, ptr %.phi.trans.insert27, align 16, !tbaa !9
  %.phi.trans.insert29 = getelementptr inbounds i8, ptr %2, i64 40
  %.pre30 = load i64, ptr %.phi.trans.insert29, align 8, !tbaa !9
  %.phi.trans.insert31 = getelementptr inbounds i8, ptr %2, i64 120
  %.pre32 = load i64, ptr %.phi.trans.insert31, align 8, !tbaa !9
  %.phi.trans.insert33 = getelementptr inbounds i8, ptr %2, i64 48
  %.pre34 = load i64, ptr %.phi.trans.insert33, align 16, !tbaa !9
  %.phi.trans.insert35 = getelementptr inbounds i8, ptr %2, i64 112
  %.pre36 = load i64, ptr %.phi.trans.insert35, align 16, !tbaa !9
  %.phi.trans.insert37 = getelementptr inbounds i8, ptr %2, i64 56
  %.pre38 = load i64, ptr %.phi.trans.insert37, align 8, !tbaa !9
  %.phi.trans.insert39 = getelementptr inbounds i8, ptr %2, i64 104
  %.pre40 = load i64, ptr %.phi.trans.insert39, align 8, !tbaa !9
  %.phi.trans.insert41 = getelementptr inbounds i8, ptr %2, i64 64
  %.pre42 = load i64, ptr %.phi.trans.insert41, align 16, !tbaa !9
  %.phi.trans.insert43 = getelementptr inbounds i8, ptr %2, i64 96
  %.pre44 = load i64, ptr %.phi.trans.insert43, align 16, !tbaa !9
  %.phi.trans.insert45 = getelementptr inbounds i8, ptr %2, i64 72
  %.pre46 = load i64, ptr %.phi.trans.insert45, align 8, !tbaa !9
  %.phi.trans.insert47 = getelementptr inbounds i8, ptr %2, i64 88
  %.pre48 = load i64, ptr %.phi.trans.insert47, align 8, !tbaa !9
  %.phi.trans.insert49 = getelementptr inbounds i8, ptr %2, i64 80
  %.pre50 = load i64, ptr %.phi.trans.insert49, align 16, !tbaa !9
  %7 = mul nsw i64 %.pre12, %.pre
  %8 = mul nsw i64 %.pre16, %.pre14
  %9 = add nsw i64 %8, %7
  %10 = mul nsw i64 %.pre20, %.pre18
  %11 = add nsw i64 %10, %9
  %12 = mul nsw i64 %.pre24, %.pre22
  %13 = add nsw i64 %12, %11
  %14 = mul nsw i64 %.pre28, %.pre26
  %15 = add nsw i64 %14, %13
  %16 = mul nsw i64 %.pre32, %.pre30
  %17 = add nsw i64 %16, %15
  %18 = mul nsw i64 %.pre36, %.pre34
  %19 = add nsw i64 %18, %17
  %20 = mul nsw i64 %.pre40, %.pre38
  %21 = add nsw i64 %20, %19
  %22 = mul nsw i64 %.pre44, %.pre42
  %23 = add nsw i64 %22, %21
  %24 = mul nsw i64 %.pre48, %.pre46
  %25 = add nsw i64 %24, %23
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %0
  %26 = phi i64 [ %.pre50, %.preheader.loopexit ], [ 0, %0 ]
  %27 = phi i64 [ %25, %.preheader.loopexit ], [ 0, %0 ]
  %28 = add nsw i64 %26, -1
  %29 = mul nsw i64 %28, %26
  %30 = sdiv i64 %29, 2
  %31 = add nsw i64 %30, %27
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %31)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 168, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0

.lr.ph:                                           ; preds = %0, %.lr.ph
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %34 = load i32, ptr %3, align 4, !tbaa !11
  %35 = add nsw i32 %34, 10
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [21 x i64], ptr %2, i64 0, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = add nsw i64 %38, 1
  store i64 %39, ptr %37, align 8, !tbaa !9
  %40 = load i64, ptr %1, align 8, !tbaa !5
  %41 = add nsw i64 %40, -1
  store i64 %41, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %40, 0
  br i1 %.not, label %.preheader.loopexit, label %.lr.ph, !llvm.loop !13
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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 nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass