; LLVM IR from ryanlayer/giggle :: src (ll)

; 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.uint64_t_ll_bpt_non_leading_data = type { ptr, ptr }

@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [52 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: nounwind uwtable
define dso_local i64 @uint64_t_ll_non_leading_deserialize(ptr noundef %0, i64 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = 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
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %16, label %13

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %13, %3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %17, align 8, !tbaa !5
  store i64 0, ptr %4, align 8
  br label %88

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

21:                                               ; preds = %18
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.3) #4
  unreachable

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %23, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds i64, ptr %24, i64 0
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = add i64 2, %26
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds i64, ptr %28, i64 1
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = add i64 %27, %30
  %32 = mul i64 %31, 8
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = icmp ne i64 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %22
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.4) #4
  unreachable

36:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %37 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 16) #6
  store ptr %37, ptr %9, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %36
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.5) #4
  unreachable

41:                                               ; preds = %36
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %42, i32 0, i32 0
  store ptr null, ptr %43, align 8, !tbaa !11
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %44, i32 0, i32 1
  store ptr null, ptr %45, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %60, %41
  %47 = load i64, ptr %10, align 8, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds i64, ptr %48, i64 0
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = icmp ult i64 %47, %50
  br i1 %51, label %52, label %63

52:                                               ; preds = %46
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = add i64 2, %56
  %58 = getelementptr inbounds i64, ptr %55, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !9
  call void @uint64_t_ll_append(ptr noundef %54, i64 noundef %59)
  br label %60

60:                                               ; preds = %52
  %61 = load i64, ptr %10, align 8, !tbaa !9
  %62 = add i64 %61, 1
  store i64 %62, ptr %10, align 8, !tbaa !9
  br label %46, !llvm.loop !14

63:                                               ; preds = %46
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %82, %63
  %65 = load i64, ptr %10, align 8, !tbaa !9
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds i64, ptr %66, i64 1
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = icmp ult i64 %65, %68
  br i1 %69, label %70, label %85

70:                                               ; preds = %64
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.uint64_t_ll_bpt_non_leading_data, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds i64, ptr %74, i64 0
  %76 = load i64, ptr %75, align 8, !tbaa !9
  %77 = add i64 2, %76
  %78 = load i64, ptr %10, align 8, !tbaa !9
  %79 = add i64 %77, %78
  %80 = getelementptr inbounds i64, ptr %73, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !9
  call void @uint64_t_ll_append(ptr noundef %72, i64 noundef %81)
  br label %82

82:                                               ; preds = %70
  %83 = load i64, ptr %10, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %10, align 8, !tbaa !9
  br label %64, !llvm.loop !16

85:                                               ; preds = %64
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %86, ptr %87, align 8, !tbaa !5
  store i64 16, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %88

88:                                               ; preds = %85, %16
  %89 = load i64, ptr %4, align 8
  ret i64 %89
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #3

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
declare dso_local void @uint64_t_ll_append(ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = { noreturn "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 = { noreturn }
attributes #5 = { nounwind }
attributes #6 = { 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 = !{!"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, !6, i64 0}
!12 = !{!"uint64_t_ll_bpt_non_leading_data", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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.3 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 17) i64 @uint64_t_ll_non_leading_deserialize(ptr noundef readonly %0, i64 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = icmp eq i64 %1, 0
  %5 = icmp eq ptr %0, null
  %or.cond = or i1 %5, %4
  br i1 %or.cond, label %.loopexit, label %6

6:                                                ; preds = %3
  %7 = icmp ult i64 %1, 2
  br i1 %7, label %8, label %9

8:                                                ; preds = %6
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.3) #3
  unreachable

9:                                                ; preds = %6
  %10 = load i64, ptr %0, align 8, !tbaa !5
  %11 = add i64 %10, 2
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = add i64 %11, %13
  %15 = shl i64 %14, 3
  %.not = icmp eq i64 %15, %1
  br i1 %.not, label %17, label %16

16:                                               ; preds = %9
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.4) #3
  unreachable

17:                                               ; preds = %9
  %18 = tail call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 1, i64 noundef 16) #4
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.5) #3
  unreachable

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %18, i64 8
  %invariant.gep = getelementptr i8, ptr %0, i64 16
  %.not36 = icmp eq i64 %10, 0
  br i1 %.not36, label %.preheader, label %.lr.ph

.preheader.loopexit:                              ; preds = %.lr.ph
  %.pre = load i64, ptr %12, align 8, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %21
  %23 = phi i64 [ %.pre, %.preheader.loopexit ], [ %13, %21 ]
  %.not37 = icmp eq i64 %23, 0
  br i1 %.not37, label %.loopexit, label %.lr.ph35

.lr.ph:                                           ; preds = %21, %.lr.ph
  %.031 = phi i64 [ %25, %.lr.ph ], [ 0, %21 ]
  %gep = getelementptr i64, ptr %invariant.gep, i64 %.031
  %24 = load i64, ptr %gep, align 8, !tbaa !5
  tail call void @uint64_t_ll_append(ptr noundef nonnull %18, i64 noundef %24)
  %25 = add nuw i64 %.031, 1
  %26 = load i64, ptr %0, align 8, !tbaa !5
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph, label %.preheader.loopexit, !llvm.loop !9

.lr.ph35:                                         ; preds = %.preheader, %.lr.ph35
  %.134 = phi i64 [ %31, %.lr.ph35 ], [ 0, %.preheader ]
  %28 = load i64, ptr %0, align 8, !tbaa !5
  %gep33 = getelementptr i64, ptr %invariant.gep, i64 %28
  %29 = getelementptr i64, ptr %gep33, i64 %.134
  %30 = load i64, ptr %29, align 8, !tbaa !5
  tail call void @uint64_t_ll_append(ptr noundef nonnull %22, i64 noundef %30)
  %31 = add nuw i64 %.134, 1
  %32 = load i64, ptr %12, align 8, !tbaa !5
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %.lr.ph35, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph35, %.preheader, %3
  %storemerge = phi ptr [ null, %3 ], [ %18, %.preheader ], [ %18, %.lr.ph35 ]
  %.027 = phi i64 [ 0, %3 ], [ 16, %.preheader ], [ 16, %.lr.ph35 ]
  store ptr %storemerge, ptr %2, align 8, !tbaa !12
  ret i64 %.027
}

; 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: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

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

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 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 = { noreturn "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 = { noreturn nounwind }
attributes #4 = { 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"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}


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