; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (342A-XeniaAndDivisors)

; 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 [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = 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 [8 x i64], align 16
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 64, ptr %3) #4
  call void @llvm.memset.p0.i64(ptr align 16 %3, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %22, %0
  %11 = load i64, ptr %5, align 8, !tbaa !5
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %13 = icmp slt i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %25

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

22:                                               ; preds = %15
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = add nsw i64 %23, 1
  store i64 %24, ptr %5, align 8, !tbaa !5
  br label %10, !llvm.loop !11

25:                                               ; preds = %14
  %26 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 5
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = icmp sgt i64 %27, 0
  br i1 %28, label %57, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 7
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %57, label %33

33:                                               ; preds = %29
  %34 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 1
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = load i64, ptr %2, align 8, !tbaa !5
  %37 = sdiv i64 %36, 3
  %38 = icmp ne i64 %35, %37
  br i1 %38, label %57, label %39

39:                                               ; preds = %33
  %40 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 2
  %41 = load i64, ptr %40, align 16, !tbaa !5
  %42 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 4
  %43 = load i64, ptr %42, align 16, !tbaa !5
  %44 = icmp slt i64 %41, %43
  br i1 %44, label %57, label %45

45:                                               ; preds = %39
  %46 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 6
  %47 = load i64, ptr %46, align 16, !tbaa !5
  %48 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 2
  %49 = load i64, ptr %48, align 16, !tbaa !5
  %50 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 3
  %51 = load i64, ptr %50, align 8, !tbaa !5
  %52 = add nsw i64 %49, %51
  %53 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 4
  %54 = load i64, ptr %53, align 16, !tbaa !5
  %55 = sub nsw i64 %52, %54
  %56 = icmp ne i64 %47, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %45, %39, %33, %29, %25
  %58 = call i32 @puts(ptr noundef @.str.2)
  br label %99

59:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %68, %59
  %61 = load i64, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 4
  %63 = load i64, ptr %62, align 16, !tbaa !5
  %64 = icmp slt i64 %61, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %71

66:                                               ; preds = %60
  %67 = call i32 @puts(ptr noundef @.str.3)
  br label %68

68:                                               ; preds = %66
  %69 = load i64, ptr %6, align 8, !tbaa !5
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %6, align 8, !tbaa !5
  br label %60, !llvm.loop !13

71:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %83, %71
  %73 = load i64, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 2
  %75 = load i64, ptr %74, align 16, !tbaa !5
  %76 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 4
  %77 = load i64, ptr %76, align 16, !tbaa !5
  %78 = sub nsw i64 %75, %77
  %79 = icmp slt i64 %73, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %86

81:                                               ; preds = %72
  %82 = call i32 @puts(ptr noundef @.str.4)
  br label %83

83:                                               ; preds = %81
  %84 = load i64, ptr %7, align 8, !tbaa !5
  %85 = add nsw i64 %84, 1
  store i64 %85, ptr %7, align 8, !tbaa !5
  br label %72, !llvm.loop !14

86:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %95, %86
  %88 = load i64, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds [8 x i64], ptr %3, i64 0, i64 3
  %90 = load i64, ptr %89, align 8, !tbaa !5
  %91 = icmp slt i64 %88, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %98

93:                                               ; preds = %87
  %94 = call i32 @puts(ptr noundef @.str.5)
  br label %95

95:                                               ; preds = %93
  %96 = load i64, ptr %8, align 8, !tbaa !5
  %97 = add nsw i64 %96, 1
  store i64 %97, ptr %8, align 8, !tbaa !5
  br label %87, !llvm.loop !15

98:                                               ; preds = %92
  br label %99

99:                                               ; preds = %98, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 64, 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 @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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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"

@.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 [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = 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 [8 x i64], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  store i64 0, ptr %1, align 8, !tbaa !5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %2, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = icmp sgt i64 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge.thread

._crit_edge:                                      ; preds = %.lr.ph
  %.phi.trans.insert = getelementptr inbounds i8, ptr %2, i64 40
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.phi.trans.insert29 = getelementptr inbounds i8, ptr %2, i64 56
  %.pre30 = load i64, ptr %.phi.trans.insert29, align 8
  %7 = icmp sgt i64 %.pre, 0
  %8 = icmp sgt i64 %.pre30, 0
  %9 = select i1 %7, i1 true, i1 %8
  br i1 %9, label %36, label %._crit_edge.thread

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01219 = phi i64 [ %16, %.lr.ph ], [ 0, %0 ]
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [8 x i64], ptr %2, i64 0, i64 %12
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = add nsw i64 %14, 1
  store i64 %15, ptr %13, align 8, !tbaa !5
  %16 = add nuw nsw i64 %.01219, 1
  %17 = load i64, ptr %1, align 8, !tbaa !5
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge.thread:                               ; preds = %0, %._crit_edge
  %.lcssa33 = phi i64 [ %17, %._crit_edge ], [ %5, %0 ]
  %19 = getelementptr inbounds i8, ptr %2, i64 8
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = sdiv i64 %.lcssa33, 3
  %.not = icmp eq i64 %20, %21
  br i1 %.not, label %22, label %36

22:                                               ; preds = %._crit_edge.thread
  %23 = getelementptr inbounds i8, ptr %2, i64 16
  %24 = load i64, ptr %23, align 16, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %2, i64 32
  %26 = load i64, ptr %25, align 16, !tbaa !5
  %27 = icmp slt i64 %24, %26
  br i1 %27, label %36, label %28

28:                                               ; preds = %22
  %29 = getelementptr inbounds i8, ptr %2, i64 48
  %30 = load i64, ptr %29, align 16, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %2, i64 24
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = sub i64 %24, %26
  %34 = add i64 %33, %32
  %.not16 = icmp eq i64 %30, %34
  br i1 %.not16, label %.preheader18, label %36

.preheader18:                                     ; preds = %28
  %35 = icmp sgt i64 %26, 0
  br i1 %35, label %.lr.ph21, label %.preheader17

36:                                               ; preds = %28, %22, %._crit_edge.thread, %._crit_edge
  %37 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.loopexit

.preheader17:                                     ; preds = %.lr.ph21, %.preheader18
  %38 = icmp sgt i64 %33, 0
  br i1 %38, label %.lr.ph23, label %.preheader

.lr.ph21:                                         ; preds = %.preheader18, %.lr.ph21
  %.01120 = phi i64 [ %40, %.lr.ph21 ], [ 0, %.preheader18 ]
  %39 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %40 = add nuw nsw i64 %.01120, 1
  %exitcond.not = icmp eq i64 %40, %26
  br i1 %exitcond.not, label %.preheader17, label %.lr.ph21, !llvm.loop !13

.preheader:                                       ; preds = %.lr.ph23, %.preheader17
  %41 = icmp sgt i64 %32, 0
  br i1 %41, label %.lr.ph25, label %.loopexit

.lr.ph23:                                         ; preds = %.preheader17, %.lr.ph23
  %.01022 = phi i64 [ %43, %.lr.ph23 ], [ 0, %.preheader17 ]
  %42 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.4)
  %43 = add nuw nsw i64 %.01022, 1
  %exitcond27.not = icmp eq i64 %43, %33
  br i1 %exitcond27.not, label %.preheader, label %.lr.ph23, !llvm.loop !14

.lr.ph25:                                         ; preds = %.preheader, %.lr.ph25
  %.024 = phi i64 [ %45, %.lr.ph25 ], [ 0, %.preheader ]
  %44 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  %45 = add nuw nsw i64 %.024, 1
  %exitcond28.not = icmp eq i64 %45, %32
  br i1 %exitcond28.not, label %.loopexit, label %.lr.ph25, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph25, %.preheader, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  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 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 @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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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