; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/Other/HFCQ/Problem C/other.ll (Z5solvev)

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

@dp = external dso_local global [110 x [201 x [101 x [3 x i64]]]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z2goiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

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

9:                                                ; preds = %55, %0
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 110
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %58

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

14:                                               ; preds = %51, %13
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

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

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

20:                                               ; preds = %47, %19
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %50

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

26:                                               ; preds = %43, %25
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 3
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %46

30:                                               ; preds = %26
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [110 x [201 x [101 x [3 x i64]]]], ptr @dp, i64 0, i64 %32
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [201 x [101 x [3 x i64]]], ptr %33, i64 0, i64 %35
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [101 x [3 x i64]], ptr %36, i64 0, i64 %38
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [3 x i64], ptr %39, i64 0, i64 %41
  store i64 -1, ptr %42, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %30
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %7, align 4, !tbaa !5
  br label %26, !llvm.loop !11

46:                                               ; preds = %29
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !5
  br label %20, !llvm.loop !13

50:                                               ; preds = %24
  br label %51

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

54:                                               ; preds = %18
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %3, align 4, !tbaa !5
  br label %9, !llvm.loop !15

58:                                               ; preds = %12
  %59 = load i32, ptr %1, align 4, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = call noundef i64 @_Z2goiiii(i32 noundef 0, i32 noundef %59, i32 noundef %60, i32 noundef 0)
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %61)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

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

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

attributes #0 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long long", !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"

@dp = external dso_local local_unnamed_addr global [110 x [201 x [101 x [3 x i64]]]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z2goiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %.not21 = icmp slt i32 %4, 0
  %5 = load i32, ptr %2, align 4
  %.not1519 = icmp slt i32 %5, 0
  %or.cond = select i1 %.not21, i1 true, i1 %.not1519
  br i1 %or.cond, label %.split26.us, label %.preheader17.preheader

.preheader17.preheader:                           ; preds = %0
  %6 = add nuw i32 %5, 1
  %7 = zext i32 %6 to i64
  %8 = mul nuw nsw i64 %7, 24
  %9 = add nuw i32 %4, 1
  %wide.trip.count = zext i32 %9 to i64
  %xtraiter = and i64 %wide.trip.count, 7
  %10 = icmp ult i32 %4, 7
  %unroll_iter = and i64 %wide.trip.count, 4294967288
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader17

.preheader17:                                     ; preds = %.preheader17.preheader, %._crit_edge23.split
  %indvar = phi i64 [ 0, %.preheader17.preheader ], [ %indvar.next, %._crit_edge23.split ]
  %11 = mul nuw nsw i64 %indvar, 487224
  %12 = getelementptr i8, ptr @dp, i64 %11
  br i1 %10, label %._crit_edge23.split.unr-lcssa, label %.preheader17.new

.preheader17.new:                                 ; preds = %.preheader17
  %invariant.gep = getelementptr i8, ptr %12, i64 2424
  %invariant.gep41 = getelementptr i8, ptr %12, i64 4848
  %invariant.gep43 = getelementptr i8, ptr %12, i64 7272
  %invariant.gep45 = getelementptr i8, ptr %12, i64 9696
  %invariant.gep47 = getelementptr i8, ptr %12, i64 12120
  %invariant.gep49 = getelementptr i8, ptr %12, i64 14544
  %invariant.gep51 = getelementptr i8, ptr %12, i64 16968
  br label %.preheader16

.split26.us:                                      ; preds = %._crit_edge23.split, %0
  %13 = call noundef i64 @_Z2goiiii(i32 noundef 0, i32 noundef %4, i32 noundef %5, i32 noundef 0)
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %13)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret void

.preheader16:                                     ; preds = %.preheader16, %.preheader17.new
  %indvar31 = phi i64 [ 0, %.preheader17.new ], [ %indvar.next32.7, %.preheader16 ]
  %niter = phi i64 [ 0, %.preheader17.new ], [ %niter.next.7, %.preheader16 ]
  %15 = mul nuw nsw i64 %indvar31, 2424
  %scevgep36 = getelementptr i8, ptr %12, i64 %15
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %scevgep36, i8 -1, i64 %8, i1 false), !tbaa !9
  %16 = mul nuw i64 %indvar31, 2424
  %gep = getelementptr i8, ptr %invariant.gep, i64 %16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep, i8 -1, i64 %8, i1 false), !tbaa !9
  %17 = mul nuw i64 %indvar31, 2424
  %gep42 = getelementptr i8, ptr %invariant.gep41, i64 %17
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep42, i8 -1, i64 %8, i1 false), !tbaa !9
  %18 = mul nuw i64 %indvar31, 2424
  %gep44 = getelementptr i8, ptr %invariant.gep43, i64 %18
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep44, i8 -1, i64 %8, i1 false), !tbaa !9
  %19 = mul nuw i64 %indvar31, 2424
  %gep46 = getelementptr i8, ptr %invariant.gep45, i64 %19
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep46, i8 -1, i64 %8, i1 false), !tbaa !9
  %20 = mul nuw i64 %indvar31, 2424
  %gep48 = getelementptr i8, ptr %invariant.gep47, i64 %20
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep48, i8 -1, i64 %8, i1 false), !tbaa !9
  %21 = mul nuw i64 %indvar31, 2424
  %gep50 = getelementptr i8, ptr %invariant.gep49, i64 %21
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep50, i8 -1, i64 %8, i1 false), !tbaa !9
  %22 = mul nuw i64 %indvar31, 2424
  %gep52 = getelementptr i8, ptr %invariant.gep51, i64 %22
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep52, i8 -1, i64 %8, i1 false), !tbaa !9
  %indvar.next32.7 = add nuw nsw i64 %indvar31, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge23.split.unr-lcssa, label %.preheader16, !llvm.loop !11

._crit_edge23.split.unr-lcssa:                    ; preds = %.preheader16, %.preheader17
  %indvar31.unr = phi i64 [ 0, %.preheader17 ], [ %indvar.next32.7, %.preheader16 ]
  br i1 %lcmp.mod.not, label %._crit_edge23.split, label %.preheader16.epil

.preheader16.epil:                                ; preds = %._crit_edge23.split.unr-lcssa, %.preheader16.epil
  %indvar31.epil = phi i64 [ %indvar.next32.epil, %.preheader16.epil ], [ %indvar31.unr, %._crit_edge23.split.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader16.epil ], [ 0, %._crit_edge23.split.unr-lcssa ]
  %23 = mul nuw nsw i64 %indvar31.epil, 2424
  %scevgep36.epil = getelementptr i8, ptr %12, i64 %23
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %scevgep36.epil, i8 -1, i64 %8, i1 false), !tbaa !9
  %indvar.next32.epil = add nuw nsw i64 %indvar31.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge23.split, label %.preheader16.epil, !llvm.loop !13

._crit_edge23.split:                              ; preds = %.preheader16.epil, %._crit_edge23.split.unr-lcssa
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond40.not = icmp eq i64 %indvar.next, 110
  br i1 %exitcond40.not, label %.split26.us, label %.preheader17, !llvm.loop !15
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { 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 #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 = { 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 long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !12}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass