; LLVM IR from intuitive-robots/mdt_policy :: pyhash-0.9.3/src/smhasher/sha1.ll (Z10SHA1_FinalP8SHA1_CTXPh)

; 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.SHA1_CTX = type { [5 x i32], [2 x i32], [64 x i8] }

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef, ptr noundef, i64 noundef) #2

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

8:                                                ; preds = %30, %2
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp ult i32 %9, 8
  br i1 %10, label %11, label %33

11:                                               ; preds = %8
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.SHA1_CTX, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = icmp uge i32 %14, 4
  %16 = zext i1 %15 to i64
  %17 = select i1 %15, i32 0, i32 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2 x i32], ptr %13, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = and i32 %21, 3
  %23 = sub i32 3, %22
  %24 = mul i32 %23, 8
  %25 = lshr i32 %20, %24
  %26 = trunc i32 %25 to i8
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds [8 x i8], ptr %6, i64 0, i64 %28
  store i8 %26, ptr %29, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %11
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = add i32 %31, 1
  store i32 %32, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !12

33:                                               ; preds = %8
  store i8 -128, ptr %7, align 1, !tbaa !11
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef %34, ptr noundef %7, i64 noundef 1)
  br label %35

35:                                               ; preds = %42, %33
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.SHA1_CTX, ptr %36, i32 0, i32 1
  %38 = getelementptr inbounds [2 x i32], ptr %37, i64 0, i64 0
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = and i32 %39, 504
  %41 = icmp ne i32 %40, 448
  br i1 %41, label %42, label %44

42:                                               ; preds = %35
  store i8 0, ptr %7, align 1, !tbaa !11
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef %43, ptr noundef %7, i64 noundef 1)
  br label %35, !llvm.loop !14

44:                                               ; preds = %35
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds [8 x i8], ptr %6, i64 0, i64 0
  call void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef %45, ptr noundef %46, i64 noundef 8)
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %68, %44
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = icmp ult i32 %48, 20
  br i1 %49, label %50, label %71

50:                                               ; preds = %47
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.SHA1_CTX, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = lshr i32 %53, 2
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds [5 x i32], ptr %52, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = and i32 %58, 3
  %60 = sub i32 3, %59
  %61 = mul i32 %60, 8
  %62 = lshr i32 %57, %61
  %63 = trunc i32 %62 to i8
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %64, i64 %66
  store i8 %63, ptr %67, align 1, !tbaa !11
  br label %68

68:                                               ; preds = %50
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = add i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !9
  br label %47, !llvm.loop !15

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10SHA1_FinalP8SHA1_CTXPh(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #2 {
  %3 = alloca [8 x i8], align 1
  %4 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 20
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = lshr i32 %7, 24
  %9 = trunc nuw i32 %8 to i8
  store i8 %9, ptr %3, align 1, !tbaa !9
  %10 = lshr i32 %7, 16
  %11 = trunc i32 %10 to i8
  %12 = getelementptr inbounds i8, ptr %3, i64 1
  store i8 %11, ptr %12, align 1, !tbaa !9
  %13 = lshr i32 %7, 8
  %14 = trunc i32 %13 to i8
  %15 = getelementptr inbounds i8, ptr %3, i64 2
  store i8 %14, ptr %15, align 1, !tbaa !9
  %16 = trunc i32 %7 to i8
  %17 = getelementptr inbounds i8, ptr %3, i64 3
  store i8 %16, ptr %17, align 1, !tbaa !9
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = lshr i32 %18, 24
  %20 = trunc nuw i32 %19 to i8
  %21 = getelementptr inbounds i8, ptr %3, i64 4
  store i8 %20, ptr %21, align 1, !tbaa !9
  %22 = lshr i32 %18, 16
  %23 = trunc i32 %22 to i8
  %24 = getelementptr inbounds i8, ptr %3, i64 5
  store i8 %23, ptr %24, align 1, !tbaa !9
  %25 = lshr i32 %18, 8
  %26 = trunc i32 %25 to i8
  %27 = getelementptr inbounds i8, ptr %3, i64 6
  store i8 %26, ptr %27, align 1, !tbaa !9
  %28 = trunc i32 %18 to i8
  %29 = getelementptr inbounds i8, ptr %3, i64 7
  store i8 %28, ptr %29, align 1, !tbaa !9
  store i8 -128, ptr %4, align 1, !tbaa !9
  call void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef %0, ptr noundef nonnull %4, i64 noundef 1)
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = and i32 %30, 504
  %.not18 = icmp eq i32 %31, 448
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  store i8 0, ptr %4, align 1, !tbaa !9
  call void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef nonnull %0, ptr noundef nonnull %4, i64 noundef 1)
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = and i32 %32, 504
  %.not = icmp eq i32 %33, 448
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %2
  call void @_Z11SHA1_UpdateP8SHA1_CTXPKhm(ptr noundef nonnull %0, ptr noundef nonnull %3, i64 noundef 8)
  %34 = load i32, ptr %0, align 4, !tbaa !5
  %35 = lshr i32 %34, 24
  %36 = trunc nuw i32 %35 to i8
  store i8 %36, ptr %1, align 1, !tbaa !9
  %37 = load i32, ptr %0, align 4, !tbaa !5
  %38 = lshr i32 %37, 16
  %39 = trunc i32 %38 to i8
  %40 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %39, ptr %40, align 1, !tbaa !9
  %41 = load i32, ptr %0, align 4, !tbaa !5
  %42 = lshr i32 %41, 8
  %43 = trunc i32 %42 to i8
  %44 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 %43, ptr %44, align 1, !tbaa !9
  %45 = load i32, ptr %0, align 4, !tbaa !5
  %46 = trunc i32 %45 to i8
  %47 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 %46, ptr %47, align 1, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %0, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = lshr i32 %49, 24
  %51 = trunc nuw i32 %50 to i8
  %52 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 %51, ptr %52, align 1, !tbaa !9
  %53 = load i32, ptr %48, align 4, !tbaa !5
  %54 = lshr i32 %53, 16
  %55 = trunc i32 %54 to i8
  %56 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %55, ptr %56, align 1, !tbaa !9
  %57 = load i32, ptr %48, align 4, !tbaa !5
  %58 = lshr i32 %57, 8
  %59 = trunc i32 %58 to i8
  %60 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %59, ptr %60, align 1, !tbaa !9
  %61 = load i32, ptr %48, align 4, !tbaa !5
  %62 = trunc i32 %61 to i8
  %63 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %62, ptr %63, align 1, !tbaa !9
  %64 = getelementptr inbounds i8, ptr %0, i64 8
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = lshr i32 %65, 24
  %67 = trunc nuw i32 %66 to i8
  %68 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %67, ptr %68, align 1, !tbaa !9
  %69 = load i32, ptr %64, align 4, !tbaa !5
  %70 = lshr i32 %69, 16
  %71 = trunc i32 %70 to i8
  %72 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 %71, ptr %72, align 1, !tbaa !9
  %73 = load i32, ptr %64, align 4, !tbaa !5
  %74 = lshr i32 %73, 8
  %75 = trunc i32 %74 to i8
  %76 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 %75, ptr %76, align 1, !tbaa !9
  %77 = load i32, ptr %64, align 4, !tbaa !5
  %78 = trunc i32 %77 to i8
  %79 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 %78, ptr %79, align 1, !tbaa !9
  %80 = getelementptr inbounds i8, ptr %0, i64 12
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = lshr i32 %81, 24
  %83 = trunc nuw i32 %82 to i8
  %84 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %83, ptr %84, align 1, !tbaa !9
  %85 = load i32, ptr %80, align 4, !tbaa !5
  %86 = lshr i32 %85, 16
  %87 = trunc i32 %86 to i8
  %88 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %87, ptr %88, align 1, !tbaa !9
  %89 = load i32, ptr %80, align 4, !tbaa !5
  %90 = lshr i32 %89, 8
  %91 = trunc i32 %90 to i8
  %92 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 %91, ptr %92, align 1, !tbaa !9
  %93 = load i32, ptr %80, align 4, !tbaa !5
  %94 = trunc i32 %93 to i8
  %95 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 %94, ptr %95, align 1, !tbaa !9
  %96 = getelementptr inbounds i8, ptr %0, i64 16
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = lshr i32 %97, 24
  %99 = trunc nuw i32 %98 to i8
  %100 = getelementptr inbounds i8, ptr %1, i64 16
  store i8 %99, ptr %100, align 1, !tbaa !9
  %101 = load i32, ptr %96, align 4, !tbaa !5
  %102 = lshr i32 %101, 16
  %103 = trunc i32 %102 to i8
  %104 = getelementptr inbounds i8, ptr %1, i64 17
  store i8 %103, ptr %104, align 1, !tbaa !9
  %105 = load i32, ptr %96, align 4, !tbaa !5
  %106 = lshr i32 %105, 8
  %107 = trunc i32 %106 to i8
  %108 = getelementptr inbounds i8, ptr %1, i64 18
  store i8 %107, ptr %108, align 1, !tbaa !9
  %109 = load i32, ptr %96, align 4, !tbaa !5
  %110 = trunc i32 %109 to i8
  %111 = getelementptr inbounds i8, ptr %1, i64 19
  store i8 %110, ptr %111, align 1, !tbaa !9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(92) %0, i8 0, i64 92, i1 false)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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