; LLVM IR from albertobsd/keyhunt :: rmd160 (rmd160)

; 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.RMD160Context = type { [16 x i32], [5 x i32], i32, i32 }

; 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 void @RMD160Final(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.RMD160Context, ptr %7, i32 0, i32 1
  %9 = getelementptr inbounds [5 x i32], ptr %8, i64 0, i64 0
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.RMD160Context, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds [16 x i32], ptr %11, i64 0, i64 0
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.RMD160Context, ptr %13, i32 0, i32 3
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.RMD160Context, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !12
  call void @RMDFinish(ptr noundef %9, ptr noundef %12, i32 noundef %15, i32 noundef %18)
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %19

19:                                               ; preds = %64, %2
  %20 = load i32, ptr %5, align 4, !tbaa !13
  %21 = icmp slt i32 %20, 5
  br i1 %21, label %22, label %67

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.RMD160Context, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %5, align 4, !tbaa !13
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [5 x i32], ptr %24, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !13
  store i32 %28, ptr %6, align 4, !tbaa !13
  %29 = load i32, ptr %6, align 4, !tbaa !13
  %30 = trunc i32 %29 to i8
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !13
  %33 = mul nsw i32 %32, 4
  %34 = add nsw i32 %33, 0
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %31, i64 %35
  store i8 %30, ptr %36, align 1, !tbaa !14
  %37 = load i32, ptr %6, align 4, !tbaa !13
  %38 = lshr i32 %37, 8
  %39 = trunc i32 %38 to i8
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !13
  %42 = mul nsw i32 %41, 4
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %40, i64 %44
  store i8 %39, ptr %45, align 1, !tbaa !14
  %46 = load i32, ptr %6, align 4, !tbaa !13
  %47 = lshr i32 %46, 16
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !13
  %51 = mul nsw i32 %50, 4
  %52 = add nsw i32 %51, 2
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %49, i64 %53
  store i8 %48, ptr %54, align 1, !tbaa !14
  %55 = load i32, ptr %6, align 4, !tbaa !13
  %56 = lshr i32 %55, 24
  %57 = trunc i32 %56 to i8
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = load i32, ptr %5, align 4, !tbaa !13
  %60 = mul nsw i32 %59, 4
  %61 = add nsw i32 %60, 3
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %58, i64 %62
  store i8 %57, ptr %63, align 1, !tbaa !14
  br label %64

64:                                               ; preds = %22
  %65 = load i32, ptr %5, align 4, !tbaa !13
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %5, align 4, !tbaa !13
  br label %19, !llvm.loop !15

67:                                               ; preds = %19
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 4 %68, i8 0, i64 92, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @RMDFinish(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 88}
!10 = !{!"RMD160Context", !7, i64 0, !7, i64 64, !11, i64 84, !11, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 84}
!13 = !{!11, !11, 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"

; Function Attrs: nounwind uwtable
define dso_local void @RMD160Final(ptr nocapture noundef writeonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 64
  %4 = getelementptr inbounds i8, ptr %1, i64 88
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 84
  %7 = load i32, ptr %6, align 4, !tbaa !10
  tail call void @RMDFinish(ptr noundef nonnull %3, ptr noundef %1, i32 noundef %5, i32 noundef %7)
  %8 = load i32, ptr %3, align 4, !tbaa !11
  %9 = trunc i32 %8 to i8
  store i8 %9, ptr %0, align 1, !tbaa !12
  %10 = lshr i32 %8, 8
  %11 = trunc i32 %10 to i8
  %12 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %11, ptr %12, align 1, !tbaa !12
  %13 = lshr i32 %8, 16
  %14 = trunc i32 %13 to i8
  %15 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %14, ptr %15, align 1, !tbaa !12
  %16 = lshr i32 %8, 24
  %17 = trunc nuw i32 %16 to i8
  %18 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %17, ptr %18, align 1, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %1, i64 68
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = trunc i32 %20 to i8
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 %21, ptr %22, align 1, !tbaa !12
  %23 = lshr i32 %20, 8
  %24 = trunc i32 %23 to i8
  %25 = getelementptr inbounds i8, ptr %0, i64 5
  store i8 %24, ptr %25, align 1, !tbaa !12
  %26 = lshr i32 %20, 16
  %27 = trunc i32 %26 to i8
  %28 = getelementptr inbounds i8, ptr %0, i64 6
  store i8 %27, ptr %28, align 1, !tbaa !12
  %29 = lshr i32 %20, 24
  %30 = trunc nuw i32 %29 to i8
  %31 = getelementptr inbounds i8, ptr %0, i64 7
  store i8 %30, ptr %31, align 1, !tbaa !12
  %32 = getelementptr inbounds i8, ptr %1, i64 72
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = trunc i32 %33 to i8
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %34, ptr %35, align 1, !tbaa !12
  %36 = lshr i32 %33, 8
  %37 = trunc i32 %36 to i8
  %38 = getelementptr inbounds i8, ptr %0, i64 9
  store i8 %37, ptr %38, align 1, !tbaa !12
  %39 = lshr i32 %33, 16
  %40 = trunc i32 %39 to i8
  %41 = getelementptr inbounds i8, ptr %0, i64 10
  store i8 %40, ptr %41, align 1, !tbaa !12
  %42 = lshr i32 %33, 24
  %43 = trunc nuw i32 %42 to i8
  %44 = getelementptr inbounds i8, ptr %0, i64 11
  store i8 %43, ptr %44, align 1, !tbaa !12
  %45 = getelementptr inbounds i8, ptr %1, i64 76
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = trunc i32 %46 to i8
  %48 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %47, ptr %48, align 1, !tbaa !12
  %49 = lshr i32 %46, 8
  %50 = trunc i32 %49 to i8
  %51 = getelementptr inbounds i8, ptr %0, i64 13
  store i8 %50, ptr %51, align 1, !tbaa !12
  %52 = lshr i32 %46, 16
  %53 = trunc i32 %52 to i8
  %54 = getelementptr inbounds i8, ptr %0, i64 14
  store i8 %53, ptr %54, align 1, !tbaa !12
  %55 = lshr i32 %46, 24
  %56 = trunc nuw i32 %55 to i8
  %57 = getelementptr inbounds i8, ptr %0, i64 15
  store i8 %56, ptr %57, align 1, !tbaa !12
  %58 = getelementptr inbounds i8, ptr %1, i64 80
  %59 = load i32, ptr %58, align 4, !tbaa !11
  %60 = trunc i32 %59 to i8
  %61 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %60, ptr %61, align 1, !tbaa !12
  %62 = lshr i32 %59, 8
  %63 = trunc i32 %62 to i8
  %64 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 %63, ptr %64, align 1, !tbaa !12
  %65 = lshr i32 %59, 16
  %66 = trunc i32 %65 to i8
  %67 = getelementptr inbounds i8, ptr %0, i64 18
  store i8 %66, ptr %67, align 1, !tbaa !12
  %68 = lshr i32 %59, 24
  %69 = trunc nuw i32 %68 to i8
  %70 = getelementptr inbounds i8, ptr %0, i64 19
  store i8 %69, ptr %70, align 1, !tbaa !12
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(92) %1, i8 0, i64 92, i1 false)
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @RMDFinish(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

attributes #0 = { 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 nounwind willreturn memory(argmem: write) }

!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, !9, i64 88}
!6 = !{!"RMD160Context", !7, i64 0, !7, i64 64, !9, i64 84, !9, i64 88}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!6, !9, i64 84}
!11 = !{!9, !9, i64 0}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass