; LLVM IR from freakout42/macrocalc :: arx/src (sql_crep)

; 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.DBF = type { [1024 x i8], [1024 x i8], ptr, ptr, i32, i32, i8, i8, i8, i8, i8, i8, i8, i32, i32, i8, ptr, ptr, %struct.DBFPROLOG }
%struct.DBFPROLOG = type { i8, i8, i8, i8, i32, i16, i16, i16, i8, i8, [12 x i8], i8, [3 x i8] }
%struct.FIELD_RECORD = type { [11 x i8], i8, i32, i8, i8, [14 x i8] }

@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @sql_crep(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.DBF, ptr %11, i32 0, i32 16
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DBF, ptr %14, i32 0, i32 15
  %16 = load i8, ptr %15, align 8, !tbaa !14
  %17 = zext i8 %16 to i32
  %18 = mul i32 %17, 32
  %19 = zext i32 %18 to i64
  %20 = call noalias ptr @malloc(i64 noundef %19) #8
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DBF, ptr %21, i32 0, i32 16
  store ptr %20, ptr %22, align 8, !tbaa !9
  %23 = icmp eq ptr %20, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %1
  store i32 8, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %221

25:                                               ; preds = %1
  %26 = call noalias ptr @malloc(i64 noundef 4001) #8
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DBF, ptr %27, i32 0, i32 17
  store ptr %26, ptr %28, align 8, !tbaa !15
  %29 = icmp eq ptr %26, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i32 8, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %221

31:                                               ; preds = %25
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.DBF, ptr %32, i32 0, i32 13
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %67

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.DBF, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.DBF, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds [1024 x i8], ptr %41, i64 0, i64 0
  %43 = load i8, ptr %42, align 8, !tbaa !18
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %36
  br label %51

47:                                               ; preds = %36
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.DBF, ptr %48, i32 0, i32 1
  %50 = getelementptr inbounds [1024 x i8], ptr %49, i64 0, i64 0
  br label %51

51:                                               ; preds = %47, %46
  %52 = phi ptr [ @.str.1, %46 ], [ %50, %47 ]
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.DBF, ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds [1024 x i8], ptr %54, i64 0, i64 0
  %56 = load i8, ptr %55, align 8, !tbaa !18
  %57 = sext i8 %56 to i32
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %51
  br label %64

60:                                               ; preds = %51
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.DBF, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds [1024 x i8], ptr %62, i64 0, i64 0
  br label %64

64:                                               ; preds = %60, %59
  %65 = phi ptr [ @.str.1, %59 ], [ %63, %60 ]
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str, ptr noundef %52, ptr noundef %65) #7
  br label %67

67:                                               ; preds = %64, %31
  store i8 1, ptr %4, align 1, !tbaa !18
  br label %68

68:                                               ; preds = %207, %67
  %69 = load i8, ptr %4, align 1, !tbaa !18
  %70 = zext i8 %69 to i32
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.DBF, ptr %71, i32 0, i32 15
  %73 = load i8, ptr %72, align 8, !tbaa !14
  %74 = zext i8 %73 to i32
  %75 = icmp sle i32 %70, %74
  br i1 %75, label %76, label %210

76:                                               ; preds = %68
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.DBF, ptr %77, i32 0, i32 16
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  %80 = load i8, ptr %4, align 1, !tbaa !18
  %81 = zext i8 %80 to i32
  %82 = sub nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %struct.FIELD_RECORD, ptr %79, i64 %83
  store ptr %84, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.FIELD_RECORD, ptr %86, i32 1
  store ptr %87, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %85, ptr align 4 %86, i64 32, i1 false), !tbaa.struct !19
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.FIELD_RECORD, ptr %88, i32 0, i32 0
  %90 = getelementptr inbounds [11 x i8], ptr %89, i64 0, i64 0
  store ptr %90, ptr %6, align 8, !tbaa !5
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.DBF, ptr %91, i32 0, i32 14
  %93 = load i32, ptr %92, align 4, !tbaa !21
  switch i32 %93, label %118 [
    i32 1, label %94
    i32 2, label %97
    i32 3, label %100
    i32 0, label %118
  ]

94:                                               ; preds = %76
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = call ptr @str_upr(ptr noundef %95)
  br label %118

97:                                               ; preds = %76
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = call ptr @str_low(ptr noundef %98)
  br label %118

100:                                              ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %101 = call ptr @__ctype_toupper_loc() #9
  %102 = load ptr, ptr %101, align 8, !tbaa !5
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds i8, ptr %103, i64 0
  %105 = load i8, ptr %104, align 1, !tbaa !18
  %106 = sext i8 %105 to i32
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i32, ptr %102, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !20
  store i32 %109, ptr %9, align 4, !tbaa !20
  %110 = load i32, ptr %9, align 4, !tbaa !20
  store i32 %110, ptr %10, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %111 = load i32, ptr %10, align 4, !tbaa !20
  %112 = trunc i32 %111 to i8
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %113, i64 0
  store i8 %112, ptr %114, align 1, !tbaa !18
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = getelementptr inbounds i8, ptr %115, i64 1
  %117 = call ptr @str_low(ptr noundef %116)
  br label %118

118:                                              ; preds = %100, %97, %94, %76, %76
  %119 = load ptr, ptr %3, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.DBF, ptr %119, i32 0, i32 13
  %121 = load i32, ptr %120, align 8, !tbaa !16
  %122 = icmp eq i32 %121, 0
  br i1 %122, label %123, label %206

123:                                              ; preds = %118
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.DBF, ptr %124, i32 0, i32 3
  %126 = load ptr, ptr %125, align 8, !tbaa !17
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.FIELD_RECORD, ptr %127, i32 0, i32 0
  %129 = getelementptr inbounds [11 x i8], ptr %128, i64 0, i64 0
  %130 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %126, ptr noundef @.str.2, i32 noundef 11, ptr noundef %129) #7
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.FIELD_RECORD, ptr %131, i32 0, i32 1
  %133 = load i8, ptr %132, align 1, !tbaa !22
  %134 = zext i8 %133 to i32
  switch i32 %134, label %191 [
    i32 68, label %135
    i32 78, label %140
    i32 70, label %160
    i32 76, label %173
    i32 67, label %178
    i32 77, label %187
  ]

135:                                              ; preds = %123
  %136 = load ptr, ptr %3, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.DBF, ptr %136, i32 0, i32 3
  %138 = load ptr, ptr %137, align 8, !tbaa !17
  %139 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %138, ptr noundef @.str.3) #7
  br label %192

140:                                              ; preds = %123
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.DBF, ptr %141, i32 0, i32 3
  %143 = load ptr, ptr %142, align 8, !tbaa !17
  %144 = load ptr, ptr %5, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.FIELD_RECORD, ptr %144, i32 0, i32 4
  %146 = load i8, ptr %145, align 1, !tbaa !24
  %147 = zext i8 %146 to i32
  %148 = icmp eq i32 %147, 0
  %149 = zext i1 %148 to i64
  %150 = select i1 %148, ptr @.str.4, ptr @.str.5
  %151 = load ptr, ptr %5, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.FIELD_RECORD, ptr %151, i32 0, i32 3
  %153 = load i8, ptr %152, align 4, !tbaa !25
  %154 = zext i8 %153 to i32
  %155 = load ptr, ptr %5, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.FIELD_RECORD, ptr %155, i32 0, i32 4
  %157 = load i8, ptr %156, align 1, !tbaa !24
  %158 = zext i8 %157 to i32
  %159 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef %150, i32 noundef %154, i32 noundef %158) #7
  br label %192

160:                                              ; preds = %123
  %161 = load ptr, ptr %3, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.DBF, ptr %161, i32 0, i32 3
  %163 = load ptr, ptr %162, align 8, !tbaa !17
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.FIELD_RECORD, ptr %164, i32 0, i32 3
  %166 = load i8, ptr %165, align 4, !tbaa !25
  %167 = zext i8 %166 to i32
  %168 = load ptr, ptr %5, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.FIELD_RECORD, ptr %168, i32 0, i32 4
  %170 = load i8, ptr %169, align 1, !tbaa !24
  %171 = zext i8 %170 to i32
  %172 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %163, ptr noundef @.str.5, i32 noundef %167, i32 noundef %171) #7
  br label %192

173:                                              ; preds = %123
  %174 = load ptr, ptr %3, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.DBF, ptr %174, i32 0, i32 3
  %176 = load ptr, ptr %175, align 8, !tbaa !17
  %177 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %176, ptr noundef @.str.4) #7
  br label %192

178:                                              ; preds = %123
  %179 = load ptr, ptr %3, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.DBF, ptr %179, i32 0, i32 3
  %181 = load ptr, ptr %180, align 8, !tbaa !17
  %182 = load ptr, ptr %5, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.FIELD_RECORD, ptr %182, i32 0, i32 3
  %184 = load i8, ptr %183, align 4, !tbaa !25
  %185 = zext i8 %184 to i32
  %186 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %181, ptr noundef @.str.6, i32 noundef %185) #7
  br label %192

187:                                              ; preds = %123
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.FIELD_RECORD, ptr %188, i32 0, i32 0
  %190 = getelementptr inbounds [11 x i8], ptr %189, i64 0, i64 0
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.7, ptr noundef %190)
  br label %192

191:                                              ; preds = %123
  call void (i32, ptr, ...) @lib_fatl(i32 noundef 12, ptr noundef @.str.8)
  br label %192

192:                                              ; preds = %191, %187, %178, %173, %160, %140, %135
  %193 = load ptr, ptr %3, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.DBF, ptr %193, i32 0, i32 3
  %195 = load ptr, ptr %194, align 8, !tbaa !17
  %196 = load i8, ptr %4, align 1, !tbaa !18
  %197 = zext i8 %196 to i32
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.DBF, ptr %198, i32 0, i32 15
  %200 = load i8, ptr %199, align 8, !tbaa !14
  %201 = zext i8 %200 to i32
  %202 = icmp eq i32 %197, %201
  %203 = zext i1 %202 to i64
  %204 = select i1 %202, ptr @.str.10, ptr @.str.11
  %205 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %195, ptr noundef @.str.9, ptr noundef %204) #7
  br label %206

206:                                              ; preds = %192, %118
  br label %207

207:                                              ; preds = %206
  %208 = load i8, ptr %4, align 1, !tbaa !18
  %209 = add i8 %208, 1
  store i8 %209, ptr %4, align 1, !tbaa !18
  br label %68, !llvm.loop !26

210:                                              ; preds = %68
  %211 = load ptr, ptr %3, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.DBF, ptr %211, i32 0, i32 13
  %213 = load i32, ptr %212, align 8, !tbaa !16
  %214 = icmp eq i32 %213, 0
  br i1 %214, label %215, label %220

215:                                              ; preds = %210
  %216 = load ptr, ptr %3, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.DBF, ptr %216, i32 0, i32 3
  %218 = load ptr, ptr %217, align 8, !tbaa !17
  %219 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %218, ptr noundef @.str.12) #7
  br label %220

220:                                              ; preds = %215, %210
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %221

221:                                              ; preds = %220, %30, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #7
  %222 = load i32, ptr %2, align 4
  ret i32 %222
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; 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) #4

declare ptr @str_upr(ptr noundef) #5

declare ptr @str_low(ptr noundef) #5

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() #6

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

declare void @lib_mesg(ptr noundef, ...) #5

declare void @lib_fatl(i32 noundef, ptr noundef, ...) #5

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 = { nounwind 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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 #6 = { nounwind willreturn memory(none) "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind willreturn memory(none) }

!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 2096}
!10 = !{!"DBF", !7, i64 0, !7, i64 1024, !6, i64 2048, !6, i64 2056, !11, i64 2064, !11, i64 2068, !7, i64 2072, !7, i64 2073, !7, i64 2074, !7, i64 2075, !7, i64 2076, !7, i64 2077, !7, i64 2078, !11, i64 2080, !11, i64 2084, !7, i64 2088, !6, i64 2096, !6, i64 2104, !12, i64 2112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"DBFPROLOG", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !11, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 28, !7, i64 29}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !7, i64 2088}
!15 = !{!10, !6, i64 2104}
!16 = !{!10, !11, i64 2080}
!17 = !{!10, !6, i64 2056}
!18 = !{!7, !7, i64 0}
!19 = !{i64 0, i64 11, !18, i64 11, i64 1, !18, i64 12, i64 4, !20, i64 16, i64 1, !18, i64 17, i64 1, !18, i64 18, i64 14, !18}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 2084}
!22 = !{!23, !7, i64 11}
!23 = !{!"FIELD_RECORD", !7, i64 0, !7, i64 11, !11, i64 12, !7, i64 16, !7, i64 17, !7, i64 18}
!24 = !{!23, !7, i64 17}
!25 = !{!23, !7, i64 16}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


; 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.FIELD_RECORD = type { [11 x i8], i8, i32, i8, i8, [14 x i8] }

@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 9) i32 @sql_crep(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 2096
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 2088
  %5 = load i8, ptr %4, align 8, !tbaa !13
  %6 = zext i8 %5 to i64
  %7 = shl nuw nsw i64 %6, 5
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #6
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %108, label %10

10:                                               ; preds = %1
  %11 = tail call noalias dereferenceable_or_null(4001) ptr @malloc(i64 noundef 4001) #6
  %12 = getelementptr inbounds i8, ptr %0, i64 2104
  store ptr %11, ptr %12, align 8, !tbaa !14
  %13 = icmp eq ptr %11, null
  br i1 %13, label %108, label %14

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 2080
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %26

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %0, i64 2056
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %0, i64 1024
  %22 = load i8, ptr %21, align 8, !tbaa !17
  %23 = icmp eq i8 %22, 0
  %24 = select i1 %23, ptr @.str.1, ptr %21
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str, ptr noundef nonnull %24, ptr noundef nonnull %24) #7
  %.pre = load i8, ptr %4, align 8, !tbaa !13
  br label %26

26:                                               ; preds = %18, %14
  %27 = phi i8 [ %.pre, %18 ], [ %5, %14 ]
  %.not50 = icmp eq i8 %27, 0
  br i1 %.not50, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %26
  %28 = getelementptr inbounds i8, ptr %0, i64 2084
  %29 = getelementptr inbounds i8, ptr %0, i64 2056
  br label %30

30:                                               ; preds = %.lr.ph, %99
  %.04752 = phi i8 [ 1, %.lr.ph ], [ %100, %99 ]
  %.04851 = phi ptr [ %3, %.lr.ph ], [ %35, %99 ]
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = zext i8 %.04752 to i64
  %33 = getelementptr %struct.FIELD_RECORD, ptr %31, i64 %32
  %34 = getelementptr i8, ptr %33, i64 -32
  %35 = getelementptr inbounds i8, ptr %.04851, i64 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(32) %34, ptr noundef nonnull align 4 dereferenceable(32) %.04851, i64 32, i1 false), !tbaa.struct !18
  %36 = load i32, ptr %28, align 4, !tbaa !20
  switch i32 %36, label %51 [
    i32 1, label %37
    i32 2, label %39
    i32 3, label %41
  ]

37:                                               ; preds = %30
  %38 = tail call ptr @str_upr(ptr noundef %34) #7
  br label %51

39:                                               ; preds = %30
  %40 = tail call ptr @str_low(ptr noundef %34) #7
  br label %51

41:                                               ; preds = %30
  %42 = tail call ptr @__ctype_toupper_loc() #8
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = load i8, ptr %34, align 1, !tbaa !17
  %45 = sext i8 %44 to i64
  %46 = getelementptr inbounds i32, ptr %43, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = trunc i32 %47 to i8
  store i8 %48, ptr %34, align 1, !tbaa !17
  %49 = getelementptr i8, ptr %33, i64 -31
  %50 = tail call ptr @str_low(ptr noundef %49) #7
  br label %51

51:                                               ; preds = %41, %39, %37, %30
  %52 = load i32, ptr %15, align 8, !tbaa !15
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %99

54:                                               ; preds = %51
  %55 = load ptr, ptr %29, align 8, !tbaa !16
  %56 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef nonnull @.str.2, i32 noundef 11, ptr noundef %34) #7
  %57 = getelementptr i8, ptr %33, i64 -21
  %58 = load i8, ptr %57, align 1, !tbaa !22
  switch i8 %58, label %92 [
    i8 68, label %59
    i8 78, label %62
    i8 70, label %73
    i8 76, label %82
    i8 67, label %85
    i8 77, label %91
  ]

59:                                               ; preds = %54
  %60 = load ptr, ptr %29, align 8, !tbaa !16
  %61 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef nonnull @.str.3) #7
  br label %93

62:                                               ; preds = %54
  %63 = load ptr, ptr %29, align 8, !tbaa !16
  %64 = getelementptr i8, ptr %33, i64 -15
  %65 = load i8, ptr %64, align 1, !tbaa !24
  %66 = zext i8 %65 to i32
  %67 = icmp eq i8 %65, 0
  %68 = select i1 %67, ptr @.str.4, ptr @.str.5
  %69 = getelementptr i8, ptr %33, i64 -16
  %70 = load i8, ptr %69, align 4, !tbaa !25
  %71 = zext i8 %70 to i32
  %72 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull %68, i32 noundef %71, i32 noundef %66) #7
  br label %93

73:                                               ; preds = %54
  %74 = load ptr, ptr %29, align 8, !tbaa !16
  %75 = getelementptr i8, ptr %33, i64 -16
  %76 = load i8, ptr %75, align 4, !tbaa !25
  %77 = zext i8 %76 to i32
  %78 = getelementptr i8, ptr %33, i64 -15
  %79 = load i8, ptr %78, align 1, !tbaa !24
  %80 = zext i8 %79 to i32
  %81 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef nonnull @.str.5, i32 noundef %77, i32 noundef %80) #7
  br label %93

82:                                               ; preds = %54
  %83 = load ptr, ptr %29, align 8, !tbaa !16
  %84 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef nonnull @.str.4) #7
  br label %93

85:                                               ; preds = %54
  %86 = load ptr, ptr %29, align 8, !tbaa !16
  %87 = getelementptr i8, ptr %33, i64 -16
  %88 = load i8, ptr %87, align 4, !tbaa !25
  %89 = zext i8 %88 to i32
  %90 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef nonnull @.str.6, i32 noundef %89) #7
  br label %93

91:                                               ; preds = %54
  tail call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.7, ptr noundef %34) #7
  br label %93

92:                                               ; preds = %54
  tail call void (i32, ptr, ...) @lib_fatl(i32 noundef 12, ptr noundef nonnull @.str.8) #7
  br label %93

93:                                               ; preds = %92, %91, %85, %82, %73, %62, %59
  %94 = load ptr, ptr %29, align 8, !tbaa !16
  %95 = load i8, ptr %4, align 8, !tbaa !13
  %96 = icmp eq i8 %.04752, %95
  %97 = select i1 %96, ptr @.str.10, ptr @.str.11
  %98 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef nonnull @.str.9, ptr noundef nonnull %97) #7
  br label %99

99:                                               ; preds = %51, %93
  %100 = add i8 %.04752, 1
  %101 = load i8, ptr %4, align 8, !tbaa !13
  %.not = icmp ugt i8 %100, %101
  br i1 %.not, label %._crit_edge, label %30, !llvm.loop !26

._crit_edge:                                      ; preds = %99, %26
  %102 = load i32, ptr %15, align 8, !tbaa !15
  %103 = icmp eq i32 %102, 0
  br i1 %103, label %104, label %108

104:                                              ; preds = %._crit_edge
  %105 = getelementptr inbounds i8, ptr %0, i64 2056
  %106 = load ptr, ptr %105, align 8, !tbaa !16
  %107 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %106, ptr noundef nonnull @.str.12) #7
  br label %108

108:                                              ; preds = %._crit_edge, %104, %10, %1
  %.0 = phi i32 [ 8, %1 ], [ 8, %10 ], [ 0, %104 ], [ 0, %._crit_edge ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress 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) #3

declare ptr @str_upr(ptr noundef) local_unnamed_addr #4

declare ptr @str_low(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() local_unnamed_addr #5

declare void @lib_mesg(ptr noundef, ...) local_unnamed_addr #4

declare void @lib_fatl(i32 noundef, ptr noundef, ...) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }

!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, !9, i64 2096}
!6 = !{!"DBF", !7, i64 0, !7, i64 1024, !9, i64 2048, !9, i64 2056, !10, i64 2064, !10, i64 2068, !7, i64 2072, !7, i64 2073, !7, i64 2074, !7, i64 2075, !7, i64 2076, !7, i64 2077, !7, i64 2078, !10, i64 2080, !10, i64 2084, !7, i64 2088, !9, i64 2096, !9, i64 2104, !11, i64 2112}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"DBFPROLOG", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !10, i64 4, !12, i64 8, !12, i64 10, !12, i64 12, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 28, !7, i64 29}
!12 = !{!"short", !7, i64 0}
!13 = !{!6, !7, i64 2088}
!14 = !{!6, !9, i64 2104}
!15 = !{!6, !10, i64 2080}
!16 = !{!6, !9, i64 2056}
!17 = !{!7, !7, i64 0}
!18 = !{i64 0, i64 11, !17, i64 11, i64 1, !17, i64 12, i64 4, !19, i64 16, i64 1, !17, i64 17, i64 1, !17, i64 18, i64 14, !17}
!19 = !{!10, !10, i64 0}
!20 = !{!6, !10, i64 2084}
!21 = !{!9, !9, i64 0}
!22 = !{!23, !7, i64 11}
!23 = !{!"FIELD_RECORD", !7, i64 0, !7, i64 11, !10, i64 12, !7, i64 16, !7, i64 17, !7, i64 18}
!24 = !{!23, !7, i64 17}
!25 = !{!23, !7, i64 16}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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