; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (md5)

; 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.ByteArray_st = type { ptr, i64 }
%struct.MD5Ctx_st = type { [4 x i32], [2 x i32], [64 x i8] }

@.str = external hidden unnamed_addr constant [13 x i8], align 1

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %16, label %14

14:                                               ; preds = %11
  store i32 2, ptr %10, align 4, !tbaa !9
  %15 = load i32, ptr %10, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 283, i32 noundef %15, ptr noundef null)
  br label %122

16:                                               ; preds = %11
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %24, label %22

22:                                               ; preds = %19
  store i32 2, ptr %10, align 4, !tbaa !9
  %23 = load i32, ptr %10, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 284, i32 noundef %23, ptr noundef null)
  br label %122

24:                                               ; preds = %19
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ByteArray_st, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  store ptr %29, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ByteArray_st, ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !14
  store i64 %32, ptr %6, align 8, !tbaa !15
  br label %33

33:                                               ; preds = %26
  %34 = load i64, ptr %6, align 8, !tbaa !15
  %35 = icmp ule i64 %34, 536870911
  br i1 %35, label %38, label %36

36:                                               ; preds = %33
  store i32 2, ptr %10, align 4, !tbaa !9
  %37 = load i32, ptr %10, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 289, i32 noundef %37, ptr noundef null)
  br label %122

38:                                               ; preds = %33
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.MD5Ctx_st, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds [2 x i32], ptr %42, i64 0, i64 0
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = lshr i32 %44, 3
  %46 = and i32 %45, 63
  %47 = zext i32 %46 to i64
  store i64 %47, ptr %8, align 8, !tbaa !15
  %48 = load i64, ptr %6, align 8, !tbaa !15
  %49 = trunc i64 %48 to i32
  %50 = shl i32 %49, 3
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.MD5Ctx_st, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds [2 x i32], ptr %52, i64 0, i64 0
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = add i32 %54, %50
  store i32 %55, ptr %53, align 4, !tbaa !9
  %56 = load i64, ptr %6, align 8, !tbaa !15
  %57 = trunc i64 %56 to i32
  %58 = shl i32 %57, 3
  %59 = icmp ult i32 %55, %58
  br i1 %59, label %60, label %66

60:                                               ; preds = %40
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.MD5Ctx_st, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds [2 x i32], ptr %62, i64 0, i64 1
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = add i32 %64, 1
  store i32 %65, ptr %63, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %60, %40
  %67 = load i64, ptr %6, align 8, !tbaa !15
  %68 = trunc i64 %67 to i32
  %69 = lshr i32 %68, 29
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MD5Ctx_st, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds [2 x i32], ptr %71, i64 0, i64 1
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = add i32 %73, %69
  store i32 %74, ptr %72, align 4, !tbaa !9
  %75 = load i64, ptr %8, align 8, !tbaa !15
  %76 = sub i64 64, %75
  store i64 %76, ptr %9, align 8, !tbaa !15
  %77 = load i64, ptr %6, align 8, !tbaa !15
  %78 = load i64, ptr %9, align 8, !tbaa !15
  %79 = icmp uge i64 %77, %78
  br i1 %79, label %80, label %110

80:                                               ; preds = %66
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.MD5Ctx_st, ptr %81, i32 0, i32 2
  %83 = load i64, ptr %8, align 8, !tbaa !15
  %84 = getelementptr inbounds [64 x i8], ptr %82, i64 0, i64 %83
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = load i64, ptr %9, align 8, !tbaa !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %84, ptr align 1 %85, i64 %86, i1 false)
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.MD5Ctx_st, ptr %87, i32 0, i32 0
  %89 = getelementptr inbounds [4 x i32], ptr %88, i64 0, i64 0
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.MD5Ctx_st, ptr %90, i32 0, i32 2
  %92 = getelementptr inbounds [64 x i8], ptr %91, i64 0, i64 0
  call void @md5_basic_transform(ptr noundef %89, ptr noundef %92)
  %93 = load i64, ptr %9, align 8, !tbaa !15
  store i64 %93, ptr %7, align 8, !tbaa !15
  br label %94

94:                                               ; preds = %106, %80
  %95 = load i64, ptr %7, align 8, !tbaa !15
  %96 = add i64 %95, 63
  %97 = load i64, ptr %6, align 8, !tbaa !15
  %98 = icmp ult i64 %96, %97
  br i1 %98, label %99, label %109

99:                                               ; preds = %94
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.MD5Ctx_st, ptr %100, i32 0, i32 0
  %102 = getelementptr inbounds [4 x i32], ptr %101, i64 0, i64 0
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = load i64, ptr %7, align 8, !tbaa !15
  %105 = getelementptr inbounds i8, ptr %103, i64 %104
  call void @md5_basic_transform(ptr noundef %102, ptr noundef %105)
  br label %106

106:                                              ; preds = %99
  %107 = load i64, ptr %7, align 8, !tbaa !15
  %108 = add i64 %107, 64
  store i64 %108, ptr %7, align 8, !tbaa !15
  br label %94, !llvm.loop !16

109:                                              ; preds = %94
  store i64 0, ptr %8, align 8, !tbaa !15
  br label %111

110:                                              ; preds = %66
  store i64 0, ptr %7, align 8, !tbaa !15
  br label %111

111:                                              ; preds = %110, %109
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MD5Ctx_st, ptr %112, i32 0, i32 2
  %114 = load i64, ptr %8, align 8, !tbaa !15
  %115 = getelementptr inbounds [64 x i8], ptr %113, i64 0, i64 %114
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = load i64, ptr %7, align 8, !tbaa !15
  %118 = getelementptr inbounds i8, ptr %116, i64 %117
  %119 = load i64, ptr %6, align 8, !tbaa !15
  %120 = load i64, ptr %7, align 8, !tbaa !15
  %121 = sub i64 %119, %120
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %115, ptr align 1 %118, i64 %121, i1 false)
  br label %122

122:                                              ; preds = %111, %36, %22, %14
  %123 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 %123
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @md5_basic_transform(ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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: readwrite) }
attributes #3 = { 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 #4 = { inlinehint 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 #5 = { 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, !6, i64 0}
!12 = !{!"ByteArray_st", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@.str = external hidden unnamed_addr constant [13 x i8], align 1

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @md5_update(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 283, i32 noundef 2, ptr noundef null) #4
  br label %41

4:                                                ; preds = %2
  %.not43 = icmp eq ptr %1, null
  br i1 %.not43, label %5, label %6

5:                                                ; preds = %4
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 284, i32 noundef 2, ptr noundef null) #4
  br label %41

6:                                                ; preds = %4
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = icmp ult i64 %9, 536870912
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 289, i32 noundef 2, ptr noundef null) #4
  br label %41

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = lshr i32 %14, 3
  %16 = and i32 %15, 63
  %17 = zext nneg i32 %16 to i64
  %18 = trunc nuw nsw i64 %9 to i32
  %19 = shl nuw i32 %18, 3
  %20 = add i32 %14, %19
  store i32 %20, ptr %13, align 4, !tbaa !12
  %21 = icmp ult i32 %20, %19
  br i1 %21, label %22, label %26

22:                                               ; preds = %12
  %23 = getelementptr inbounds i8, ptr %0, i64 20
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = add i32 %24, 1
  store i32 %25, ptr %23, align 4, !tbaa !12
  br label %26

26:                                               ; preds = %22, %12
  %27 = sub nuw nsw i64 64, %17
  %.not44 = icmp ult i64 %9, %27
  br i1 %.not44, label %.loopexit, label %28

28:                                               ; preds = %26
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  %30 = getelementptr inbounds [64 x i8], ptr %29, i64 0, i64 %17
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %30, ptr noundef nonnull align 1 dereferenceable(1) %7, i64 %27, i1 false)
  tail call void @md5_basic_transform(ptr noundef nonnull %0, ptr noundef nonnull %29)
  %31 = xor i64 %17, 127
  %32 = icmp ult i64 %31, %9
  br i1 %32, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %28, %.lr.ph
  %.03845 = phi i64 [ %34, %.lr.ph ], [ %27, %28 ]
  %33 = getelementptr inbounds i8, ptr %7, i64 %.03845
  tail call void @md5_basic_transform(ptr noundef nonnull %0, ptr noundef %33)
  %34 = add i64 %.03845, 64
  %35 = add i64 %.03845, 127
  %36 = icmp ult i64 %35, %9
  br i1 %36, label %.lr.ph, label %.loopexit, !llvm.loop !14

.loopexit:                                        ; preds = %.lr.ph, %28, %26
  %.1 = phi i64 [ 0, %26 ], [ %27, %28 ], [ %34, %.lr.ph ]
  %.037 = phi i64 [ %17, %26 ], [ 0, %28 ], [ 0, %.lr.ph ]
  %37 = getelementptr inbounds i8, ptr %0, i64 24
  %38 = getelementptr inbounds [64 x i8], ptr %37, i64 0, i64 %.037
  %39 = getelementptr inbounds i8, ptr %7, i64 %.1
  %40 = sub i64 %9, %.1
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %38, ptr align 1 %39, i64 %40, i1 false)
  br label %41

41:                                               ; preds = %.loopexit, %11, %5, %3
  %.0 = phi i32 [ 0, %.loopexit ], [ 2, %11 ], [ 2, %5 ], [ 2, %3 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @md5_basic_transform(ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #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: readwrite) }
attributes #2 = { 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 = { inlinehint 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 #4 = { 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, !7, i64 0}
!6 = !{!"ByteArray_st", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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