; LLVM IR from kala13x/libxutils :: src/crypt (hmac)

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @XHMAC_SHA256(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @XHMAC_SHA256_HEX(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i8, align 1
  %15 = alloca [32 x i8], align 16
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !9
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %21, label %18

18:                                               ; preds = %6
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = icmp ult i64 %19, 65
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %6
  store i32 -1, ptr %7, align 4
  br label %52

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #3
  %23 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load i64, ptr %11, align 8, !tbaa !9
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = load i64, ptr %13, align 8, !tbaa !9
  %28 = call i32 @XHMAC_SHA256(ptr noundef %23, i64 noundef 32, ptr noundef %24, i64 noundef %25, ptr noundef %26, i64 noundef %27)
  store i8 0, ptr %14, align 1, !tbaa !11
  br label %29

29:                                               ; preds = %46, %22
  %30 = load i8, ptr %14, align 1, !tbaa !11
  %31 = zext i8 %30 to i64
  %32 = icmp ult i64 %31, 32
  br i1 %32, label %33, label %49

33:                                               ; preds = %29
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load i8, ptr %14, align 1, !tbaa !11
  %36 = zext i8 %35 to i32
  %37 = mul nsw i32 %36, 2
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %34, i64 %38
  %40 = load i8, ptr %14, align 1, !tbaa !11
  %41 = zext i8 %40 to i64
  %42 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !11
  %44 = zext i8 %43 to i32
  %45 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %39, i64 noundef 3, ptr noundef @.str, i32 noundef %44)
  br label %46

46:                                               ; preds = %33
  %47 = load i8, ptr %14, align 1, !tbaa !11
  %48 = add i8 %47, 1
  store i8 %48, ptr %14, align 1, !tbaa !11
  br label %29, !llvm.loop !12

49:                                               ; preds = %29
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 64
  store i8 0, ptr %51, align 1, !tbaa !11
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  br label %52

52:                                               ; preds = %49, %21
  %53 = load i32, ptr %7, align 4
  ret i32 %53
}

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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 [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @XHMAC_SHA256(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @XHMAC_SHA256_HEX(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #0 {
  %7 = alloca [32 x i8], align 16
  %8 = icmp eq ptr %0, null
  %9 = icmp ult i64 %1, 65
  %or.cond = or i1 %8, %9
  br i1 %or.cond, label %171, label %10

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #3
  %11 = call i32 @XHMAC_SHA256(ptr noundef nonnull %7, i64 noundef 32, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5)
  %12 = load i8, ptr %7, align 16, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %0, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %13) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 2
  %16 = getelementptr inbounds i8, ptr %7, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = zext i8 %17 to i32
  %19 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %15, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %18) #3
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  %21 = getelementptr inbounds i8, ptr %7, i64 2
  %22 = load i8, ptr %21, align 2, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %20, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %23) #3
  %25 = getelementptr inbounds i8, ptr %0, i64 6
  %26 = getelementptr inbounds i8, ptr %7, i64 3
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = zext i8 %27 to i32
  %29 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %25, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %28) #3
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = getelementptr inbounds i8, ptr %7, i64 4
  %32 = load i8, ptr %31, align 4, !tbaa !5
  %33 = zext i8 %32 to i32
  %34 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %30, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %33) #3
  %35 = getelementptr inbounds i8, ptr %0, i64 10
  %36 = getelementptr inbounds i8, ptr %7, i64 5
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = zext i8 %37 to i32
  %39 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %35, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %38) #3
  %40 = getelementptr inbounds i8, ptr %0, i64 12
  %41 = getelementptr inbounds i8, ptr %7, i64 6
  %42 = load i8, ptr %41, align 2, !tbaa !5
  %43 = zext i8 %42 to i32
  %44 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %40, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %43) #3
  %45 = getelementptr inbounds i8, ptr %0, i64 14
  %46 = getelementptr inbounds i8, ptr %7, i64 7
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = zext i8 %47 to i32
  %49 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %45, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %48) #3
  %50 = getelementptr inbounds i8, ptr %0, i64 16
  %51 = getelementptr inbounds i8, ptr %7, i64 8
  %52 = load i8, ptr %51, align 8, !tbaa !5
  %53 = zext i8 %52 to i32
  %54 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %50, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %53) #3
  %55 = getelementptr inbounds i8, ptr %0, i64 18
  %56 = getelementptr inbounds i8, ptr %7, i64 9
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = zext i8 %57 to i32
  %59 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %55, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %58) #3
  %60 = getelementptr inbounds i8, ptr %0, i64 20
  %61 = getelementptr inbounds i8, ptr %7, i64 10
  %62 = load i8, ptr %61, align 2, !tbaa !5
  %63 = zext i8 %62 to i32
  %64 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %60, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %63) #3
  %65 = getelementptr inbounds i8, ptr %0, i64 22
  %66 = getelementptr inbounds i8, ptr %7, i64 11
  %67 = load i8, ptr %66, align 1, !tbaa !5
  %68 = zext i8 %67 to i32
  %69 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %65, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %68) #3
  %70 = getelementptr inbounds i8, ptr %0, i64 24
  %71 = getelementptr inbounds i8, ptr %7, i64 12
  %72 = load i8, ptr %71, align 4, !tbaa !5
  %73 = zext i8 %72 to i32
  %74 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %70, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %73) #3
  %75 = getelementptr inbounds i8, ptr %0, i64 26
  %76 = getelementptr inbounds i8, ptr %7, i64 13
  %77 = load i8, ptr %76, align 1, !tbaa !5
  %78 = zext i8 %77 to i32
  %79 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %75, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %78) #3
  %80 = getelementptr inbounds i8, ptr %0, i64 28
  %81 = getelementptr inbounds i8, ptr %7, i64 14
  %82 = load i8, ptr %81, align 2, !tbaa !5
  %83 = zext i8 %82 to i32
  %84 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %80, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %83) #3
  %85 = getelementptr inbounds i8, ptr %0, i64 30
  %86 = getelementptr inbounds i8, ptr %7, i64 15
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = zext i8 %87 to i32
  %89 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %85, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %88) #3
  %90 = getelementptr inbounds i8, ptr %0, i64 32
  %91 = getelementptr inbounds i8, ptr %7, i64 16
  %92 = load i8, ptr %91, align 16, !tbaa !5
  %93 = zext i8 %92 to i32
  %94 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %90, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %93) #3
  %95 = getelementptr inbounds i8, ptr %0, i64 34
  %96 = getelementptr inbounds i8, ptr %7, i64 17
  %97 = load i8, ptr %96, align 1, !tbaa !5
  %98 = zext i8 %97 to i32
  %99 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %95, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %98) #3
  %100 = getelementptr inbounds i8, ptr %0, i64 36
  %101 = getelementptr inbounds i8, ptr %7, i64 18
  %102 = load i8, ptr %101, align 2, !tbaa !5
  %103 = zext i8 %102 to i32
  %104 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %100, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %103) #3
  %105 = getelementptr inbounds i8, ptr %0, i64 38
  %106 = getelementptr inbounds i8, ptr %7, i64 19
  %107 = load i8, ptr %106, align 1, !tbaa !5
  %108 = zext i8 %107 to i32
  %109 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %105, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %108) #3
  %110 = getelementptr inbounds i8, ptr %0, i64 40
  %111 = getelementptr inbounds i8, ptr %7, i64 20
  %112 = load i8, ptr %111, align 4, !tbaa !5
  %113 = zext i8 %112 to i32
  %114 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %110, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %113) #3
  %115 = getelementptr inbounds i8, ptr %0, i64 42
  %116 = getelementptr inbounds i8, ptr %7, i64 21
  %117 = load i8, ptr %116, align 1, !tbaa !5
  %118 = zext i8 %117 to i32
  %119 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %115, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %118) #3
  %120 = getelementptr inbounds i8, ptr %0, i64 44
  %121 = getelementptr inbounds i8, ptr %7, i64 22
  %122 = load i8, ptr %121, align 2, !tbaa !5
  %123 = zext i8 %122 to i32
  %124 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %120, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %123) #3
  %125 = getelementptr inbounds i8, ptr %0, i64 46
  %126 = getelementptr inbounds i8, ptr %7, i64 23
  %127 = load i8, ptr %126, align 1, !tbaa !5
  %128 = zext i8 %127 to i32
  %129 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %125, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %128) #3
  %130 = getelementptr inbounds i8, ptr %0, i64 48
  %131 = getelementptr inbounds i8, ptr %7, i64 24
  %132 = load i8, ptr %131, align 8, !tbaa !5
  %133 = zext i8 %132 to i32
  %134 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %130, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %133) #3
  %135 = getelementptr inbounds i8, ptr %0, i64 50
  %136 = getelementptr inbounds i8, ptr %7, i64 25
  %137 = load i8, ptr %136, align 1, !tbaa !5
  %138 = zext i8 %137 to i32
  %139 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %135, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %138) #3
  %140 = getelementptr inbounds i8, ptr %0, i64 52
  %141 = getelementptr inbounds i8, ptr %7, i64 26
  %142 = load i8, ptr %141, align 2, !tbaa !5
  %143 = zext i8 %142 to i32
  %144 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %140, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %143) #3
  %145 = getelementptr inbounds i8, ptr %0, i64 54
  %146 = getelementptr inbounds i8, ptr %7, i64 27
  %147 = load i8, ptr %146, align 1, !tbaa !5
  %148 = zext i8 %147 to i32
  %149 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %145, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %148) #3
  %150 = getelementptr inbounds i8, ptr %0, i64 56
  %151 = getelementptr inbounds i8, ptr %7, i64 28
  %152 = load i8, ptr %151, align 4, !tbaa !5
  %153 = zext i8 %152 to i32
  %154 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %150, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %153) #3
  %155 = getelementptr inbounds i8, ptr %0, i64 58
  %156 = getelementptr inbounds i8, ptr %7, i64 29
  %157 = load i8, ptr %156, align 1, !tbaa !5
  %158 = zext i8 %157 to i32
  %159 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %155, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %158) #3
  %160 = getelementptr inbounds i8, ptr %0, i64 60
  %161 = getelementptr inbounds i8, ptr %7, i64 30
  %162 = load i8, ptr %161, align 2, !tbaa !5
  %163 = zext i8 %162 to i32
  %164 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %160, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %163) #3
  %165 = getelementptr inbounds i8, ptr %0, i64 62
  %166 = getelementptr inbounds i8, ptr %7, i64 31
  %167 = load i8, ptr %166, align 1, !tbaa !5
  %168 = zext i8 %167 to i32
  %169 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %165, i64 noundef 3, ptr noundef nonnull @.str, i32 noundef %168) #3
  %170 = getelementptr inbounds i8, ptr %0, i64 64
  store i8 0, ptr %170, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #3
  br label %171

171:                                              ; preds = %6, %10
  %.013 = phi i32 [ 1, %10 ], [ -1, %6 ]
  ret i32 %.013
}

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #2

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 nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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