; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/SHORT/COOK70/Problem D/brute.ll (Z4initv)

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

@VAL = external dso_local global [256 x i64], align 16
@s = external dso_local global [211111 x i8], align 16
@n = external dso_local global i32, align 4
@hsh = external dso_local global [211111 x i64], align 16
@bpw = external dso_local global [211111 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z4initv() #0 {
  %1 = alloca i32, align 4
  store i64 455, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 97), align 8, !tbaa !5
  store i64 563, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 98), align 16, !tbaa !5
  store i64 928, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 99), align 8, !tbaa !5
  store i64 468, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 100), align 16, !tbaa !5
  store i64 510, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 101), align 8, !tbaa !5
  store i64 590, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 102), align 16, !tbaa !5
  store i64 186, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 103), align 8, !tbaa !5
  store i64 514, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 104), align 16, !tbaa !5
  store i64 633, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 105), align 8, !tbaa !5
  store i64 797, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 106), align 16, !tbaa !5
  store i64 95, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 107), align 8, !tbaa !5
  store i64 305, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 108), align 16, !tbaa !5
  store i64 92, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 109), align 8, !tbaa !5
  store i64 813, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 110), align 16, !tbaa !5
  store i64 697, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 111), align 8, !tbaa !5
  store i64 43, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 112), align 16, !tbaa !5
  store i64 987, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 113), align 8, !tbaa !5
  store i64 969, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 114), align 16, !tbaa !5
  store i64 657, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 115), align 8, !tbaa !5
  store i64 619, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 116), align 16, !tbaa !5
  store i64 159, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 117), align 8, !tbaa !5
  store i64 16, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 118), align 16, !tbaa !5
  store i64 531, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 119), align 8, !tbaa !5
  store i64 60, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 120), align 16, !tbaa !5
  store i64 191, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 121), align 8, !tbaa !5
  store i64 243, ptr getelementptr inbounds ([256 x i64], ptr @VAL, i64 0, i64 122), align 16, !tbaa !5
  store i64 0, ptr @hsh, align 16, !tbaa !5
  store i64 1, ptr @bpw, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %2

2:                                                ; preds = %36, %0
  %3 = load i32, ptr %1, align 4, !tbaa !9
  %4 = load i32, ptr @n, align 4, !tbaa !9
  %5 = icmp slt i32 %3, %4
  br i1 %5, label %7, label %6

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

7:                                                ; preds = %2
  %8 = load i32, ptr %1, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [211111 x i64], ptr @hsh, i64 0, i64 %9
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = mul nsw i64 %11, 1005
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [211111 x i8], ptr @s, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i64
  %18 = getelementptr inbounds [256 x i64], ptr @VAL, i64 0, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = add nsw i64 %12, %19
  %21 = srem i64 %20, 1000000009
  %22 = load i32, ptr %1, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [211111 x i64], ptr @hsh, i64 0, i64 %24
  store i64 %21, ptr %25, align 8, !tbaa !5
  %26 = load i32, ptr %1, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [211111 x i64], ptr @bpw, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = mul nsw i64 %29, 1005
  %31 = srem i64 %30, 1000000009
  %32 = load i32, ptr %1, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [211111 x i64], ptr @bpw, i64 0, i64 %34
  store i64 %31, ptr %35, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %7
  %37 = load i32, ptr %1, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %1, align 4, !tbaa !9
  br label %2, !llvm.loop !12

39:                                               ; preds = %6
  ret void
}

; 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

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@VAL = external dso_local local_unnamed_addr global [256 x i64], align 16
@s = external dso_local local_unnamed_addr global [211111 x i8], align 16
@n = external dso_local local_unnamed_addr global i32, align 4
@hsh = external dso_local local_unnamed_addr global [211111 x i64], align 16
@bpw = external dso_local local_unnamed_addr global [211111 x i64], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 {
  store i64 455, ptr getelementptr inbounds (i8, ptr @VAL, i64 776), align 8, !tbaa !5
  store i64 563, ptr getelementptr inbounds (i8, ptr @VAL, i64 784), align 16, !tbaa !5
  store i64 928, ptr getelementptr inbounds (i8, ptr @VAL, i64 792), align 8, !tbaa !5
  store i64 468, ptr getelementptr inbounds (i8, ptr @VAL, i64 800), align 16, !tbaa !5
  store i64 510, ptr getelementptr inbounds (i8, ptr @VAL, i64 808), align 8, !tbaa !5
  store i64 590, ptr getelementptr inbounds (i8, ptr @VAL, i64 816), align 16, !tbaa !5
  store i64 186, ptr getelementptr inbounds (i8, ptr @VAL, i64 824), align 8, !tbaa !5
  store i64 514, ptr getelementptr inbounds (i8, ptr @VAL, i64 832), align 16, !tbaa !5
  store i64 633, ptr getelementptr inbounds (i8, ptr @VAL, i64 840), align 8, !tbaa !5
  store i64 797, ptr getelementptr inbounds (i8, ptr @VAL, i64 848), align 16, !tbaa !5
  store i64 95, ptr getelementptr inbounds (i8, ptr @VAL, i64 856), align 8, !tbaa !5
  store i64 305, ptr getelementptr inbounds (i8, ptr @VAL, i64 864), align 16, !tbaa !5
  store i64 92, ptr getelementptr inbounds (i8, ptr @VAL, i64 872), align 8, !tbaa !5
  store i64 813, ptr getelementptr inbounds (i8, ptr @VAL, i64 880), align 16, !tbaa !5
  store i64 697, ptr getelementptr inbounds (i8, ptr @VAL, i64 888), align 8, !tbaa !5
  store i64 43, ptr getelementptr inbounds (i8, ptr @VAL, i64 896), align 16, !tbaa !5
  store i64 987, ptr getelementptr inbounds (i8, ptr @VAL, i64 904), align 8, !tbaa !5
  store i64 969, ptr getelementptr inbounds (i8, ptr @VAL, i64 912), align 16, !tbaa !5
  store i64 657, ptr getelementptr inbounds (i8, ptr @VAL, i64 920), align 8, !tbaa !5
  store i64 619, ptr getelementptr inbounds (i8, ptr @VAL, i64 928), align 16, !tbaa !5
  store i64 159, ptr getelementptr inbounds (i8, ptr @VAL, i64 936), align 8, !tbaa !5
  store i64 16, ptr getelementptr inbounds (i8, ptr @VAL, i64 944), align 16, !tbaa !5
  store i64 531, ptr getelementptr inbounds (i8, ptr @VAL, i64 952), align 8, !tbaa !5
  store i64 60, ptr getelementptr inbounds (i8, ptr @VAL, i64 960), align 16, !tbaa !5
  store i64 191, ptr getelementptr inbounds (i8, ptr @VAL, i64 968), align 8, !tbaa !5
  store i64 243, ptr getelementptr inbounds (i8, ptr @VAL, i64 976), align 16, !tbaa !5
  store i64 0, ptr @hsh, align 16, !tbaa !5
  store i64 1, ptr @bpw, align 16, !tbaa !5
  %1 = load i32, ptr @n, align 4, !tbaa !9
  %2 = icmp sgt i32 %1, 0
  br i1 %2, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %3 = phi i64 [ 1, %.lr.ph.preheader ], [ %15, %.lr.ph ]
  %4 = phi i64 [ 0, %.lr.ph.preheader ], [ %12, %.lr.ph ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %5 = mul nsw i64 %4, 1005
  %6 = getelementptr inbounds [211111 x i8], ptr @s, i64 0, i64 %indvars.iv
  %7 = load i8, ptr %6, align 1, !tbaa !11
  %8 = sext i8 %7 to i64
  %9 = getelementptr inbounds [256 x i64], ptr @VAL, i64 0, i64 %8
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = add nsw i64 %10, %5
  %12 = srem i64 %11, 1000000009
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = getelementptr inbounds [211111 x i64], ptr @hsh, i64 0, i64 %indvars.iv.next
  store i64 %12, ptr %13, align 8, !tbaa !5
  %14 = mul nsw i64 %3, 1005
  %15 = srem i64 %14, 1000000009
  %16 = getelementptr inbounds [211111 x i64], ptr @bpw, i64 0, i64 %indvars.iv.next
  store i64 %15, ptr %16, align 8, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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" }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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