; LLVM IR from DionysiosB/CodeForces :: 1100-1199 (1184A1-HeidiLearnsHashingEasy)

; 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 [11 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 i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 1, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %57, %0
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = sitofp i64 %10 to double
  %12 = fcmp ole double %11, 1.000000e+06
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  br label %60

14:                                               ; preds = %9
  %15 = load i64, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %5, align 8, !tbaa !5
  %17 = mul nsw i64 %15, %16
  %18 = load i64, ptr %5, align 8, !tbaa !5
  %19 = mul nsw i64 3, %18
  %20 = add nsw i64 %17, %19
  %21 = add nsw i64 %20, 1
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = icmp sgt i64 %21, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %14
  store i32 2, ptr %6, align 4
  br label %60

25:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %5, align 8, !tbaa !5
  %29 = mul nsw i64 %27, %28
  %30 = sub nsw i64 %26, %29
  %31 = load i64, ptr %5, align 8, !tbaa !5
  %32 = sub nsw i64 %30, %31
  %33 = sub nsw i64 %32, 1
  %34 = load i64, ptr %5, align 8, !tbaa !5
  %35 = mul nsw i64 2, %34
  %36 = sdiv i64 %33, %35
  store i64 %36, ptr %7, align 8, !tbaa !5
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = mul nsw i64 %37, %38
  %40 = load i64, ptr %5, align 8, !tbaa !5
  %41 = mul nsw i64 2, %40
  %42 = load i64, ptr %7, align 8, !tbaa !5
  %43 = mul nsw i64 %41, %42
  %44 = add nsw i64 %39, %43
  %45 = load i64, ptr %5, align 8, !tbaa !5
  %46 = add nsw i64 %44, %45
  %47 = add nsw i64 %46, 1
  %48 = load i64, ptr %2, align 8, !tbaa !5
  %49 = icmp eq i64 %47, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %25
  %51 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %51, ptr %3, align 8, !tbaa !5
  %52 = load i64, ptr %7, align 8, !tbaa !5
  store i64 %52, ptr %4, align 8, !tbaa !5
  store i32 2, ptr %6, align 4
  br label %54

53:                                               ; preds = %25
  store i32 0, ptr %6, align 4
  br label %54

54:                                               ; preds = %53, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %55 = load i32, ptr %6, align 4
  switch i32 %55, label %60 [
    i32 0, label %56
  ]

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56
  %58 = load i64, ptr %5, align 8, !tbaa !5
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %5, align 8, !tbaa !5
  br label %9, !llvm.loop !9

60:                                               ; preds = %54, %24, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %61

61:                                               ; preds = %60
  %62 = load i64, ptr %3, align 8, !tbaa !5
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %71

64:                                               ; preds = %61
  %65 = load i64, ptr %4, align 8, !tbaa !5
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %71

67:                                               ; preds = %64
  %68 = load i64, ptr %3, align 8, !tbaa !5
  %69 = load i64, ptr %4, align 8, !tbaa !5
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %68, i64 noundef %69)
  br label %73

71:                                               ; preds = %64, %61
  %72 = call i32 @puts(ptr noundef @.str.2)
  br label %73

73:                                               ; preds = %71, %67
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %74 = load i32, ptr %1, align 4
  ret i32 %74
}

; 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

declare i32 @puts(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 = !{!"long long", !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"

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %0, %18
  %.02330 = phi i64 [ 1, %0 ], [ %15, %18 ]
  %5 = add nuw nsw i64 %.02330, 3
  %6 = mul nuw nsw i64 %5, %.02330
  %.not = icmp slt i64 %6, %3
  br i1 %.not, label %7, label %.thread

7:                                                ; preds = %4
  %8 = mul nuw nsw i64 %.02330, %.02330
  %9 = add nuw nsw i64 %8, %.02330
  %10 = xor i64 %9, -1
  %11 = add nsw i64 %3, %10
  %12 = shl nuw nsw i64 %.02330, 1
  %13 = sdiv i64 %11, %12
  %14 = mul nsw i64 %13, %12
  %15 = add nuw nsw i64 %.02330, 1
  %16 = add nuw i64 %15, %8
  %17 = add i64 %16, %14
  %.not29 = icmp eq i64 %17, %3
  br i1 %.not29, label %19, label %18

18:                                               ; preds = %7
  %exitcond.not = icmp eq i64 %15, 1000001
  br i1 %exitcond.not, label %.thread, label %4, !llvm.loop !9

19:                                               ; preds = %7
  %.not35 = icmp eq i64 %13, 0
  br i1 %.not35, label %.thread, label %20

20:                                               ; preds = %19
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.02330, i64 noundef %13)
  br label %23

.thread:                                          ; preds = %4, %18, %19
  %22 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %23

23:                                               ; preds = %.thread, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  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 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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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