; LLVM IR from cryspen/libcrux :: sys/hacl/c/src/msvc (Hacl_Bignum256)

; 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 [70 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 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

; 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 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

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @load64(ptr noundef) #6

; Function Attrs: nounwind uwtable
define dso_local ptr @Hacl_Bignum256_new_bn_from_bytes_le(i32 noundef %0, ptr noundef %1) #7 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %27, label %21

21:                                               ; preds = %2
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sub i32 %22, 1
  %24 = udiv i32 %23, 8
  %25 = add i32 %24, 1
  %26 = icmp ule i32 %25, 536870911
  br i1 %26, label %28, label %27

27:                                               ; preds = %21, %2
  store ptr null, ptr %3, align 8
  br label %112

28:                                               ; preds = %21
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sub i32 %30, 1
  %32 = udiv i32 %31, 8
  %33 = add i32 %32, 1
  %34 = zext i32 %33 to i64
  %35 = icmp ugt i64 %34, 2305843009213693951
  br i1 %35, label %36, label %38

36:                                               ; preds = %29
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1282)
  call void @exit(i32 noundef 253) #8
  unreachable

38:                                               ; preds = %29
  br label %39

39:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #9
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sub i32 %40, 1
  %42 = udiv i32 %41, 8
  %43 = add i32 %42, 1
  %44 = zext i32 %43 to i64
  %45 = call noalias ptr @calloc(i64 noundef %44, i64 noundef 8) #10
  store ptr %45, ptr %6, align 8, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %50

48:                                               ; preds = %39
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %49, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %111

50:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #9
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %51, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %52, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sub i32 %53, 1
  %55 = udiv i32 %54, 8
  %56 = add i32 %55, 1
  store i32 %56, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = mul i32 8, %57
  store i32 %58, ptr %11, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %50
  %60 = load i32, ptr %11, align 4, !tbaa !5
  %61 = zext i32 %60 to i64
  %62 = icmp ugt i64 %61, -1
  br i1 %62, label %63, label %65

63:                                               ; preds = %59
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1292)
  call void @exit(i32 noundef 253) #8
  unreachable

65:                                               ; preds = %59
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = zext i32 %68 to i64
  %70 = mul i64 %69, 1
  %71 = alloca i8, i64 %70, align 16
  store ptr %71, ptr %12, align 8, !tbaa !9
  %72 = load ptr, ptr %12, align 8, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = zext i32 %73 to i64
  %75 = mul i64 %74, 1
  call void @llvm.memset.p0.i64(ptr align 1 %72, i8 0, i64 %75, i1 false)
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = zext i32 %78 to i64
  %80 = mul i64 %79, 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %76, ptr align 1 %77, i64 %80, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %106, %67
  %82 = load i32, ptr %13, align 4, !tbaa !5
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sub i32 %83, 1
  %85 = udiv i32 %84, 8
  %86 = add i32 %85, 1
  %87 = icmp ult i32 %82, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %81
  store i32 6, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %109

89:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #9
  %90 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %90, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  %91 = load ptr, ptr %12, align 8, !tbaa !9
  %92 = load i32, ptr %13, align 4, !tbaa !5
  %93 = mul i32 %92, 8
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %91, i64 %94
  store ptr %95, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #9
  %96 = load ptr, ptr %15, align 8, !tbaa !9
  %97 = call i64 @load64(ptr noundef %96)
  %98 = call i64 @__uint64_identity(i64 noundef %97)
  store i64 %98, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #9
  %99 = load i64, ptr %16, align 8, !tbaa !11
  store i64 %99, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #9
  %100 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %100, ptr %18, align 8, !tbaa !11
  %101 = load i64, ptr %18, align 8, !tbaa !11
  %102 = load ptr, ptr %14, align 8, !tbaa !9
  %103 = load i32, ptr %13, align 4, !tbaa !5
  %104 = zext i32 %103 to i64
  %105 = getelementptr inbounds i64, ptr %102, i64 %104
  store i64 %101, ptr %105, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  br label %106

106:                                              ; preds = %89
  %107 = load i32, ptr %13, align 4, !tbaa !5
  %108 = add i32 %107, 1
  store i32 %108, ptr %13, align 4, !tbaa !5
  br label %81, !llvm.loop !13

109:                                              ; preds = %88
  %110 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %110, ptr %3, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #9
  br label %111

111:                                              ; preds = %109, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  br label %112

112:                                              ; preds = %111, %27
  %113 = load ptr, ptr %3, align 8
  ret ptr %113
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @__uint64_identity(i64 noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nounwind allocsize(0,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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = { noreturn nounwind "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 #6 = { 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 #7 = { 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 #8 = { noreturn nounwind }
attributes #9 = { nounwind }
attributes #10 = { nounwind allocsize(0,1) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 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: inlinehint nounwind uwtable
declare hidden i64 @load64(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @Hacl_Bignum256_new_bn_from_bytes_le(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #4 {
  %3 = icmp eq i32 %0, 0
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %2
  %5 = add i32 %0, -1
  %6 = lshr i32 %5, 3
  %7 = add nuw nsw i32 %6, 1
  %.not = icmp eq i32 %6, 536870911
  br i1 %.not, label %.loopexit, label %8

8:                                                ; preds = %4
  %9 = zext nneg i32 %7 to i64
  %10 = tail call noalias ptr @calloc(i64 noundef %9, i64 noundef 8) #5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %.loopexit, label %12

12:                                               ; preds = %8
  %13 = shl nuw i32 %7, 3
  %14 = zext i32 %13 to i64
  %15 = alloca i8, i64 %14, align 16
  %16 = zext i32 %0 to i64
  %.not36 = icmp ugt i32 %13, %0
  %17 = sub nsw i64 %14, %16
  %18 = select i1 %.not36, i64 %17, i64 0
  %19 = getelementptr i8, ptr %15, i64 %16
  call void @llvm.memset.p0.i64(ptr align 1 %19, i8 0, i64 %18, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %15, ptr align 1 %1, i64 %16, i1 false)
  br label %20

20:                                               ; preds = %12, %20
  %indvars.iv = phi i64 [ 0, %12 ], [ %indvars.iv.next, %20 ]
  %21 = shl nuw i64 %indvars.iv, 3
  %22 = getelementptr inbounds i8, ptr %15, i64 %21
  %23 = call i64 @load64(ptr noundef nonnull %22)
  %24 = call i64 @__uint64_identity(i64 noundef %23)
  %25 = getelementptr inbounds i64, ptr %10, i64 %indvars.iv
  store i64 %24, ptr %25, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %9
  br i1 %exitcond.not, label %.loopexit, label %20, !llvm.loop !9

.loopexit:                                        ; preds = %20, %8, %2, %4
  %.1 = phi ptr [ null, %4 ], [ null, %2 ], [ null, %8 ], [ %10, %20 ]
  ret ptr %.1
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @__uint64_identity(i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 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 allocsize(0,1) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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