; LLVM IR from sympiler/nasoq :: nasoq_driver.ll (ZN7sym_lib10csr_to_cscEPN6format3CSRE)

; 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.format::CSR" = type { i64, i64, i64, i32, i8, i8, ptr, ptr, ptr }
%"struct.format::CSC" = type { i64, i64, i64, i32, i8, i8, ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7sym_lib10csc_to_csrEiiPiS0_PdRS0_S2_RS1_(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7sym_lib10csr_to_cscEPN6format3CSRE(ptr noundef %0) #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %7 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 56) #6
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.format::CSR", ptr %8, i32 0, i32 0
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.format::CSR", ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.format::CSR", ptr %14, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !15
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.format::CSR", ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !16
  invoke void @_ZN6format3CSCC2EmmmPiS1_i(ptr noundef nonnull align 8 dereferenceable(56) %7, i64 noundef %10, i64 noundef %13, i64 noundef %16, ptr noundef null, ptr noundef null, i32 noundef %19)
          to label %20 unwind label %61

20:                                               ; preds = %1
  store ptr %7, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.format::CSC", ptr %21, i32 0, i32 5
  store i8 0, ptr %22, align 1, !tbaa !17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.format::CSC", ptr %23, i32 0, i32 4
  store i8 0, ptr %24, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.format::CSR", ptr %25, i32 0, i32 0
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = trunc i64 %27 to i32
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.format::CSR", ptr %29, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !14
  %32 = trunc i64 %31 to i32
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.format::CSR", ptr %33, i32 0, i32 6
  %35 = load ptr, ptr %34, align 8, !tbaa !20
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.format::CSR", ptr %36, i32 0, i32 7
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.format::CSR", ptr %39, i32 0, i32 8
  %41 = load ptr, ptr %40, align 8, !tbaa !22
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.format::CSC", ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.format::CSC", ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.format::CSC", ptr %46, i32 0, i32 8
  %48 = call noundef i32 @_ZN7sym_lib10csc_to_csrEiiPiS0_PdRS0_S2_RS1_(i32 noundef %28, i32 noundef %32, ptr noundef %35, ptr noundef %38, ptr noundef %41, ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef nonnull align 8 dereferenceable(8) %47)
  store i32 %48, ptr %6, align 4, !tbaa !23
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.format::CSC", ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !24
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.format::CSC", ptr %52, i32 0, i32 1
  %54 = load i64, ptr %53, align 8, !tbaa !25
  %55 = getelementptr inbounds i32, ptr %51, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !23
  %57 = sext i32 %56 to i64
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.format::CSC", ptr %58, i32 0, i32 2
  store i64 %57, ptr %59, align 8, !tbaa !26
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret ptr %60

61:                                               ; preds = %1
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %4, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %7, i64 noundef 56) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %65

65:                                               ; preds = %61
  %66 = load ptr, ptr %4, align 8
  %67 = load i32, ptr %5, align 4
  %68 = insertvalue { ptr, i32 } poison, ptr %66, 0
  %69 = insertvalue { ptr, i32 } %68, i32 %67, 1
  resume { ptr, i32 } %69
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6format3CSCC2EmmmPiS1_i(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) unnamed_addr #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(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 = { nobuiltin 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 #3 = { 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 #4 = { mustprogress 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 }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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, !11, i64 0}
!10 = !{!"_ZTSN6format3CSRE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 28, !13, i64 29, !6, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !12, i64 24}
!17 = !{!18, !13, i64 29}
!18 = !{!"_ZTSN6format3CSCE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 28, !13, i64 29, !6, i64 32, !6, i64 40, !6, i64 48}
!19 = !{!18, !13, i64 28}
!20 = !{!10, !6, i64 32}
!21 = !{!10, !6, i64 40}
!22 = !{!10, !6, i64 48}
!23 = !{!12, !12, i64 0}
!24 = !{!18, !6, i64 32}
!25 = !{!18, !11, i64 8}
!26 = !{!18, !11, i64 16}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7sym_lib10csc_to_csrEiiPiS0_PdRS0_S2_RS1_(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN7sym_lib10csr_to_cscEPN6format3CSRE(ptr nocapture noundef readonly %0) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %2 = tail call noalias noundef nonnull dereferenceable(56) ptr @_Znwm(i64 noundef 56) #3
  %3 = load i64, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i32, ptr %8, align 8, !tbaa !15
  tail call void @_ZN6format3CSCC2EmmmPiS1_i(ptr noundef nonnull align 8 dereferenceable(56) %2, i64 noundef %3, i64 noundef %5, i64 noundef %7, ptr noundef null, ptr noundef null, i32 noundef %9)
  %10 = getelementptr inbounds i8, ptr %2, i64 29
  store i8 0, ptr %10, align 1, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %2, i64 28
  store i8 0, ptr %11, align 4, !tbaa !18
  %12 = load i64, ptr %0, align 8, !tbaa !5
  %13 = trunc i64 %12 to i32
  %14 = load i64, ptr %4, align 8, !tbaa !13
  %15 = trunc i64 %14 to i32
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load ptr, ptr %16, align 8, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %2, i64 32
  %23 = getelementptr inbounds i8, ptr %2, i64 40
  %24 = getelementptr inbounds i8, ptr %2, i64 48
  %25 = tail call noundef i32 @_ZN7sym_lib10csc_to_csrEiiPiS0_PdRS0_S2_RS1_(i32 noundef %13, i32 noundef %15, ptr noundef %17, ptr noundef %19, ptr noundef %21, ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = load ptr, ptr %22, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %2, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !23
  %29 = getelementptr inbounds i32, ptr %26, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !24
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %2, i64 16
  store i64 %31, ptr %32, align 8, !tbaa !25
  ret ptr %2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6format3CSCC2EmmmPiS1_i(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) unnamed_addr #2 align 2

attributes #0 = { nobuiltin allocsize(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 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 = { mustprogress 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 = { builtin allocsize(0) }

!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 0}
!6 = !{!"_ZTSN6format3CSRE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 28, !11, i64 29, !12, i64 32, !12, i64 40, !12, i64 48}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !10, i64 24}
!16 = !{!17, !11, i64 29}
!17 = !{!"_ZTSN6format3CSCE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 28, !11, i64 29, !12, i64 32, !12, i64 40, !12, i64 48}
!18 = !{!17, !11, i64 28}
!19 = !{!6, !12, i64 32}
!20 = !{!6, !12, i64 40}
!21 = !{!6, !12, i64 48}
!22 = !{!17, !12, i64 32}
!23 = !{!17, !7, i64 8}
!24 = !{!10, !10, i64 0}
!25 = !{!17, !7, i64 16}


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