; LLVM IR from caryll/otfcc :: lib/table (SVG)

; 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.__caryll_vectorinterface_table_SVG = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.table_SVG = type { i64, i64, ptr }
%struct.svg_Assignment = type { i16, i16, ptr }
%struct.caryll_Buffer = type { i64, i64, i64, ptr }

@table_iSVG = external dso_local constant %struct.__caryll_vectorinterface_table_SVG, align 8

; 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 ptr @otfcc_buildSVG(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.table_SVG, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %20

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.table_SVG, ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %15, %2
  store ptr null, ptr %3, align 8
  br label %89

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #3
  %22 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_table_SVG, ptr @table_iSVG, i32 0, i32 1), align 8, !tbaa !12
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  call void %22(ptr noundef %6, ptr noundef %23)
  %24 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_table_SVG, ptr @table_iSVG, i32 0, i32 18), align 8, !tbaa !14
  call void %24(ptr noundef %6, ptr noundef @byStartGID)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %25 = getelementptr inbounds %struct.table_SVG, ptr %6, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = call ptr (i32, ...) @bk_new_Block(i32 noundef 2, i64 noundef %26, i32 noundef 0)
  store ptr %27, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 1, ptr %9, align 8, !tbaa !15
  br label %28

28:                                               ; preds = %75, %21
  %29 = load i64, ptr %9, align 8, !tbaa !15
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = load i64, ptr %8, align 8, !tbaa !15
  %33 = getelementptr inbounds %struct.table_SVG, ptr %6, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = icmp ult i64 %32, %34
  br label %36

36:                                               ; preds = %31, %28
  %37 = phi i1 [ false, %28 ], [ %35, %31 ]
  br i1 %37, label %39, label %38

38:                                               ; preds = %36
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %83

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %40 = getelementptr inbounds %struct.table_SVG, ptr %6, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = load i64, ptr %8, align 8, !tbaa !15
  %43 = getelementptr inbounds %struct.svg_Assignment, ptr %41, i64 %42
  store ptr %43, ptr %11, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %68, %39
  %45 = load i64, ptr %9, align 8, !tbaa !15
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %74

48:                                               ; preds = %44
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.svg_Assignment, ptr %50, i32 0, i32 0
  %52 = load i16, ptr %51, align 8, !tbaa !17
  %53 = zext i16 %52 to i32
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.svg_Assignment, ptr %54, i32 0, i32 1
  %56 = load i16, ptr %55, align 2, !tbaa !20
  %57 = zext i16 %56 to i32
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.svg_Assignment, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  %61 = call ptr @bk_newBlockFromBufferCopy(ptr noundef %60)
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.svg_Assignment, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = getelementptr inbounds %struct.caryll_Buffer, ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !22
  %67 = call ptr (ptr, i32, ...) @bk_push(ptr noundef %49, i32 noundef 2, i32 noundef %53, i32 noundef 2, i32 noundef %57, i32 noundef 17, ptr noundef %61, i32 noundef 3, i64 noundef %66, i32 noundef 0)
  br label %68

68:                                               ; preds = %48
  %69 = load i64, ptr %9, align 8, !tbaa !15
  %70 = icmp ne i64 %69, 0
  %71 = xor i1 %70, true
  %72 = zext i1 %71 to i32
  %73 = sext i32 %72 to i64
  store i64 %73, ptr %9, align 8, !tbaa !15
  br label %44, !llvm.loop !24

74:                                               ; preds = %47
  br label %75

75:                                               ; preds = %74
  %76 = load i64, ptr %9, align 8, !tbaa !15
  %77 = icmp ne i64 %76, 0
  %78 = xor i1 %77, true
  %79 = zext i1 %78 to i32
  %80 = sext i32 %79 to i64
  store i64 %80, ptr %9, align 8, !tbaa !15
  %81 = load i64, ptr %8, align 8, !tbaa !15
  %82 = add i64 %81, 1
  store i64 %82, ptr %8, align 8, !tbaa !15
  br label %28, !llvm.loop !26

83:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = call ptr (i32, ...) @bk_new_Block(i32 noundef 2, i32 noundef 0, i32 noundef 17, ptr noundef %84, i32 noundef 3, i32 noundef 0, i32 noundef 0)
  store ptr %85, ptr %12, align 8, !tbaa !5
  %86 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_table_SVG, ptr @table_iSVG, i32 0, i32 3), align 8, !tbaa !27
  call void %86(ptr noundef %6)
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = call ptr @bk_build_Block(ptr noundef %87)
  store ptr %88, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #3
  br label %89

89:                                               ; preds = %83, %20
  %90 = load ptr, ptr %3, align 8
  ret ptr %90
}

; Function Attrs: nounwind uwtable
declare hidden i32 @byStartGID(ptr noundef, ptr noundef) #1

declare ptr @bk_new_Block(i32 noundef, ...) #2

declare ptr @bk_push(ptr noundef, i32 noundef, ...) #2

declare ptr @bk_newBlockFromBufferCopy(ptr noundef) #2

