; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (byte-utils-internal)

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

@big_endian_test = external dso_local constant i32, align 4
@.str = external hidden unnamed_addr constant [29 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 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

11:                                               ; preds = %4
  %12 = load ptr, ptr %5, 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 !11
  %15 = load i32, ptr %10, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 184, i32 noundef %15, ptr noundef null)
  br label %81

16:                                               ; preds = %11
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  br label %19

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

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

24:                                               ; preds = %19
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %32, label %30

30:                                               ; preds = %27
  store i32 2, ptr %10, align 4, !tbaa !11
  %31 = load i32, ptr %10, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 186, i32 noundef %31, ptr noundef null)
  br label %81

32:                                               ; preds = %27
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = mul i64 %36, 8
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = mul i64 %38, 4
  %40 = icmp eq i64 %37, %39
  br i1 %40, label %43, label %41

41:                                               ; preds = %35
  store i32 2, ptr %10, align 4, !tbaa !11
  %42 = load i32, ptr %10, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 187, i32 noundef %42, ptr noundef null)
  br label %81

43:                                               ; preds = %35
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load i8, ptr @big_endian_test, align 4, !tbaa !13
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %75

49:                                               ; preds = %45
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %71, %49
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = icmp ult i64 %51, %52
  br i1 %53, label %54, label %74

54:                                               ; preds = %50
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load i64, ptr %9, align 8, !tbaa !9
  %57 = getelementptr inbounds i32, ptr %55, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = add i64 %60, 1
  %62 = getelementptr inbounds i32, ptr %59, i64 %61
  store i32 %58, ptr %62, align 4, !tbaa !11
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = add i64 %64, 1
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !11
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load i64, ptr %9, align 8, !tbaa !9
  %70 = getelementptr inbounds i32, ptr %68, i64 %69
  store i32 %67, ptr %70, align 4, !tbaa !11
  br label %71

71:                                               ; preds = %54
  %72 = load i64, ptr %9, align 8, !tbaa !9
  %73 = add i64 %72, 2
  store i64 %73, ptr %9, align 8, !tbaa !9
  br label %50, !llvm.loop !14

74:                                               ; preds = %50
  br label %80

75:                                               ; preds = %45
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load i64, ptr %6, align 8, !tbaa !9
  %79 = mul i64 %78, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %76, ptr align 4 %77, i64 %79, i1 false)
  br label %80

80:                                               ; preds = %75, %74
  br label %81

81:                                               ; preds = %80, %41, %30, %22, %14
  %82 = load i32, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret i32 %82
}

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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@big_endian_test = external dso_local local_unnamed_addr constant i32, align 4
@.str = external hidden unnamed_addr constant [29 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 @uint32_to_uint64(ptr noundef readonly %0, i64 noundef %1, ptr noundef writeonly %2, i64 noundef %3) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

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

6:                                                ; preds = %4
  %.not28 = icmp eq i64 %1, 0
  br i1 %.not28, label %7, label %8

7:                                                ; preds = %6
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 185, i32 noundef 2, ptr noundef null) #3
  br label %.loopexit

8:                                                ; preds = %6
  %.not29 = icmp eq ptr %2, null
  br i1 %.not29, label %9, label %10

9:                                                ; preds = %8
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 186, i32 noundef 2, ptr noundef null) #3
  br label %.loopexit

10:                                               ; preds = %8
  %11 = shl i64 %3, 3
  %12 = shl i64 %1, 2
  %13 = icmp eq i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 187, i32 noundef 2, ptr noundef null) #3
  br label %.loopexit

15:                                               ; preds = %10
  %16 = load i8, ptr @big_endian_test, align 4, !tbaa !5
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %.preheader.preheader, label %48

