; LLVM IR from caryll/otfcc :: src (otfccdll)

; 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_elementinterface_otfcc_Font = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otfcc_Options = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, ptr }
%struct.otfcc_ILogger = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.otfcc_IFontBuilder = type { ptr, ptr }
%struct.otfcc_IFontSerializer = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@otfcc_iFont = external constant %struct.__caryll_elementinterface_otfcc_Font, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @otfccbuild_json_otf(i32 noundef %0, ptr noundef %1, i8 noundef zeroext %2, i1 noundef zeroext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store i8 %2, ptr %8, align 1, !tbaa !11
  %17 = zext i1 %3 to i8
  store i8 %17, ptr %9, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %18 = call ptr (...) @otfcc_newOptions()
  store ptr %18, ptr %10, align 8, !tbaa !9
  %19 = call ptr (...) @otfcc_newEmptyTarget()
  %20 = call ptr @otfcc_newLogger(ptr noundef %19)
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.otfcc_Options, ptr %21, i32 0, i32 24
  store ptr %20, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr %10, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.otfcc_Options, ptr %23, i32 0, i32 24
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = getelementptr inbounds %struct.otfcc_ILogger, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = load ptr, ptr %10, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.otfcc_Options, ptr %28, i32 0, i32 24
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  call void %27(ptr noundef %30, ptr noundef @.str)
  %31 = load ptr, ptr %10, align 8, !tbaa !9
  %32 = load i8, ptr %8, align 1, !tbaa !11
  call void @otfcc_Options_optimizeTo(ptr noundef %31, i8 noundef zeroext %32)
  %33 = load i8, ptr %9, align 1, !tbaa !12, !range !18, !noundef !19
  %34 = trunc i8 %33 to i1
  br i1 %34, label %35, label %40

35:                                               ; preds = %4
  %36 = load ptr, ptr %10, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.otfcc_Options, ptr %36, i32 0, i32 1
  store i8 1, ptr %37, align 1, !tbaa !20
  %38 = load ptr, ptr %10, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.otfcc_Options, ptr %38, i32 0, i32 16
  store i8 1, ptr %39, align 8, !tbaa !21
  br label %40

40:                                               ; preds = %35, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = call ptr @json_parse(ptr noundef %41, i64 noundef %43)
  store ptr %44, ptr %11, align 8, !tbaa !9
  %45 = load ptr, ptr %11, align 8, !tbaa !9
  %46 = icmp ne ptr %45, null
  br i1 %46, label %48, label %47

47:                                               ; preds = %40
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %83

48:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %49 = call ptr (...) @otfcc_newJsonReader()
  store ptr %49, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %50 = load ptr, ptr %13, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.otfcc_IFontBuilder, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !22
  %53 = load ptr, ptr %11, align 8, !tbaa !9
  %54 = load ptr, ptr %10, align 8, !tbaa !9
  %55 = call ptr %52(ptr noundef %53, i32 noundef 0, ptr noundef %54)
  store ptr %55, ptr %14, align 8, !tbaa !9
  %56 = load ptr, ptr %13, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.otfcc_IFontBuilder, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !24
  %59 = load ptr, ptr %13, align 8, !tbaa !9
  call void %58(ptr noundef %59)
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  call void @json_value_free(ptr noundef %60)
  %61 = load ptr, ptr %14, align 8, !tbaa !9
  %62 = icmp ne ptr %61, null
  br i1 %62, label %64, label %63

63:                                               ; preds = %48
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %82

64:                                               ; preds = %48
  %65 = load ptr, ptr getelementptr inbounds (%struct.__caryll_elementinterface_otfcc_Font, ptr @otfcc_iFont, i32 0, i32 8), align 8, !tbaa !25
  %66 = load ptr, ptr %14, align 8, !tbaa !9
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  call void %65(ptr noundef %66, ptr noundef %67)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %68 = call ptr (...) @otfcc_newOTFWriter()
  store ptr %68, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %69 = load ptr, ptr %15, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.otfcc_IFontSerializer, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !27
  %72 = load ptr, ptr %14, align 8, !tbaa !9
  %73 = load ptr, ptr %10, align 8, !tbaa !9
  %74 = call ptr %71(ptr noundef %72, ptr noundef %73)
  store ptr %74, ptr %16, align 8, !tbaa !9
  %75 = load ptr, ptr %15, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.otfcc_IFontSerializer, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !29
  %78 = load ptr, ptr %15, align 8, !tbaa !9
  call void %77(ptr noundef %78)
  %79 = load ptr, ptr getelementptr inbounds (%struct.__caryll_elementinterface_otfcc_Font, ptr @otfcc_iFont, i32 0, i32 7), align 8, !tbaa !30
  %80 = load ptr, ptr %14, align 8, !tbaa !9
  call void %79(ptr noundef %80)
  %81 = load ptr, ptr %16, align 8, !tbaa !9
  store ptr %81, ptr %5, align 8
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %82

82:                                               ; preds = %64, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %83

83:                                               ; preds = %82, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %84 = load ptr, ptr %5, align 8
  ret ptr %84
}

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

declare ptr @otfcc_newOptions(...) #2

declare ptr @otfcc_newLogger(ptr noundef) #2

declare ptr @otfcc_newEmptyTarget(...) #2

declare void @otfcc_Options_optimizeTo(ptr noundef, i8 noundef zeroext) #2

declare ptr @json_parse(ptr noundef, i64 noundef) #2

declare ptr @otfcc_newJsonReader(...) #2

declare void @json_value_free(ptr noundef) #2

declare ptr @otfcc_newOTFWriter(...) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!15, !10, i64 32}
!15 = !{!"", !13, i64 0, !13, i64 1, !13, i64 2, !13, i64 3, !13, i64 4, !13, i64 5, !13, i64 6, !13, i64 7, !13, i64 8, !13, i64 9, !13, i64 10, !13, i64 11, !13, i64 12, !13, i64 13, !13, i64 14, !13, i64 15, !13, i64 16, !13, i64 17, !13, i64 18, !13, i64 19, !13, i64 20, !13, i64 21, !13, i64 22, !10, i64 24, !10, i64 32}
!16 = !{!17, !10, i64 8}
!17 = !{!"otfcc_ILogger", !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}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!15, !13, i64 1}
!21 = !{!15, !13, i64 16}
!22 = !{!23, !10, i64 0}
!23 = !{!"otfcc_IFontBuilder", !10, i64 0, !10, i64 8}
!24 = !{!23, !10, i64 8}
!25 = !{!26, !10, i64 64}
!26 = !{!"__caryll_elementinterface_otfcc_Font", !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}
!27 = !{!28, !10, i64 0}
!28 = !{!"otfcc_IFontSerializer", !10, i64 0, !10, i64 8}
!29 = !{!28, !10, i64 8}
!30 = !{!26, !10, i64 56}


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

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@otfcc_iFont = external local_unnamed_addr constant %struct.__caryll_elementinterface_otfcc_Font, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @otfccbuild_json_otf(i32 noundef %0, ptr noundef %1, i8 noundef zeroext %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = tail call ptr (...) @otfcc_newOptions() #2
  %6 = tail call ptr (...) @otfcc_newEmptyTarget() #2
  %7 = tail call ptr @otfcc_newLogger(ptr noundef %6) #2
  %8 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %7, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  tail call void %10(ptr noundef %7, ptr noundef nonnull @.str) #2
  tail call void @otfcc_Options_optimizeTo(ptr noundef %5, i8 noundef zeroext %2) #2
  br i1 %3, label %11, label %14

11:                                               ; preds = %4
  %12 = getelementptr inbounds i8, ptr %5, i64 1
  store i8 1, ptr %12, align 1, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %5, i64 16
  store i8 1, ptr %13, align 8, !tbaa !14
  br label %14

14:                                               ; preds = %11, %4
  %15 = zext i32 %0 to i64
  %16 = tail call ptr @json_parse(ptr noundef %1, i64 noundef %15) #2
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %31, label %17

17:                                               ; preds = %14
  %18 = tail call ptr (...) @otfcc_newJsonReader() #2
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = tail call ptr %19(ptr noundef nonnull %16, i32 noundef 0, ptr noundef nonnull %5) #2
  %21 = getelementptr inbounds i8, ptr %18, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  tail call void %22(ptr noundef nonnull %18) #2
  tail call void @json_value_free(ptr noundef nonnull %16) #2
  %.not29 = icmp eq ptr %20, null
  br i1 %.not29, label %31, label %23

23:                                               ; preds = %17
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @otfcc_iFont, i64 64), align 8, !tbaa !18
  tail call void %24(ptr noundef nonnull %20, ptr noundef nonnull %5) #2
  %25 = tail call ptr (...) @otfcc_newOTFWriter() #2
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  %27 = tail call ptr %26(ptr noundef nonnull %20, ptr noundef nonnull %5) #2
  %28 = getelementptr inbounds i8, ptr %25, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !22
  tail call void %29(ptr noundef nonnull %25) #2
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @otfcc_iFont, i64 56), align 8, !tbaa !23
  tail call void %30(ptr noundef nonnull %20) #2
  br label %31

31:                                               ; preds = %23, %17, %14
  %.1 = phi ptr [ null, %14 ], [ %27, %23 ], [ null, %17 ]
  ret ptr %.1
}

declare ptr @otfcc_newOptions(...) local_unnamed_addr #1

declare ptr @otfcc_newLogger(ptr noundef) local_unnamed_addr #1

declare ptr @otfcc_newEmptyTarget(...) local_unnamed_addr #1

declare void @otfcc_Options_optimizeTo(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare ptr @json_parse(ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @otfcc_newJsonReader(...) local_unnamed_addr #1

declare void @json_value_free(ptr noundef) local_unnamed_addr #1

declare ptr @otfcc_newOTFWriter(...) local_unnamed_addr #1

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 = { "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 }

!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, !10, i64 32}
!6 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22, !10, i64 24, !10, i64 32}
!7 = !{!"_Bool", !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 = !{!"otfcc_ILogger", !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}
!13 = !{!6, !7, i64 1}
!14 = !{!6, !7, i64 16}
!15 = !{!16, !10, i64 0}
!16 = !{!"otfcc_IFontBuilder", !10, i64 0, !10, i64 8}
!17 = !{!16, !10, i64 8}
!18 = !{!19, !10, i64 64}
!19 = !{!"__caryll_elementinterface_otfcc_Font", !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}
!20 = !{!21, !10, i64 0}
!21 = !{!"otfcc_IFontSerializer", !10, i64 0, !10, i64 8}
!22 = !{!21, !10, i64 8}
!23 = !{!19, !10, i64 56}


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