; LLVM IR from yuikns/panther :: lib/argcv/util/util.ll (ZN5argcv4util9BlzKeygenC2Ev)

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

%"class.argcv::util::BlzKeygen" = type { ptr, [1280 x i64] }

@_ZTVN5argcv4util9BlzKeygenE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5argcv4util9BlzKeygenC2Ev(ptr noundef nonnull align 8 dereferenceable(10248) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN5argcv4util9BlzKeygenE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store i64 1048577, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %4, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %44, %1
  %11 = load i64, ptr %4, align 8, !tbaa !11
  %12 = icmp ult i64 %11, 256
  br i1 %12, label %13, label %47

13:                                               ; preds = %10
  %14 = load i64, ptr %4, align 8, !tbaa !11
  store i64 %14, ptr %5, align 8, !tbaa !11
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %15

15:                                               ; preds = %38, %13
  %16 = load i64, ptr %6, align 8, !tbaa !11
  %17 = icmp ult i64 %16, 5
  br i1 %17, label %18, label %43

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %19 = load i64, ptr %3, align 8, !tbaa !11
  %20 = mul i64 %19, 125
  %21 = add i64 %20, 3
  %22 = urem i64 %21, 2796203
  store i64 %22, ptr %3, align 8, !tbaa !11
  %23 = load i64, ptr %3, align 8, !tbaa !11
  %24 = and i64 %23, 65535
  %25 = shl i64 %24, 16
  store i64 %25, ptr %7, align 8, !tbaa !11
  %26 = load i64, ptr %3, align 8, !tbaa !11
  %27 = mul i64 %26, 125
  %28 = add i64 %27, 3
  %29 = urem i64 %28, 2796203
  store i64 %29, ptr %3, align 8, !tbaa !11
  %30 = load i64, ptr %3, align 8, !tbaa !11
  %31 = and i64 %30, 65535
  store i64 %31, ptr %8, align 8, !tbaa !11
  %32 = load i64, ptr %7, align 8, !tbaa !11
  %33 = load i64, ptr %8, align 8, !tbaa !11
  %34 = or i64 %32, %33
  %35 = getelementptr inbounds %"class.argcv::util::BlzKeygen", ptr %9, i32 0, i32 1
  %36 = load i64, ptr %5, align 8, !tbaa !11
  %37 = getelementptr inbounds [1280 x i64], ptr %35, i64 0, i64 %36
  store i64 %34, ptr %37, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %38

38:                                               ; preds = %18
  %39 = load i64, ptr %6, align 8, !tbaa !11
  %40 = add i64 %39, 1
  store i64 %40, ptr %6, align 8, !tbaa !11
  %41 = load i64, ptr %5, align 8, !tbaa !11
  %42 = add i64 %41, 256
  store i64 %42, ptr %5, align 8, !tbaa !11
  br label %15, !llvm.loop !13

43:                                               ; preds = %15
  br label %44

44:                                               ; preds = %43
  %45 = load i64, ptr %4, align 8, !tbaa !11
  %46 = add i64 %45, 1
  store i64 %46, ptr %4, align 8, !tbaa !11
  br label %10, !llvm.loop !15

47:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@_ZTVN5argcv4util9BlzKeygenE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @_ZN5argcv4util9BlzKeygenC2Ev(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(10248) %0) unnamed_addr #0 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN5argcv4util9BlzKeygenE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  br label %.preheader

.preheader:                                       ; preds = %1, %.preheader
  %.020 = phi i64 [ 1048577, %1 ], [ %.zext.4, %.preheader ]
  %.01319 = phi i64 [ 0, %1 ], [ %58, %.preheader ]
  %3 = mul nuw nsw i64 %.020, 125
  %4 = add nuw nsw i64 %3, 3
  %5 = urem i64 %4, 2796203
  %6 = shl nuw nsw i64 %5, 16
  %7 = and i64 %6, 4294901760
  %8 = trunc nuw nsw i64 %5 to i32
  %9 = mul nuw nsw i32 %8, 125
  %.lhs.trunc = add nuw nsw i32 %9, 3
  %10 = urem i32 %.lhs.trunc, 2796203
  %11 = and i32 %10, 65535
  %12 = zext nneg i32 %11 to i64
  %13 = or disjoint i64 %7, %12
  %14 = getelementptr inbounds [1280 x i64], ptr %2, i64 0, i64 %.01319
  store i64 %13, ptr %14, align 8, !tbaa !8
  %15 = add nuw nsw i64 %.01319, 256
  %16 = mul nuw nsw i32 %10, 125
  %.lhs.trunc21 = add nuw nsw i32 %16, 3
  %17 = urem i32 %.lhs.trunc21, 2796203
  %.zext22 = zext nneg i32 %17 to i64
  %18 = shl nuw nsw i64 %.zext22, 16
  %19 = and i64 %18, 4294901760
  %20 = mul nuw nsw i32 %17, 125
  %.lhs.trunc.1 = add nuw nsw i32 %20, 3
  %21 = urem i32 %.lhs.trunc.1, 2796203
  %22 = and i32 %21, 65535
  %23 = zext nneg i32 %22 to i64
  %24 = or disjoint i64 %19, %23
  %25 = getelementptr inbounds [1280 x i64], ptr %2, i64 0, i64 %15
  store i64 %24, ptr %25, align 8, !tbaa !8
  %26 = add nuw nsw i64 %.01319, 512
  %27 = mul nuw nsw i32 %21, 125
  %.lhs.trunc23 = add nuw nsw i32 %27, 3
  %28 = urem i32 %.lhs.trunc23, 2796203
  %.zext24 = zext nneg i32 %28 to i64
  %29 = shl nuw nsw i64 %.zext24, 16
  %30 = and i64 %29, 4294901760
  %31 = mul nuw nsw i32 %28, 125
  %.lhs.trunc.2 = add nuw nsw i32 %31, 3
  %32 = urem i32 %.lhs.trunc.2, 2796203
  %33 = and i32 %32, 65535
  %34 = zext nneg i32 %33 to i64
  %35 = or disjoint i64 %30, %34
  %36 = getelementptr inbounds [1280 x i64], ptr %2, i64 0, i64 %26
  store i64 %35, ptr %36, align 8, !tbaa !8
  %37 = add nuw nsw i64 %.01319, 768
  %38 = mul nuw nsw i32 %32, 125
  %.lhs.trunc25 = add nuw nsw i32 %38, 3
  %39 = urem i32 %.lhs.trunc25, 2796203
  %.zext26 = zext nneg i32 %39 to i64
  %40 = shl nuw nsw i64 %.zext26, 16
  %41 = and i64 %40, 4294901760
  %42 = mul nuw nsw i32 %39, 125
  %.lhs.trunc.3 = add nuw nsw i32 %42, 3
  %43 = urem i32 %.lhs.trunc.3, 2796203
  %44 = and i32 %43, 65535
  %45 = zext nneg i32 %44 to i64
  %46 = or disjoint i64 %41, %45
  %47 = getelementptr inbounds [1280 x i64], ptr %2, i64 0, i64 %37
  store i64 %46, ptr %47, align 8, !tbaa !8
  %48 = add nuw nsw i64 %.01319, 1024
  %49 = mul nuw nsw i32 %43, 125
  %.lhs.trunc27 = add nuw nsw i32 %49, 3
  %50 = urem i32 %.lhs.trunc27, 2796203
  %.zext28 = zext nneg i32 %50 to i64
  %51 = shl nuw nsw i64 %.zext28, 16
  %52 = and i64 %51, 4294901760
  %53 = mul nuw nsw i32 %50, 125
  %.lhs.trunc.4 = add nuw nsw i32 %53, 3
  %54 = urem i32 %.lhs.trunc.4, 2796203
  %.zext.4 = zext nneg i32 %54 to i64
  %55 = and i64 %.zext.4, 65535
  %56 = or disjoint i64 %55, %52
  %57 = getelementptr inbounds [1280 x i64], ptr %2, i64 0, i64 %48
  store i64 %56, ptr %57, align 8, !tbaa !8
  %58 = add nuw nsw i64 %.01319, 1
  %exitcond.not = icmp eq i64 %58, 256
  br i1 %exitcond.not, label %59, label %.preheader, !llvm.loop !11

59:                                               ; preds = %.preheader
  ret void
}

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


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