.preheader.preheader:                             ; preds = %15
  %18 = add i64 %1, -1
  %19 = lshr i64 %18, 1
  %20 = add nuw i64 %19, 1
  %min.iters.check = icmp ult i64 %1, 59
  br i1 %min.iters.check, label %.preheader.preheader41, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.preheader.preheader
  %21 = add i64 %1, -1
  %22 = lshr i64 %21, 1
  %scevgep = getelementptr i8, ptr %2, i64 4
  %mul.result = shl i64 %22, 3
  %23 = getelementptr i8, ptr %scevgep, i64 %mul.result
  %24 = icmp ult ptr %23, %scevgep
  %mul.result32 = shl i64 %22, 3
  %mul.overflow33 = icmp ugt i64 %21, 4611686018427387903
  %25 = getelementptr i8, ptr %2, i64 %mul.result32
  %26 = icmp ult ptr %25, %2
  %27 = or i1 %26, %mul.overflow33
  %28 = or i1 %24, %27
  br i1 %28, label %.preheader.preheader41, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %29 = shl i64 %1, 2
  %30 = add i64 %29, -4
  %31 = and i64 %30, -8
  %32 = add i64 %31, 8
  %scevgep34 = getelementptr i8, ptr %2, i64 %32
  %scevgep35 = getelementptr i8, ptr %0, i64 %32
  %bound0 = icmp ugt ptr %scevgep35, %2
  %bound1 = icmp ugt ptr %scevgep34, %0
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.preheader.preheader41, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %20, -4
  %ind.end = shl i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 1
  %33 = or disjoint i64 %offset.idx, 4
  %34 = getelementptr inbounds i32, ptr %0, i64 %offset.idx
  %35 = getelementptr inbounds i32, ptr %0, i64 %33
  %wide.vec = load <4 x i32>, ptr %34, align 4, !tbaa !8
  %wide.vec36 = load <4 x i32>, ptr %35, align 4, !tbaa !8
  %36 = getelementptr inbounds i32, ptr %2, i64 %offset.idx
  %37 = getelementptr inbounds i32, ptr %2, i64 %33
  %interleaved.vec = shufflevector <4 x i32> %wide.vec, <4 x i32> poison, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
  store <4 x i32> %interleaved.vec, ptr %36, align 4, !tbaa !8
  %interleaved.vec40 = shufflevector <4 x i32> %wide.vec36, <4 x i32> poison, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
  store <4 x i32> %interleaved.vec40, ptr %37, align 4, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %38 = icmp eq i64 %index.next, %n.vec
  br i1 %38, label %middle.block, label %vector.body, !llvm.loop !10

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %20, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.preheader.preheader41

.preheader.preheader41:                           ; preds = %middle.block, %vector.memcheck, %vector.scevcheck, %.preheader.preheader
  %.02330.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %vector.scevcheck ], [ 0, %.preheader.preheader ], [ %ind.end, %middle.block ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader41, %.preheader
  %.02330 = phi i64 [ %46, %.preheader ], [ %.02330.ph, %.preheader.preheader41 ]
  %39 = getelementptr inbounds i32, ptr %0, i64 %.02330
  %40 = load i32, ptr %39, align 4, !tbaa !8
  %41 = or disjoint i64 %.02330, 1
  %42 = getelementptr inbounds i32, ptr %2, i64 %41
  store i32 %40, ptr %42, align 4, !tbaa !8
  %43 = getelementptr inbounds i32, ptr %0, i64 %41
  %44 = load i32, ptr %43, align 4, !tbaa !8
  %45 = getelementptr inbounds i32, ptr %2, i64 %.02330
  store i32 %44, ptr %45, align 4, !tbaa !8
  %46 = add nuw i64 %.02330, 2
  %47 = icmp ult i64 %46, %1
  br i1 %47, label %.preheader, label %.loopexit, !llvm.loop !14

48:                                               ; preds = %15
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %2, ptr nonnull align 4 %0, i64 %11, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %middle.block, %48, %14, %9, %7, %5
  %.0 = phi i32 [ 0, %48 ], [ 2, %14 ], [ 2, %9 ], [ 2, %7 ], [ 2, %5 ], [ 0, %middle.block ], [ 0, %.preheader ]
  ret i32 %.0
}

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 = { 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"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass