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

; 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_cpal_ColorSet = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__caryll_elementinterface_cpal_Palette = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__caryll_vectorinterface_cpal_PaletteSet = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__caryll_elementinterface_table_CPAL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cpal_Palette = type { %struct.cpal_ColorSet, i32, i32 }
%struct.cpal_ColorSet = type { i64, i64, ptr }
%struct.cpal_Color = type { i8, i8, i8, i8, i16 }
%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._json_value = type { ptr, i32, %union.anon, %union.anon.2 }
%union.anon = type { %struct.anon }
%struct.anon = type { i32, ptr }
%union.anon.2 = type { ptr }
%struct.anon.1 = type { i32, ptr }
%struct.table_CPAL = type { i16, %struct.cpal_PaletteSet }
%struct.cpal_PaletteSet = type { i64, i64, ptr }

@cpal_iColorSet = external dso_local constant %struct.__caryll_vectorinterface_cpal_ColorSet, align 8
@cpal_iPalette = external dso_local constant %struct.__caryll_elementinterface_cpal_Palette, align 8
@cpal_iPaletteSet = external dso_local constant %struct.__caryll_vectorinterface_cpal_PaletteSet, align 8
@table_iCPAL = external dso_local constant %struct.__caryll_elementinterface_table_CPAL, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

declare ptr @sdscatprintf(ptr noundef, ptr noundef, ...) #2

declare ptr @sdsempty() #2

; Function Attrs: nounwind uwtable
define dso_local ptr @otfcc_parseCPAL(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i16, align 2
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %struct.cpal_Palette, align 8
  %15 = alloca i16, align 2
  %16 = alloca %struct.cpal_Color, align 2
  %17 = alloca i48, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call ptr @json_obj_get_type(ptr noundef %18, ptr noundef @.str, i32 noundef 1)
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %151

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.otfcc_Options, ptr %23, i32 0, i32 24
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.otfcc_ILogger, ptr %25, i32 0, i32 4
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.otfcc_Options, ptr %28, i32 0, i32 24
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = call ptr @sdsempty()
  %32 = call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %31, ptr noundef @.str)
  call void %27(ptr noundef %30, ptr noundef %32)
  store i8 1, ptr %9, align 1, !tbaa !14
  br label %33

33:                                               ; preds = %137, %22
  %34 = load i8, ptr %9, align 1, !tbaa !14, !range !15, !noundef !16
  %35 = trunc i8 %34 to i1
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  store i32 2, ptr %7, align 4
  br label %146

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call ptr @json_obj_get_type(ptr noundef %38, ptr noundef @.str.2, i32 noundef 2)
  store ptr %39, ptr %10, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %48

42:                                               ; preds = %37
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._json_value, ptr %43, i32 0, i32 2
  %45 = getelementptr inbounds %struct.anon.1, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !17
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %42, %37
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %134

49:                                               ; preds = %42
  %50 = load ptr, ptr getelementptr inbounds (%struct.__caryll_elementinterface_table_CPAL, ptr @table_iCPAL, i32 0, i32 6), align 8, !tbaa !18
  %51 = call ptr (...) %50()
  store ptr %51, ptr %8, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = call i32 @json_obj_getint(ptr noundef %52, ptr noundef @.str.1)
  %54 = trunc i32 %53 to i16
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.table_CPAL, ptr %55, i32 0, i32 0
  store i16 %54, ptr %56, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #5
  store i16 0, ptr %11, align 2, !tbaa !25
  br label %57

57:                                               ; preds = %130, %49
  %58 = load i16, ptr %11, align 2, !tbaa !25
  %59 = zext i16 %58 to i32
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._json_value, ptr %60, i32 0, i32 2
  %62 = getelementptr inbounds %struct.anon.1, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !17
  %64 = icmp ult i32 %59, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %57
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #5
  br label %133

66:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._json_value, ptr %67, i32 0, i32 2
  %69 = getelementptr inbounds %struct.anon.1, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !17
  %71 = load i16, ptr %11, align 2, !tbaa !25
  %72 = zext i16 %71 to i64
  %73 = getelementptr inbounds ptr, ptr %70, i64 %72
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  store ptr %74, ptr %12, align 8, !tbaa !5
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %82

77:                                               ; preds = %66
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._json_value, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 8, !tbaa !26
  %81 = icmp ne i32 %80, 1
  br i1 %81, label %82, label %83

82:                                               ; preds = %77, %66
  store i32 7, ptr %7, align 4
  br label %127

83:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = call ptr @json_obj_get_type(ptr noundef %84, ptr noundef @.str.3, i32 noundef 2)
  store ptr %85, ptr %13, align 8, !tbaa !5
  %86 = load ptr, ptr %13, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %89, label %88

88:                                               ; preds = %83
  store i32 7, ptr %7, align 4
  br label %126

89:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #5
  %90 = load ptr, ptr @cpal_iPalette, align 8, !tbaa !29
  call void %90(ptr noundef %14)
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = call i32 @json_obj_getint(ptr noundef %91, ptr noundef @.str.4)
  %93 = getelementptr inbounds %struct.cpal_Palette, ptr %14, i32 0, i32 1
  store i32 %92, ptr %93, align 8, !tbaa !31
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = call i32 @json_obj_getint_fallback(ptr noundef %94, ptr noundef @.str.4, i32 noundef 65535)
  %96 = getelementptr inbounds %struct.cpal_Palette, ptr %14, i32 0, i32 2
  store i32 %95, ptr %96, align 4, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #5
  store i16 0, ptr %15, align 2, !tbaa !25
  br label %97

97:                                               ; preds = %119, %89
  %98 = load i16, ptr %15, align 2, !tbaa !25
  %99 = zext i16 %98 to i32
  %100 = load ptr, ptr %13, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._json_value, ptr %100, i32 0, i32 2
  %102 = getelementptr inbounds %struct.anon.1, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 8, !tbaa !17
  %104 = icmp ult i32 %99, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %97
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #5
  br label %122

106:                                              ; preds = %97
  %107 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_cpal_ColorSet, ptr @cpal_iColorSet, i32 0, i32 13), align 8, !tbaa !34
  %108 = getelementptr inbounds %struct.cpal_Palette, ptr %14, i32 0, i32 0
  %109 = load ptr, ptr %13, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._json_value, ptr %109, i32 0, i32 2
  %111 = getelementptr inbounds %struct.anon.1, ptr %110, i32 0, i32 1
  %112 = load ptr, ptr %111, align 8, !tbaa !17
  %113 = load i16, ptr %15, align 2, !tbaa !25
  %114 = zext i16 %113 to i64
  %115 = getelementptr inbounds ptr, ptr %112, i64 %114
  %116 = load ptr, ptr %115, align 8, !tbaa !5
  %117 = call i48 @parseColor(ptr noundef %116)
  store i48 %117, ptr %16, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 2 %16, i64 6, i1 false)
  %118 = load i48, ptr %17, align 8
  call void %107(ptr noundef %108, i48 %118)
  br label %119

119:                                              ; preds = %106
  %120 = load i16, ptr %15, align 2, !tbaa !25
  %121 = add i16 %120, 1
  store i16 %121, ptr %15, align 2, !tbaa !25
  br label %97, !llvm.loop !36

122:                                              ; preds = %105
  %123 = load ptr, ptr getelementptr inbounds (%struct.__caryll_vectorinterface_cpal_PaletteSet, ptr @cpal_iPaletteSet, i32 0, i32 13), align 8, !tbaa !38
  %124 = load ptr, ptr %8, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.table_CPAL, ptr %124, i32 0, i32 1
  call void %123(ptr noundef %125, ptr noundef byval(%struct.cpal_Palette) align 8 %14)
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  store i32 0, ptr %7, align 4
  br label %126

126:                                              ; preds = %122, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %127

127:                                              ; preds = %126, %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %128 = load i32, ptr %7, align 4
  switch i32 %128, label %153 [
    i32 0, label %129
    i32 7, label %130
  ]

129:                                              ; preds = %127
  br label %130

130:                                              ; preds = %129, %127
  %131 = load i16, ptr %11, align 2, !tbaa !25
  %132 = add i16 %131, 1
  store i16 %132, ptr %11, align 2, !tbaa !25
  br label %57, !llvm.loop !40

133:                                              ; preds = %65
  store i32 0, ptr %7, align 4
  br label %134

134:                                              ; preds = %133, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %135 = load i32, ptr %7, align 4
  switch i32 %135, label %146 [
    i32 0, label %136
  ]

136:                                              ; preds = %134
  br label %137

137:                                              ; preds = %136
  store i8 0, ptr %9, align 1, !tbaa !14
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.otfcc_Options, ptr %138, i32 0, i32 24
  %140 = load ptr, ptr %139, align 8, !tbaa !9
  %141 = getelementptr inbounds %struct.otfcc_ILogger, ptr %140, i32 0, i32 8
  %142 = load ptr, ptr %141, align 8, !tbaa !41
  %143 = load ptr, ptr %5, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.otfcc_Options, ptr %143, i32 0, i32 24
  %145 = load ptr, ptr %144, align 8, !tbaa !9
  call void %142(ptr noundef %145)
  br label %33, !llvm.loop !42

146:                                              ; preds = %134, %36
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  %147 = load i32, ptr %7, align 4
  switch i32 %147, label %150 [
    i32 2, label %148
  ]

148:                                              ; preds = %146
  %149 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %149, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %150

150:                                              ; preds = %148, %146
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %151

151:                                              ; preds = %150, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %152 = load ptr, ptr %3, align 8
  ret ptr %152

153:                                              ; preds = %127
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @json_obj_get_type(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @json_obj_getint(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @json_obj_getint_fallback(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i48 @parseColor(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 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 = { inlinehint 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 }

!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, !6, i64 32}
!10 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8, !11, i64 9, !11, i64 10, !11, i64 11, !11, i64 12, !11, i64 13, !11, i64 14, !11, i64 15, !11, i64 16, !11, i64 17, !11, i64 18, !11, i64 19, !11, i64 20, !11, i64 21, !11, i64 22, !6, i64 24, !6, i64 32}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!13, !6, i64 32}
!13 = !{!"otfcc_ILogger", !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}
!14 = !{!11, !11, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !6, i64 48}
!19 = !{!"__caryll_elementinterface_table_CPAL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!20 = !{!21, !22, i64 0}
!21 = !{!"", !22, i64 0, !23, i64 8}
!22 = !{!"short", !7, i64 0}
!23 = !{!"", !24, i64 0, !24, i64 8, !6, i64 16}
!24 = !{!"long", !7, i64 0}
!25 = !{!22, !22, i64 0}
!26 = !{!27, !28, i64 8}
!27 = !{!"_json_value", !6, i64 0, !28, i64 8, !7, i64 16, !7, i64 32}
!28 = !{!"int", !7, i64 0}
!29 = !{!30, !6, i64 0}
!30 = !{!"__caryll_elementinterface_cpal_Palette", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!31 = !{!32, !28, i64 24}
!32 = !{!"", !23, i64 0, !28, i64 24, !28, i64 28}
!33 = !{!32, !28, i64 28}
!34 = !{!35, !6, i64 104}
!35 = !{!"__caryll_vectorinterface_cpal_ColorSet", !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}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!39, !6, i64 104}
!39 = !{!"__caryll_vectorinterface_cpal_PaletteSet", !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}
!40 = distinct !{!40, !37}
!41 = !{!13, !6, i64 64}
!42 = distinct !{!42, !37}


; 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_cpal_ColorSet = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__caryll_elementinterface_cpal_Palette = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__caryll_vectorinterface_cpal_PaletteSet = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.__caryll_elementinterface_table_CPAL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cpal_Palette = type { %struct.cpal_ColorSet, i32, i32 }
%struct.cpal_ColorSet = type { i64, i64, ptr }

@cpal_iColorSet = external dso_local local_unnamed_addr constant %struct.__caryll_vectorinterface_cpal_ColorSet, align 8
@cpal_iPalette = external dso_local local_unnamed_addr constant %struct.__caryll_elementinterface_cpal_Palette, align 8
@cpal_iPaletteSet = external dso_local local_unnamed_addr constant %struct.__caryll_vectorinterface_cpal_PaletteSet, align 8
@table_iCPAL = external dso_local local_unnamed_addr constant %struct.__caryll_elementinterface_table_CPAL, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1

; 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

declare ptr @sdscatprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare ptr @sdsempty() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @otfcc_parseCPAL(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca %struct.cpal_Palette, align 8
  %4 = tail call ptr @json_obj_get_type(ptr noundef %0, ptr noundef nonnull @.str, i32 noundef 1)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.thread, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = tail call ptr @sdsempty() #4
  %11 = tail call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %10, ptr noundef nonnull @.str) #4
  tail call void %9(ptr noundef %7, ptr noundef %11) #4
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @table_iCPAL, i64 48), align 8
  %13 = load ptr, ptr @cpal_iPalette, align 8
  %14 = getelementptr inbounds i8, ptr %3, i64 24
  %15 = getelementptr inbounds i8, ptr %3, i64 28
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @cpal_iColorSet, i64 104), align 8
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @cpal_iPaletteSet, i64 104), align 8
  %18 = tail call ptr @json_obj_get_type(ptr noundef nonnull %4, ptr noundef nonnull @.str.2, i32 noundef 2)
  %.not45 = icmp eq ptr %18, null
  br i1 %.not45, label %.thread, label %19

19:                                               ; preds = %5
  %20 = getelementptr inbounds i8, ptr %18, i64 16
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %.not46 = icmp eq i32 %21, 0
  br i1 %.not46, label %.thread, label %22

22:                                               ; preds = %19
  %23 = tail call ptr (...) %12() #4
  %24 = tail call i32 @json_obj_getint(ptr noundef nonnull %4, ptr noundef nonnull @.str.1)
  %25 = trunc i32 %24 to i16
  store i16 %25, ptr %23, align 8, !tbaa !14
  %26 = load i32, ptr %20, align 8, !tbaa !13
  %.not57 = icmp eq i32 %26, 0
  br i1 %.not57, label %._crit_edge56, label %.lr.ph55

.lr.ph55:                                         ; preds = %22
  %27 = getelementptr inbounds i8, ptr %18, i64 24
  %28 = getelementptr inbounds i8, ptr %23, i64 8
  br label %29

29:                                               ; preds = %.lr.ph55, %55
  %.03953 = phi i16 [ 0, %.lr.ph55 ], [ %56, %55 ]
  %30 = load ptr, ptr %27, align 8, !tbaa !13
  %31 = zext i16 %.03953 to i64
  %32 = getelementptr inbounds ptr, ptr %30, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  %.not47 = icmp eq ptr %33, null
  br i1 %.not47, label %55, label %34

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %33, i64 8
  %36 = load i32, ptr %35, align 8, !tbaa !20
  %.not48 = icmp eq i32 %36, 1
  br i1 %.not48, label %37, label %55

37:                                               ; preds = %34
  %38 = call ptr @json_obj_get_type(ptr noundef nonnull %33, ptr noundef nonnull @.str.3, i32 noundef 2)
  %.not49 = icmp eq ptr %38, null
  br i1 %.not49, label %55, label %39

39:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  call void %13(ptr noundef nonnull %3) #4
  %40 = call i32 @json_obj_getint(ptr noundef nonnull %33, ptr noundef nonnull @.str.4)
  store i32 %40, ptr %14, align 8, !tbaa !23
  %41 = call i32 @json_obj_getint_fallback(ptr noundef nonnull %33, ptr noundef nonnull @.str.4, i32 noundef 65535)
  store i32 %41, ptr %15, align 4, !tbaa !25
  %42 = getelementptr inbounds i8, ptr %38, i64 16
  %43 = load i32, ptr %42, align 8, !tbaa !13
  %.not58 = icmp eq i32 %43, 0
  br i1 %.not58, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %39
  %44 = getelementptr inbounds i8, ptr %38, i64 24
  br label %45

._crit_edge:                                      ; preds = %45, %39
  call void %17(ptr noundef nonnull %28, ptr noundef nonnull byval(%struct.cpal_Palette) align 8 %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  br label %55

45:                                               ; preds = %.lr.ph, %45
  %.03352 = phi i16 [ 0, %.lr.ph ], [ %51, %45 ]
  %46 = load ptr, ptr %44, align 8, !tbaa !13
  %47 = zext i16 %.03352 to i64
  %48 = getelementptr inbounds ptr, ptr %46, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  %50 = call i48 @parseColor(ptr noundef %49)
  call void %16(ptr noundef nonnull %3, i48 %50) #4
  %51 = add i16 %.03352, 1
  %52 = zext i16 %51 to i32
  %53 = load i32, ptr %42, align 8, !tbaa !13
  %54 = icmp ugt i32 %53, %52
  br i1 %54, label %45, label %._crit_edge, !llvm.loop !26

55:                                               ; preds = %._crit_edge, %37, %29, %34
  %56 = add i16 %.03953, 1
  %57 = zext i16 %56 to i32
  %58 = load i32, ptr %20, align 8, !tbaa !13
  %59 = icmp ugt i32 %58, %57
  br i1 %59, label %29, label %._crit_edge56, !llvm.loop !28

._crit_edge56:                                    ; preds = %55, %22
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 64
  %62 = load ptr, ptr %61, align 8, !tbaa !29
  call void %62(ptr noundef %60) #4
  br label %.thread, !llvm.loop !30

.thread:                                          ; preds = %19, %5, %._crit_edge56, %2
  %.4 = phi ptr [ null, %2 ], [ %23, %._crit_edge56 ], [ null, %19 ], [ null, %5 ]
  ret ptr %.4
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @json_obj_get_type(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @json_obj_getint(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @json_obj_getint_fallback(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i48 @parseColor(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { inlinehint 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 #4 = { 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 32}
!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 = !{!8, !8, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"", !16, i64 0, !17, i64 8}
!16 = !{!"short", !8, i64 0}
!17 = !{!"", !18, i64 0, !18, i64 8, !10, i64 16}
!18 = !{!"long", !8, i64 0}
!19 = !{!10, !10, i64 0}
!20 = !{!21, !22, i64 8}
!21 = !{!"_json_value", !10, i64 0, !22, i64 8, !8, i64 16, !8, i64 32}
!22 = !{!"int", !8, i64 0}
!23 = !{!24, !22, i64 24}
!24 = !{!"", !17, i64 0, !22, i64 24, !22, i64 28}
!25 = !{!24, !22, i64 28}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}
!29 = !{!12, !10, i64 64}
!30 = distinct !{!30, !27}


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