declare ptr @bk_build_Block(ptr noundef) #2

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 = { "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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 8}
!13 = !{!"__caryll_vectorinterface_table_SVG", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!14 = !{!13, !6, i64 144}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !6, i64 16}
!17 = !{!18, !19, i64 0}
!18 = !{!"", !19, i64 0, !19, i64 2, !6, i64 8}
!19 = !{!"short", !7, i64 0}
!20 = !{!18, !19, i64 2}
!21 = !{!18, !6, i64 8}
!22 = !{!23, !11, i64 8}
!23 = !{!"caryll_Buffer", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = !{!13, !6, i64 24}


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

%struct.__caryll_vectorinterface_table_SVG = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.table_SVG = type { i64, i64, ptr }
%struct.svg_Assignment = type { i16, i16, ptr }

@table_iSVG = external dso_local local_unnamed_addr constant %struct.__caryll_vectorinterface_table_SVG, align 8

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

; Function Attrs: mustprogress 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 ptr @otfcc_buildSVG(ptr noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = alloca %struct.table_SVG, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %33, label %4

4:                                                ; preds = %2
  %5 = load i64, ptr %0, align 8, !tbaa !5
  %.not20 = icmp eq i64 %5, 0
  br i1 %.not20, label %33, label %6

6:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @table_iSVG, i64 8), align 8, !tbaa !11
  call void %7(ptr noundef nonnull %3, ptr noundef nonnull %0) #3
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @table_iSVG, i64 144), align 8, !tbaa !13
  call void %8(ptr noundef nonnull %3, ptr noundef nonnull @byStartGID) #3
  %9 = load i64, ptr %3, align 8, !tbaa !5
  %10 = call ptr (i32, ...) @bk_new_Block(i32 noundef 2, i64 noundef %9, i32 noundef 0) #3
  %11 = load i64, ptr %3, align 8
  %.not23 = icmp eq i64 %11, 0
  br i1 %.not23, label %._crit_edge, label %.critedge.lr.ph

.critedge.lr.ph:                                  ; preds = %6
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  br label %.critedge

._crit_edge:                                      ; preds = %.critedge, %6
  %13 = call ptr (i32, ...) @bk_new_Block(i32 noundef 2, i32 noundef 0, i32 noundef 17, ptr noundef %10, i32 noundef 3, i32 noundef 0, i32 noundef 0) #3
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @table_iSVG, i64 24), align 8, !tbaa !14
  call void %14(ptr noundef nonnull %3) #3
  %15 = call ptr @bk_build_Block(ptr noundef %13) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  br label %33

.critedge:                                        ; preds = %.critedge.lr.ph, %.critedge
  %.01722 = phi i64 [ 0, %.critedge.lr.ph ], [ %30, %.critedge ]
  %16 = load ptr, ptr %12, align 8, !tbaa !15
  %17 = getelementptr inbounds %struct.svg_Assignment, ptr %16, i64 %.01722
  %18 = load i16, ptr %17, align 8, !tbaa !16
  %19 = zext i16 %18 to i32
  %20 = getelementptr inbounds i8, ptr %17, i64 2
  %21 = load i16, ptr %20, align 2, !tbaa !19
  %22 = zext i16 %21 to i32
  %23 = getelementptr inbounds i8, ptr %17, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %25 = call ptr @bk_newBlockFromBufferCopy(ptr noundef %24) #3
  %26 = load ptr, ptr %23, align 8, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !21
  %29 = call ptr (ptr, i32, ...) @bk_push(ptr noundef %10, i32 noundef 2, i32 noundef %19, i32 noundef 2, i32 noundef %22, i32 noundef 17, ptr noundef %25, i32 noundef 3, i64 noundef %28, i32 noundef 0) #3
  %30 = add nuw i64 %.01722, 1
  %31 = load i64, ptr %3, align 8
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %.critedge, label %._crit_edge, !llvm.loop !23

33:                                               ; preds = %2, %4, %._crit_edge
  %.0 = phi ptr [ %15, %._crit_edge ], [ null, %4 ], [ null, %2 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @byStartGID(ptr noundef, ptr noundef) #1

declare ptr @bk_new_Block(i32 noundef, ...) local_unnamed_addr #2

declare ptr @bk_push(ptr noundef, i32 noundef, ...) local_unnamed_addr #2

declare ptr @bk_newBlockFromBufferCopy(ptr noundef) local_unnamed_addr #2

declare ptr @bk_build_Block(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"__caryll_vectorinterface_table_SVG", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144}
!13 = !{!12, !10, i64 144}
!14 = !{!12, !10, i64 24}
!15 = !{!6, !10, i64 16}
!16 = !{!17, !18, i64 0}
!17 = !{!"", !18, i64 0, !18, i64 2, !10, i64 8}
!18 = !{!"short", !8, i64 0}
!19 = !{!17, !18, i64 2}
!20 = !{!17, !10, i64 8}
!21 = !{!22, !7, i64 8}
!22 = !{!"caryll_Buffer", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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