; LLVM IR from imkcat/CatCrypto :: Sources/ModuleMaps/MD6 (md6_mode)

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

%struct.md6_state = type { i32, i32, [128 x i8], [129 x i8], i32, i64, i64, i32, [8 x i64], i32, i32, i32, i32, [29 x [64 x i64]], [29 x i32], [29 x i64] }

@md6_compute_hex_hashval.hex_digits = external hidden global [17 x i8], align 16

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @md6_compute_hex_hashval(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i32 3, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %68

9:                                                ; preds = %1
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %55, %9
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.md6_state, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = add nsw i32 %14, 7
  %16 = sdiv i32 %15, 8
  %17 = icmp slt i32 %11, %16
  br i1 %17, label %18, label %58

18:                                               ; preds = %10
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.md6_state, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [128 x i8], ptr %20, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !14
  %25 = zext i8 %24 to i32
  %26 = ashr i32 %25, 4
  %27 = and i32 %26, 15
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [17 x i8], ptr @md6_compute_hex_hashval.hex_digits, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !14
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.md6_state, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = mul nsw i32 2, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [129 x i8], ptr %32, i64 0, i64 %35
  store i8 %30, ptr %36, align 1, !tbaa !14
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.md6_state, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [128 x i8], ptr %38, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !14
  %43 = zext i8 %42 to i32
  %44 = and i32 %43, 15
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [17 x i8], ptr @md6_compute_hex_hashval.hex_digits, i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !14
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.md6_state, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = mul nsw i32 2, %50
  %52 = add nsw i32 %51, 1
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [129 x i8], ptr %49, i64 0, i64 %53
  store i8 %47, ptr %54, align 1, !tbaa !14
  br label %55

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

58:                                               ; preds = %10
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.md6_state, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.md6_state, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = add nsw i32 %63, 3
  %65 = sdiv i32 %64, 4
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [129 x i8], ptr %60, i64 0, i64 %66
  store i8 0, ptr %67, align 1, !tbaa !14
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %68

68:                                               ; preds = %58, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %69 = load i32, ptr %2, align 4
  ret i32 %69
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 136, !10, i64 268, !13, i64 272, !13, i64 280, !10, i64 288, !7, i64 296, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !7, i64 376, !7, i64 15224, !7, i64 15344}
!13 = !{!"long", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@md6_compute_hex_hashval.hex_digits = external hidden local_unnamed_addr global [17 x i8], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 4) i32 @md6_compute_hex_hashval(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %29, label %.preheader

.preheader:                                       ; preds = %1
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %5 = add nuw nsw i32 %3, 7
  %6 = lshr i32 %5, 3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = getelementptr inbounds i8, ptr %0, i64 136
  %wide.trip.count = zext nneg i32 %6 to i64
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %10 = getelementptr inbounds [128 x i8], ptr %7, i64 0, i64 %indvars.iv
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = lshr i8 %11, 4
  %13 = zext nneg i8 %12 to i64
  %14 = getelementptr inbounds [17 x i8], ptr @md6_compute_hex_hashval.hex_digits, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = shl nuw nsw i64 %indvars.iv, 1
  %17 = getelementptr inbounds [129 x i8], ptr %8, i64 0, i64 %16
  store i8 %15, ptr %17, align 1, !tbaa !11
  %18 = and i8 %11, 15
  %19 = zext nneg i8 %18 to i64
  %20 = getelementptr inbounds [17 x i8], ptr @md6_compute_hex_hashval.hex_digits, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = or disjoint i64 %16, 1
  %23 = getelementptr inbounds [129 x i8], ptr %8, i64 0, i64 %22
  store i8 %21, ptr %23, align 1, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %9, !llvm.loop !12

._crit_edge:                                      ; preds = %9, %.preheader
  %24 = getelementptr inbounds i8, ptr %0, i64 136
  %25 = add nsw i32 %3, 3
  %26 = sdiv i32 %25, 4
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [129 x i8], ptr %24, i64 0, i64 %27
  store i8 0, ptr %28, align 1, !tbaa !11
  br label %29

29:                                               ; preds = %1, %._crit_edge
  %.014 = phi i32 [ 0, %._crit_edge ], [ 3, %1 ]
  ret i32 %.014
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 136, !7, i64 268, !10, i64 272, !10, i64 280, !7, i64 288, !8, i64 296, !7, i64 360, !7, i64 364, !7, i64 368, !7, i64 372, !8, i64 376, !8, i64 15224, !8, i64 15344}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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