; LLVM IR from fwip/fastqz :: libzpaq.ll (ZN7libzpaq4SHA16resultEv)

; 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.libzpaq::SHA1" = type { i32, i32, [5 x i32], [80 x i32], [20 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 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 @_ZN7libzpaq4SHA14initEv(ptr noundef nonnull align 4 dereferenceable(368)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7libzpaq4SHA16resultEv(ptr noundef nonnull align 4 dereferenceable(368) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %7 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %8, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %9 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !13
  store i32 %10, ptr %4, align 4, !tbaa !12
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef 128)
  br label %11

11:                                               ; preds = %16, %1
  %12 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = and i32 %13, 511
  %15 = icmp ne i32 %14, 448
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef 0)
  br label %11, !llvm.loop !14

17:                                               ; preds = %11
  %18 = load i32, ptr %3, align 4, !tbaa !12
  %19 = lshr i32 %18, 24
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %19)
  %20 = load i32, ptr %3, align 4, !tbaa !12
  %21 = lshr i32 %20, 16
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %21)
  %22 = load i32, ptr %3, align 4, !tbaa !12
  %23 = lshr i32 %22, 8
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %23)
  %24 = load i32, ptr %3, align 4, !tbaa !12
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %24)
  %25 = load i32, ptr %4, align 4, !tbaa !12
  %26 = lshr i32 %25, 24
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %26)
  %27 = load i32, ptr %4, align 4, !tbaa !12
  %28 = lshr i32 %27, 16
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %28)
  %29 = load i32, ptr %4, align 4, !tbaa !12
  %30 = lshr i32 %29, 8
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %30)
  %31 = load i32, ptr %4, align 4, !tbaa !12
  call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %6, i32 noundef %31)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %32

32:                                               ; preds = %87, %17
  %33 = load i32, ptr %5, align 4, !tbaa !12
  %34 = icmp slt i32 %33, 5
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %90

36:                                               ; preds = %32
  %37 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 2
  %38 = load i32, ptr %5, align 4, !tbaa !12
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [5 x i32], ptr %37, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = lshr i32 %41, 24
  %43 = trunc i32 %42 to i8
  %44 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 4
  %45 = load i32, ptr %5, align 4, !tbaa !12
  %46 = mul nsw i32 4, %45
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [20 x i8], ptr %44, i64 0, i64 %47
  store i8 %43, ptr %48, align 1, !tbaa !16
  %49 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 2
  %50 = load i32, ptr %5, align 4, !tbaa !12
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [5 x i32], ptr %49, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !12
  %54 = lshr i32 %53, 16
  %55 = trunc i32 %54 to i8
  %56 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 4
  %57 = load i32, ptr %5, align 4, !tbaa !12
  %58 = mul nsw i32 4, %57
  %59 = add nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [20 x i8], ptr %56, i64 0, i64 %60
  store i8 %55, ptr %61, align 1, !tbaa !16
  %62 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 2
  %63 = load i32, ptr %5, align 4, !tbaa !12
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [5 x i32], ptr %62, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !12
  %67 = lshr i32 %66, 8
  %68 = trunc i32 %67 to i8
  %69 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 4
  %70 = load i32, ptr %5, align 4, !tbaa !12
  %71 = mul nsw i32 4, %70
  %72 = add nsw i32 %71, 2
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [20 x i8], ptr %69, i64 0, i64 %73
  store i8 %68, ptr %74, align 1, !tbaa !16
  %75 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 2
  %76 = load i32, ptr %5, align 4, !tbaa !12
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [5 x i32], ptr %75, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !12
  %80 = trunc i32 %79 to i8
  %81 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 4
  %82 = load i32, ptr %5, align 4, !tbaa !12
  %83 = mul nsw i32 4, %82
  %84 = add nsw i32 %83, 3
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [20 x i8], ptr %81, i64 0, i64 %85
  store i8 %80, ptr %86, align 1, !tbaa !16
  br label %87

87:                                               ; preds = %36
  %88 = load i32, ptr %5, align 4, !tbaa !12
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %5, align 4, !tbaa !12
  br label %32, !llvm.loop !17

90:                                               ; preds = %35
  call void @_ZN7libzpaq4SHA14initEv(ptr noundef nonnull align 4 dereferenceable(368) %6)
  %91 = getelementptr inbounds %"class.libzpaq::SHA1", ptr %6, i32 0, i32 4
  %92 = getelementptr inbounds [20 x i8], ptr %91, i64 0, i64 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret ptr %92
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368), i32 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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, !11, i64 4}
!10 = !{!"_ZTSN7libzpaq4SHA1E", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 28, !7, i64 348}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !15}


; 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 nounwind uwtable
declare dso_local void @_ZN7libzpaq4SHA14initEv(ptr noundef nonnull align 4 dereferenceable(368)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull ptr @_ZN7libzpaq4SHA16resultEv(ptr noundef nonnull align 4 dereferenceable(368) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr %0, align 4, !tbaa !10
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef 128)
  %5 = load i32, ptr %0, align 4, !tbaa !10
  %6 = and i32 %5, 511
  %.not18 = icmp eq i32 %6, 448
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef 0)
  %7 = load i32, ptr %0, align 4, !tbaa !10
  %8 = and i32 %7, 511
  %.not = icmp eq i32 %8, 448
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %1
  %9 = lshr i32 %3, 24
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %9)
  %10 = lshr i32 %3, 16
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %10)
  %11 = lshr i32 %3, 8
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %11)
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %3)
  %12 = lshr i32 %4, 24
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %12)
  %13 = lshr i32 %4, 16
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %13)
  %14 = lshr i32 %4, 8
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %14)
  tail call void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368) %0, i32 noundef %4)
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = getelementptr inbounds i8, ptr %0, i64 348
  %17 = load i32, ptr %15, align 4, !tbaa !13
  %18 = lshr i32 %17, 24
  %19 = trunc nuw i32 %18 to i8
  store i8 %19, ptr %16, align 4, !tbaa !14
  %20 = lshr i32 %17, 16
  %21 = trunc i32 %20 to i8
  %22 = getelementptr inbounds i8, ptr %0, i64 349
  store i8 %21, ptr %22, align 1, !tbaa !14
  %23 = lshr i32 %17, 8
  %24 = trunc i32 %23 to i8
  %25 = getelementptr inbounds i8, ptr %0, i64 350
  store i8 %24, ptr %25, align 2, !tbaa !14
  %26 = trunc i32 %17 to i8
  %27 = getelementptr inbounds i8, ptr %0, i64 351
  store i8 %26, ptr %27, align 1, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %0, i64 12
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = lshr i32 %29, 24
  %31 = trunc nuw i32 %30 to i8
  %32 = getelementptr inbounds i8, ptr %0, i64 352
  store i8 %31, ptr %32, align 4, !tbaa !14
  %33 = lshr i32 %29, 16
  %34 = trunc i32 %33 to i8
  %35 = getelementptr inbounds i8, ptr %0, i64 353
  store i8 %34, ptr %35, align 1, !tbaa !14
  %36 = lshr i32 %29, 8
  %37 = trunc i32 %36 to i8
  %38 = getelementptr inbounds i8, ptr %0, i64 354
  store i8 %37, ptr %38, align 2, !tbaa !14
  %39 = trunc i32 %29 to i8
  %40 = getelementptr inbounds i8, ptr %0, i64 355
  store i8 %39, ptr %40, align 1, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  %42 = load i32, ptr %41, align 4, !tbaa !13
  %43 = lshr i32 %42, 24
  %44 = trunc nuw i32 %43 to i8
  %45 = getelementptr inbounds i8, ptr %0, i64 356
  store i8 %44, ptr %45, align 4, !tbaa !14
  %46 = lshr i32 %42, 16
  %47 = trunc i32 %46 to i8
  %48 = getelementptr inbounds i8, ptr %0, i64 357
  store i8 %47, ptr %48, align 1, !tbaa !14
  %49 = lshr i32 %42, 8
  %50 = trunc i32 %49 to i8
  %51 = getelementptr inbounds i8, ptr %0, i64 358
  store i8 %50, ptr %51, align 2, !tbaa !14
  %52 = trunc i32 %42 to i8
  %53 = getelementptr inbounds i8, ptr %0, i64 359
  store i8 %52, ptr %53, align 1, !tbaa !14
  %54 = getelementptr inbounds i8, ptr %0, i64 20
  %55 = load i32, ptr %54, align 4, !tbaa !13
  %56 = lshr i32 %55, 24
  %57 = trunc nuw i32 %56 to i8
  %58 = getelementptr inbounds i8, ptr %0, i64 360
  store i8 %57, ptr %58, align 4, !tbaa !14
  %59 = lshr i32 %55, 16
  %60 = trunc i32 %59 to i8
  %61 = getelementptr inbounds i8, ptr %0, i64 361
  store i8 %60, ptr %61, align 1, !tbaa !14
  %62 = lshr i32 %55, 8
  %63 = trunc i32 %62 to i8
  %64 = getelementptr inbounds i8, ptr %0, i64 362
  store i8 %63, ptr %64, align 2, !tbaa !14
  %65 = trunc i32 %55 to i8
  %66 = getelementptr inbounds i8, ptr %0, i64 363
  store i8 %65, ptr %66, align 1, !tbaa !14
  %67 = getelementptr inbounds i8, ptr %0, i64 24
  %68 = load i32, ptr %67, align 4, !tbaa !13
  %69 = lshr i32 %68, 24
  %70 = trunc nuw i32 %69 to i8
  %71 = getelementptr inbounds i8, ptr %0, i64 364
  store i8 %70, ptr %71, align 4, !tbaa !14
  %72 = lshr i32 %68, 16
  %73 = trunc i32 %72 to i8
  %74 = getelementptr inbounds i8, ptr %0, i64 365
  store i8 %73, ptr %74, align 1, !tbaa !14
  %75 = lshr i32 %68, 8
  %76 = trunc i32 %75 to i8
  %77 = getelementptr inbounds i8, ptr %0, i64 366
  store i8 %76, ptr %77, align 2, !tbaa !14
  %78 = trunc i32 %68 to i8
  %79 = getelementptr inbounds i8, ptr %0, i64 367
  store i8 %78, ptr %79, align 1, !tbaa !14
  tail call void @_ZN7libzpaq4SHA14initEv(ptr noundef nonnull align 4 dereferenceable(368) %0)
  ret ptr %16
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7libzpaq4SHA13putEi(ptr noundef nonnull align 4 dereferenceable(368), i32 noundef) local_unnamed_addr #0 align 2

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

!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 4}
!6 = !{!"_ZTSN7libzpaq4SHA1E", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 28, !8, i64 348}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = !{!8, !8, i64 0}


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