; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/WF/Easy Medium/CHEFMATH (A)

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

@f = external dso_local global [45 x i64], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() #1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i64 1, ptr @f, align 16, !tbaa !5
  store i64 2, ptr getelementptr inbounds ([45 x i64], ptr @f, i64 0, i64 1), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 2, ptr %2, align 4, !tbaa !9
  br label %4

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

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

8:                                                ; preds = %4
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = sub nsw i32 %9, 1
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [45 x i64], ptr @f, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = sub nsw i32 %14, 2
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [45 x i64], ptr @f, i64 0, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = add nsw i64 %13, %18
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [45 x i64], ptr @f, i64 0, i64 %21
  store i64 %19, ptr %22, align 8, !tbaa !5
  br label %23

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

26:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3)
  br label %28

28:                                               ; preds = %32, %26
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr %3, align 4, !tbaa !9
  %31 = icmp ne i32 %29, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  call void @_Z5solvev()
  br label %28, !llvm.loop !13

33:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #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 = { 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 #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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple 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"

@f = external dso_local local_unnamed_addr global [45 x i64], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() local_unnamed_addr #1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  store i64 1, ptr @f, align 16, !tbaa !5
  store i64 2, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !5
  %2 = load i64, ptr @f, align 16, !tbaa !5
  %3 = add nsw i64 %2, 2
  store i64 %3, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !5
  %4 = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !5
  %5 = add nsw i64 %4, %3
  store i64 %5, ptr getelementptr inbounds (i8, ptr @f, i64 24), align 8, !tbaa !5
  %6 = add nsw i64 %3, %5
  store i64 %6, ptr getelementptr inbounds (i8, ptr @f, i64 32), align 16, !tbaa !5
  %7 = add nsw i64 %5, %6
  store i64 %7, ptr getelementptr inbounds (i8, ptr @f, i64 40), align 8, !tbaa !5
  %8 = add nsw i64 %6, %7
  store i64 %8, ptr getelementptr inbounds (i8, ptr @f, i64 48), align 16, !tbaa !5
  %9 = add nsw i64 %7, %8
  store i64 %9, ptr getelementptr inbounds (i8, ptr @f, i64 56), align 8, !tbaa !5
  %10 = add nsw i64 %8, %9
  store i64 %10, ptr getelementptr inbounds (i8, ptr @f, i64 64), align 16, !tbaa !5
  %11 = add nsw i64 %9, %10
  store i64 %11, ptr getelementptr inbounds (i8, ptr @f, i64 72), align 8, !tbaa !5
  %12 = add nsw i64 %10, %11
  store i64 %12, ptr getelementptr inbounds (i8, ptr @f, i64 80), align 16, !tbaa !5
  %13 = add nsw i64 %11, %12
  store i64 %13, ptr getelementptr inbounds (i8, ptr @f, i64 88), align 8, !tbaa !5
  %14 = add nsw i64 %12, %13
  store i64 %14, ptr getelementptr inbounds (i8, ptr @f, i64 96), align 16, !tbaa !5
  %15 = add nsw i64 %13, %14
  store i64 %15, ptr getelementptr inbounds (i8, ptr @f, i64 104), align 8, !tbaa !5
  %16 = add nsw i64 %14, %15
  store i64 %16, ptr getelementptr inbounds (i8, ptr @f, i64 112), align 16, !tbaa !5
  %17 = add nsw i64 %15, %16
  store i64 %17, ptr getelementptr inbounds (i8, ptr @f, i64 120), align 8, !tbaa !5
  %18 = add nsw i64 %16, %17
  store i64 %18, ptr getelementptr inbounds (i8, ptr @f, i64 128), align 16, !tbaa !5
  %19 = add nsw i64 %17, %18
  store i64 %19, ptr getelementptr inbounds (i8, ptr @f, i64 136), align 8, !tbaa !5
  %20 = add nsw i64 %18, %19
  store i64 %20, ptr getelementptr inbounds (i8, ptr @f, i64 144), align 16, !tbaa !5
  %21 = add nsw i64 %19, %20
  store i64 %21, ptr getelementptr inbounds (i8, ptr @f, i64 152), align 8, !tbaa !5
  %22 = add nsw i64 %20, %21
  store i64 %22, ptr getelementptr inbounds (i8, ptr @f, i64 160), align 16, !tbaa !5
  %23 = add nsw i64 %21, %22
  store i64 %23, ptr getelementptr inbounds (i8, ptr @f, i64 168), align 8, !tbaa !5
  %24 = add nsw i64 %22, %23
  store i64 %24, ptr getelementptr inbounds (i8, ptr @f, i64 176), align 16, !tbaa !5
  %25 = add nsw i64 %23, %24
  store i64 %25, ptr getelementptr inbounds (i8, ptr @f, i64 184), align 8, !tbaa !5
  %26 = add nsw i64 %24, %25
  store i64 %26, ptr getelementptr inbounds (i8, ptr @f, i64 192), align 16, !tbaa !5
  %27 = add nsw i64 %25, %26
  store i64 %27, ptr getelementptr inbounds (i8, ptr @f, i64 200), align 8, !tbaa !5
  %28 = add nsw i64 %26, %27
  store i64 %28, ptr getelementptr inbounds (i8, ptr @f, i64 208), align 16, !tbaa !5
  %29 = add nsw i64 %27, %28
  store i64 %29, ptr getelementptr inbounds (i8, ptr @f, i64 216), align 8, !tbaa !5
  %30 = add nsw i64 %28, %29
  store i64 %30, ptr getelementptr inbounds (i8, ptr @f, i64 224), align 16, !tbaa !5
  %31 = add nsw i64 %29, %30
  store i64 %31, ptr getelementptr inbounds (i8, ptr @f, i64 232), align 8, !tbaa !5
  %32 = add nsw i64 %30, %31
  store i64 %32, ptr getelementptr inbounds (i8, ptr @f, i64 240), align 16, !tbaa !5
  %33 = add nsw i64 %31, %32
  store i64 %33, ptr getelementptr inbounds (i8, ptr @f, i64 248), align 8, !tbaa !5
  %34 = add nsw i64 %32, %33
  store i64 %34, ptr getelementptr inbounds (i8, ptr @f, i64 256), align 16, !tbaa !5
  %35 = add nsw i64 %33, %34
  store i64 %35, ptr getelementptr inbounds (i8, ptr @f, i64 264), align 8, !tbaa !5
  %36 = add nsw i64 %34, %35
  store i64 %36, ptr getelementptr inbounds (i8, ptr @f, i64 272), align 16, !tbaa !5
  %37 = add nsw i64 %35, %36
  store i64 %37, ptr getelementptr inbounds (i8, ptr @f, i64 280), align 8, !tbaa !5
  %38 = add nsw i64 %36, %37
  store i64 %38, ptr getelementptr inbounds (i8, ptr @f, i64 288), align 16, !tbaa !5
  %39 = add nsw i64 %37, %38
  store i64 %39, ptr getelementptr inbounds (i8, ptr @f, i64 296), align 8, !tbaa !5
  %40 = add nsw i64 %38, %39
  store i64 %40, ptr getelementptr inbounds (i8, ptr @f, i64 304), align 16, !tbaa !5
  %41 = add nsw i64 %39, %40
  store i64 %41, ptr getelementptr inbounds (i8, ptr @f, i64 312), align 8, !tbaa !5
  %42 = add nsw i64 %40, %41
  store i64 %42, ptr getelementptr inbounds (i8, ptr @f, i64 320), align 16, !tbaa !5
  %43 = add nsw i64 %41, %42
  store i64 %43, ptr getelementptr inbounds (i8, ptr @f, i64 328), align 8, !tbaa !5
  %44 = add nsw i64 %42, %43
  store i64 %44, ptr getelementptr inbounds (i8, ptr @f, i64 336), align 16, !tbaa !5
  %45 = add nsw i64 %43, %44
  store i64 %45, ptr getelementptr inbounds (i8, ptr @f, i64 344), align 8, !tbaa !5
  %46 = add nsw i64 %44, %45
  store i64 %46, ptr getelementptr inbounds (i8, ptr @f, i64 352), align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1)
  %48 = load i32, ptr %1, align 4, !tbaa !9
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %1, align 4, !tbaa !9
  %.not6 = icmp eq i32 %48, 0
  br i1 %.not6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  call void @_Z5solvev()
  %50 = load i32, ptr %1, align 4, !tbaa !9
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr %1, align 4, !tbaa !9
  %.not = icmp eq i32 %50, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #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 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 #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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass