; LLVM IR from Waqar144/simplecrypto-cxx :: simplecrypto-cxx (pbkdf2)

; 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.PBKDF2_CTX = type { %"struct.std::array.0", %"struct.std::array.0", %"struct.std::array.0", %"struct.std::array", i8 }
%"struct.std::array.0" = type { [8 x i32] }
%"struct.std::array" = type { [16 x i32] }

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

; Function Attrs: mustprogress nounwind willreturn memory(none) uwtable
declare dso_local noundef ptr @_ZNSt5arrayIjLm16EE4dataEv(ptr noundef nonnull align 4 dereferenceable(64)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef) #2 align 2

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

declare void @_Z16sha256_TransformRKSt5arrayIjLm8EERKS_IjLm16EEPj(ptr noundef nonnull align 4 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(64), ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z25pbkdf2_hmac_sha256_UpdateIjLm64ELm32EEvP10PBKDF2_CTXIT_XT0_EXT1_EEj(ptr noundef %0, i32 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %8, i32 0, i32 4
  %10 = load i8, ptr %9, align 4, !tbaa !11
  %11 = sext i8 %10 to i32
  store i32 %11, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %55, %2
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp ult i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %58

17:                                               ; preds = %12
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %22, i32 0, i32 3
  %24 = call noundef ptr @_ZNSt5arrayIjLm16EE4dataEv(ptr noundef nonnull align 4 dereferenceable(64) %23) #6
  call void @_Z16sha256_TransformRKSt5arrayIjLm8EERKS_IjLm16EEPj(ptr noundef nonnull align 4 dereferenceable(32) %19, ptr noundef nonnull align 4 dereferenceable(64) %21, ptr noundef %24)
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %27, i32 0, i32 3
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %29, i32 0, i32 3
  %31 = call noundef ptr @_ZNSt5arrayIjLm16EE4dataEv(ptr noundef nonnull align 4 dereferenceable(64) %30) #6
  call void @_Z16sha256_TransformRKSt5arrayIjLm8EERKS_IjLm16EEPj(ptr noundef nonnull align 4 dereferenceable(32) %26, ptr noundef nonnull align 4 dereferenceable(64) %28, ptr noundef %31)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %51, %17
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = icmp ult i64 %34, 8
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %54

37:                                               ; preds = %32
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %38, i32 0, i32 3
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %39, i64 noundef %41) #5
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %44, i32 0, i32 2
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %45, i64 noundef %47) #5
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = xor i32 %49, %43
  store i32 %50, ptr %48, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %37
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = add i32 %52, 1
  store i32 %53, ptr %7, align 4, !tbaa !9
  br label %32, !llvm.loop !15

54:                                               ; preds = %36
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = add i32 %56, 1
  store i32 %57, ptr %5, align 4, !tbaa !9
  br label %12, !llvm.loop !17

58:                                               ; preds = %16
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.PBKDF2_CTX, ptr %59, i32 0, i32 4
  store i8 0, ptr %60, align 4, !tbaa !11
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind willreturn memory(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" }
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 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }

!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 = !{!12, !7, i64 160}
!12 = !{!"_ZTS10PBKDF2_CTXIjLm64ELm32EE", !13, i64 0, !13, i64 32, !13, i64 64, !14, i64 96, !7, i64 160}
!13 = !{!"_ZTSSt5arrayIjLm8EE", !7, i64 0}
!14 = !{!"_ZTSSt5arrayIjLm16EE", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 nofree nosync nounwind willreturn memory(none) uwtable
declare dso_local noundef ptr @_ZNSt5arrayIjLm16EE4dataEv(ptr noundef nonnull align 4 dereferenceable(64)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef) local_unnamed_addr #1 align 2

declare void @_Z16sha256_TransformRKSt5arrayIjLm8EERKS_IjLm16EEPj(ptr noundef nonnull align 4 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(64), ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z25pbkdf2_hmac_sha256_UpdateIjLm64ELm32EEvP10PBKDF2_CTXIT_XT0_EXT1_EEj(ptr noundef %0, i32 noundef %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 160
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = icmp ult i32 %5, %1
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  %9 = tail call noundef ptr @_ZNSt5arrayIjLm16EE4dataEv(ptr noundef nonnull align 4 dereferenceable(64) %8) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  br label %11

._crit_edge:                                      ; preds = %11, %2
  store i8 0, ptr %3, align 4, !tbaa !5
  ret void

11:                                               ; preds = %.lr.ph, %11
  %.01619 = phi i32 [ %5, %.lr.ph ], [ %52, %11 ]
  tail call void @_Z16sha256_TransformRKSt5arrayIjLm8EERKS_IjLm16EEPj(ptr noundef nonnull align 4 dereferenceable(32) %7, ptr noundef nonnull align 4 dereferenceable(64) %8, ptr noundef %9)
  tail call void @_Z16sha256_TransformRKSt5arrayIjLm8EERKS_IjLm16EEPj(ptr noundef nonnull align 4 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(64) %8, ptr noundef %9)
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 0) #5
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 0) #5
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = xor i32 %15, %13
  store i32 %16, ptr %14, align 4, !tbaa !11
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 1) #5
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 1) #5
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = xor i32 %20, %18
  store i32 %21, ptr %19, align 4, !tbaa !11
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 2) #5
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 2) #5
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = xor i32 %25, %23
  store i32 %26, ptr %24, align 4, !tbaa !11
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 3) #5
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 3) #5
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = xor i32 %30, %28
  store i32 %31, ptr %29, align 4, !tbaa !11
  %32 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 4) #5
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 4) #5
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = xor i32 %35, %33
  store i32 %36, ptr %34, align 4, !tbaa !11
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 5) #5
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 5) #5
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = xor i32 %40, %38
  store i32 %41, ptr %39, align 4, !tbaa !11
  %42 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 6) #5
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 6) #5
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = xor i32 %45, %43
  store i32 %46, ptr %44, align 4, !tbaa !11
  %47 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm16EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %8, i64 noundef 7) #5
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32) %10, i64 noundef 7) #5
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = xor i32 %50, %48
  store i32 %51, ptr %49, align 4, !tbaa !11
  %52 = add nuw i32 %.01619, 1
  %exitcond.not = icmp eq i32 %52, %1
  br i1 %exitcond.not, label %._crit_edge, label %11, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm8EEixEm(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(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" }
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 = { "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 = { 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 #4 = { nounwind willreturn memory(none) }
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, !8, i64 160}
!6 = !{!"_ZTS10PBKDF2_CTXIjLm64ELm32EE", !7, i64 0, !7, i64 32, !7, i64 64, !10, i64 96, !8, i64 160}
!7 = !{!"_ZTSSt5arrayIjLm8EE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt5arrayIjLm16EE", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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