; 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: nounwind uwtable
define dso_local i32 @uint8_to_uint32(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca [4 x i8], align 1
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  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 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %20, label %18

18:                                               ; preds = %15
  store i32 2, ptr %9, align 4, !tbaa !11
  %19 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 91, i32 noundef %19, ptr noundef null)
  br label %130

20:                                               ; preds = %15
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %28, label %26

26:                                               ; preds = %23
  store i32 2, ptr %9, align 4, !tbaa !11
  %27 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 92, i32 noundef %27, ptr noundef null)
  br label %130

28:                                               ; preds = %23
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %36, label %34

34:                                               ; preds = %31
  store i32 2, ptr %9, align 4, !tbaa !11
  %35 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 93, i32 noundef %35, ptr noundef null)
  br label %130

36:                                               ; preds = %31
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = mul i64 %40, 4
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = icmp uge i64 %41, %42
  br i1 %43, label %46, label %44

44:                                               ; preds = %39
  store i32 2, ptr %9, align 4, !tbaa !11
  %45 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 94, i32 noundef %45, ptr noundef null)
  br label %130

46:                                               ; preds = %39
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load i64, ptr %6, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 1 %50, i64 %51, i1 false)
  %52 = load i64, ptr %8, align 8, !tbaa !9
  %53 = mul i64 %52, 4
  %54 = load i64, ptr %6, align 8, !tbaa !9
  %55 = icmp ugt i64 %53, %54
  br i1 %55, label %56, label %64

56:                                               ; preds = %48
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i64, ptr %6, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  %60 = load i64, ptr %8, align 8, !tbaa !9
  %61 = mul i64 %60, 4
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = sub i64 %61, %62
  call void @llvm.memset.p0.i64(ptr align 1 %59, i8 0, i64 %63, i1 false)
  br label %64

64:                                               ; preds = %56, %48
  %65 = load i8, ptr @big_endian_test, align 4, !tbaa !13
  %66 = sext i8 %65 to i32
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %129

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %69, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %70, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %71 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %71, ptr %14, align 8, !tbaa !9
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %72

72:                                               ; preds = %125, %68
  %73 = load i64, ptr %13, align 8, !tbaa !9
  %74 = load i64, ptr %14, align 8, !tbaa !9
  %75 = icmp ult i64 %73, %74
  br i1 %75, label %76, label %128

76:                                               ; preds = %72
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load i64, ptr %13, align 8, !tbaa !9
  %79 = add i64 %78, 3
  %80 = getelementptr inbounds i8, ptr %77, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !13
  %82 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  store i8 %81, ptr %82, align 1, !tbaa !13
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = load i64, ptr %13, align 8, !tbaa !9
  %85 = add i64 %84, 2
  %86 = getelementptr inbounds i8, ptr %83, i64 %85
  %87 = load i8, ptr %86, align 1, !tbaa !13
  %88 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 1
  store i8 %87, ptr %88, align 1, !tbaa !13
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = load i64, ptr %13, align 8, !tbaa !9
  %91 = add i64 %90, 1
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !13
  %94 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 2
  store i8 %93, ptr %94, align 1, !tbaa !13
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = load i64, ptr %13, align 8, !tbaa !9
  %97 = add i64 %96, 0
  %98 = getelementptr inbounds i8, ptr %95, i64 %97
  %99 = load i8, ptr %98, align 1, !tbaa !13
  %100 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 3
  store i8 %99, ptr %100, align 1, !tbaa !13
  %101 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  %102 = load i8, ptr %101, align 1, !tbaa !13
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = load i64, ptr %13, align 8, !tbaa !9
  %105 = add i64 %104, 0
  %106 = getelementptr inbounds i8, ptr %103, i64 %105
  store i8 %102, ptr %106, align 1, !tbaa !13
  %107 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 1
  %108 = load i8, ptr %107, align 1, !tbaa !13
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = load i64, ptr %13, align 8, !tbaa !9
  %111 = add i64 %110, 1
  %112 = getelementptr inbounds i8, ptr %109, i64 %111
  store i8 %108, ptr %112, align 1, !tbaa !13
  %113 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 2
  %114 = load i8, ptr %113, align 1, !tbaa !13
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  %116 = load i64, ptr %13, align 8, !tbaa !9
  %117 = add i64 %116, 2
  %118 = getelementptr inbounds i8, ptr %115, i64 %117
  store i8 %114, ptr %118, align 1, !tbaa !13
  %119 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 3
  %120 = load i8, ptr %119, align 1, !tbaa !13
  %121 = load ptr, ptr %11, align 8, !tbaa !5
  %122 = load i64, ptr %13, align 8, !tbaa !9
  %123 = add i64 %122, 3
  %124 = getelementptr inbounds i8, ptr %121, i64 %123
  store i8 %120, ptr %124, align 1, !tbaa !13
  br label %125

125:                                              ; preds = %76
  %126 = load i64, ptr %13, align 8, !tbaa !9
  %127 = add i64 %126, 4
  store i64 %127, ptr %13, align 8, !tbaa !9
  br label %72, !llvm.loop !14

128:                                              ; preds = %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %129

129:                                              ; preds = %128, %64
  br label %130

130:                                              ; preds = %129, %44, %34, %26, %18
  %131 = load i32, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret i32 %131
}

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

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

; 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) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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

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

5:                                                ; preds = %4
  %.not45 = icmp eq i64 %1, 0
  br i1 %.not45, label %.loopexit.sink.split, label %6

6:                                                ; preds = %5
  %.not46 = icmp eq ptr %2, null
  br i1 %.not46, label %.loopexit.sink.split, label %7

7:                                                ; preds = %6
  %8 = shl i64 %3, 2
  %.not47 = icmp ult i64 %8, %1
  br i1 %.not47, label %.loopexit.sink.split, label %9

9:                                                ; preds = %7
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %2, ptr nonnull align 1 %0, i64 %1, i1 false)
  %10 = icmp ugt i64 %8, %1
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %2, i64 %1
  %13 = sub i64 %8, %1
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %12, i8 0, i64 %13, i1 false)
  br label %14

14:                                               ; preds = %11, %9
  %15 = load i8, ptr @big_endian_test, align 4, !tbaa !5
  %16 = icmp eq i8 %15, 0
  br i1 %16, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %14, %.preheader
  %.04048 = phi i64 [ %20, %.preheader ], [ 0, %14 ]
  %17 = getelementptr inbounds i8, ptr %2, i64 %.04048
  %18 = load <4 x i8>, ptr %17, align 1, !tbaa !5
  %19 = shufflevector <4 x i8> %18, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  store <4 x i8> %19, ptr %17, align 1, !tbaa !5
  %20 = add nuw i64 %.04048, 4
  %21 = icmp ult i64 %20, %1
  br i1 %21, label %.preheader, label %.loopexit, !llvm.loop !8

.loopexit.sink.split:                             ; preds = %7, %6, %5, %4
  %.sink = phi i64 [ 91, %4 ], [ 92, %5 ], [ 93, %6 ], [ 94, %7 ]
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef %.sink, i32 noundef 2, ptr noundef null) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.sink.split, %14
  %.0 = phi i32 [ 0, %14 ], [ 2, %.loopexit.sink.split ], [ 0, %.preheader ]
  ret i32 %.0
}

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

; 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) #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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