; LLVM IR from fwip/fastqz :: libzpaq.ll (ZN7libzpaq5ZPAQL3runEj)

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

%"class.libzpaq::ZPAQL" = type { ptr, ptr, %"class.libzpaq::Array.0", i32, i32, i32, [4 x i8], %"class.libzpaq::Array.0", %"class.libzpaq::Array", %"class.libzpaq::Array", %"class.libzpaq::Array.4", i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%"class.libzpaq::Array.0" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array.4" = type <{ ptr, i64, i32, [4 x i8] }>

@.str.45 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [17 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: mustprogress uwtable
declare dso_local void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1

declare void @_ZN7libzpaq5errorEPKc(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7libzpaq5ZPAQL3runEj(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 19
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = icmp ne ptr %8, null
  br i1 %9, label %31, label %10

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %11 = call noundef i32 @_ZN7libzpaq5ZPAQL8assembleEv(ptr noundef nonnull align 8 dereferenceable(192) %6)
  store i32 %11, ptr %5, align 4, !tbaa !9
  %12 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 19
  %13 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 18
  %14 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef %14)
  %15 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 19
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %29

18:                                               ; preds = %10
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp slt i32 %19, 10
  br i1 %20, label %29, label %21

21:                                               ; preds = %18
  %22 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 18
  %23 = load i32, ptr %22, align 4, !tbaa !17
  %24 = icmp slt i32 %23, 10
  br i1 %24, label %29, label %25

25:                                               ; preds = %21
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = call noundef i32 @_ZN7libzpaq5ZPAQL8assembleEv(ptr noundef nonnull align 8 dereferenceable(192) %6)
  %28 = icmp ne i32 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %25, %21, %18, %10
  call void @_ZN7libzpaq5errorEPKc(ptr noundef @.str.45)
  br label %30

30:                                               ; preds = %29, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %31

31:                                               ; preds = %30, %2
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 12
  store i32 %32, ptr %33, align 4, !tbaa !18
  %34 = getelementptr inbounds %"class.libzpaq::ZPAQL", ptr %6, i32 0, i32 19
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %35, i64 0
  %37 = call noundef i32 %36()
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %31
  call void @_ZN7libzpaq5errorEPKc(ptr noundef @.str.46)
  br label %40

40:                                               ; preds = %39, %31
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7libzpaq5ZPAQL8assembleEv(ptr noundef nonnull align 8 dereferenceable(192)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 184}
!12 = !{!"_ZTSN7libzpaq5ZPAQLE", !6, i64 0, !6, i64 8, !13, i64 16, !10, i64 40, !10, i64 44, !10, i64 48, !13, i64 56, !15, i64 80, !15, i64 104, !16, i64 128, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !6, i64 184}
!13 = !{!"_ZTSN7libzpaq5ArrayIhEE", !6, i64 0, !14, i64 8, !10, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN7libzpaq5ArrayIjEE", !6, i64 0, !14, i64 8, !10, i64 16}
!16 = !{!"_ZTSN7libzpaq5ArrayIcEE", !6, i64 0, !14, i64 8, !10, i64 16}
!17 = !{!12, !10, i64 180}
!18 = !{!12, !10, i64 156}


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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #0

declare void @_ZN7libzpaq5errorEPKc(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7libzpaq5ZPAQL3runEj(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 184
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %16

5:                                                ; preds = %2
  %6 = tail call noundef i32 @_ZN7libzpaq5ZPAQL8assembleEv(ptr noundef nonnull align 8 dereferenceable(192) %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 180
  tail call void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %7, i32 noundef %6)
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  %10 = icmp slt i32 %6, 10
  %or.cond = or i1 %10, %9
  %11 = load i32, ptr %7, align 4
  %12 = icmp slt i32 %11, 10
  %or.cond8 = select i1 %or.cond, i1 true, i1 %12
  br i1 %or.cond8, label %15, label %13

13:                                               ; preds = %5
  %14 = tail call noundef i32 @_ZN7libzpaq5ZPAQL8assembleEv(ptr noundef nonnull align 8 dereferenceable(192) %0)
  %.not5 = icmp eq i32 %6, %14
  br i1 %.not5, label %16, label %15

15:                                               ; preds = %13, %5
  tail call void @_ZN7libzpaq5errorEPKc(ptr noundef nonnull @.str.45)
  br label %16

16:                                               ; preds = %13, %15, %2
  %17 = getelementptr inbounds i8, ptr %0, i64 156
  store i32 %1, ptr %17, align 4, !tbaa !15
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = tail call noundef i32 %18()
  %.not6 = icmp eq i32 %19, 0
  br i1 %.not6, label %20, label %21

20:                                               ; preds = %16
  tail call void @_ZN7libzpaq5errorEPKc(ptr noundef nonnull @.str.46)
  br label %21

21:                                               ; preds = %20, %16
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7libzpaq5ZPAQL8assembleEv(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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, !7, i64 184}
!6 = !{!"_ZTSN7libzpaq5ZPAQLE", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 40, !12, i64 44, !12, i64 48, !10, i64 56, !13, i64 80, !13, i64 104, !14, i64 128, !12, i64 152, !12, i64 156, !12, i64 160, !12, i64 164, !12, i64 168, !12, i64 172, !12, i64 176, !12, i64 180, !7, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7libzpaq5ArrayIhEE", !7, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_ZTSN7libzpaq5ArrayIjEE", !7, i64 0, !11, i64 8, !12, i64 16}
!14 = !{!"_ZTSN7libzpaq5ArrayIcEE", !7, i64 0, !11, i64 8, !12, i64 16}
!15 = !{!6, !12, i64 156}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass