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

; 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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @rdb_2dbf(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.DBF, ptr %15, i32 0, i32 17
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DBF, ptr %18, i32 0, i32 12
  %20 = load i8, ptr %19, align 2, !tbaa !14
  %21 = sext i8 %20 to i32
  %22 = icmp ne i32 %21, 0
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, i32 0, i32 32
  %25 = trunc i32 %24 to i8
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.DBF, ptr %26, i32 0, i32 18
  %28 = getelementptr inbounds %struct.DBFPROLOG, ptr %27, i32 0, i32 6
  %29 = load i16, ptr %28, align 2, !tbaa !15
  %30 = zext i16 %29 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %17, i8 %25, i64 %30, i1 false)
  store i8 0, ptr %5, align 1, !tbaa !16
  br label %31

31:                                               ; preds = %268, %2
  %32 = load i8, ptr %5, align 1, !tbaa !16
  %33 = zext i8 %32 to i32
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.DBF, ptr %34, i32 0, i32 15
  %36 = load i8, ptr %35, align 8, !tbaa !17
  %37 = zext i8 %36 to i32
  %38 = icmp slt i32 %33, %37
  br i1 %38, label %39, label %271

39:                                               ; preds = %31
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.DBF, ptr %40, i32 0, i32 16
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = load i8, ptr %5, align 1, !tbaa !16
  %44 = zext i8 %43 to i64
  %45 = getelementptr inbounds %struct.FIELD_RECORD, ptr %42, i64 %44
  store ptr %45, ptr %8, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.DBF, ptr %46, i32 0, i32 16
  %48 = load ptr, ptr %47, align 8, !tbaa !18
  %49 = load i8, ptr %5, align 1, !tbaa !16
  %50 = zext i8 %49 to i64
  %51 = getelementptr inbounds %struct.FIELD_RECORD, ptr %48, i64 %50
  store ptr %51, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.DBF, ptr %52, i32 0, i32 17
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.FIELD_RECORD, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !19
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %54, i64 %58
  store ptr %59, ptr %9, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.DBF, ptr %60, i32 0, i32 17
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.FIELD_RECORD, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !19
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %62, i64 %66
  store ptr %67, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = icmp eq ptr %68, null
  br i1 %69, label %70, label %74

70:                                               ; preds = %39
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.DBF, ptr %71, i32 0, i32 4
  %73 = load i32, ptr %72, align 8, !tbaa !21
  call void (ptr, ...) @lib_mesg(ptr noundef @.str, i32 noundef %73)
  br label %271

74:                                               ; preds = %39
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = call i64 @strlen(ptr noundef %75) #7
  %77 = trunc i64 %76 to i8
  store i8 %77, ptr %6, align 1, !tbaa !16
  %78 = load i8, ptr %6, align 1, !tbaa !16
  %79 = zext i8 %78 to i32
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %267

81:                                               ; preds = %74
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.FIELD_RECORD, ptr %82, i32 0, i32 1
  %84 = load i8, ptr %83, align 1, !tbaa !22
  %85 = zext i8 %84 to i32
  switch i32 %85, label %258 [
    i32 76, label %86
    i32 68, label %110
    i32 78, label %158
    i32 70, label %158
    i32 67, label %233
    i32 88, label %266
  ]

86:                                               ; preds = %81
  %87 = load i8, ptr %6, align 1, !tbaa !16
  %88 = zext i8 %87 to i32
  %89 = icmp eq i32 %88, 1
  br i1 %89, label %90, label %100

90:                                               ; preds = %86
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = load i8, ptr %91, align 1, !tbaa !16
  %93 = sext i8 %92 to i32
  %94 = call ptr @strchr(ptr noundef @.str.1, i32 noundef %93) #7
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %100

96:                                               ; preds = %90
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = load i8, ptr %97, align 1, !tbaa !16
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 %98, ptr %99, align 1, !tbaa !16
  br label %109

100:                                              ; preds = %90, %86
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.FIELD_RECORD, ptr %101, i32 0, i32 0
  %103 = getelementptr inbounds [11 x i8], ptr %102, i64 0, i64 0
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.DBF, ptr %104, i32 0, i32 4
  %106 = load i32, ptr %105, align 8, !tbaa !21
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.2, ptr noundef %103, i32 noundef %106, ptr noundef %107)
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 70, ptr %108, align 1, !tbaa !16
  br label %109

109:                                              ; preds = %100, %96
  br label %266

110:                                              ; preds = %81
  %111 = load i8, ptr %6, align 1, !tbaa !16
  %112 = zext i8 %111 to i32
  %113 = icmp eq i32 %112, 6
  br i1 %113, label %114, label %125

114:                                              ; preds = %110
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %115, ptr noundef @.str.3, ptr noundef %12, ptr noundef %13, ptr noundef %14) #6
  %117 = icmp eq i32 %116, 3
  br i1 %117, label %118, label %125

118:                                              ; preds = %114
  %119 = load ptr, ptr %9, align 8, !tbaa !5
  %120 = call ptr @strcpy(ptr noundef %119, ptr noundef @.str.4) #6
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = getelementptr inbounds i8, ptr %121, i64 2
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = call ptr @strncpy(ptr noundef %122, ptr noundef %123, i64 noundef 6) #6
  br label %157

125:                                              ; preds = %114, %110
  %126 = load i8, ptr %6, align 1, !tbaa !16
  %127 = zext i8 %126 to i32
  %128 = icmp eq i32 %127, 8
  br i1 %128, label %129, label %141

129:                                              ; preds = %125
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  %131 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %130, ptr noundef @.str.5, ptr noundef %12, ptr noundef %13, ptr noundef %14) #6
  %132 = icmp eq i32 %131, 3
  br i1 %132, label %133, label %141

133:                                              ; preds = %129
  %134 = load ptr, ptr %9, align 8, !tbaa !5
  %135 = load ptr, ptr %10, align 8, !tbaa !5
  %136 = load ptr, ptr %8, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.FIELD_RECORD, ptr %136, i32 0, i32 3
  %138 = load i8, ptr %137, align 4, !tbaa !23
  %139 = zext i8 %138 to i64
  %140 = call ptr @strncpy(ptr noundef %134, ptr noundef %135, i64 noundef %139) #6
  br label %156

141:                                              ; preds = %129, %125
  %142 = load ptr, ptr %7, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.FIELD_RECORD, ptr %142, i32 0, i32 0
  %144 = getelementptr inbounds [11 x i8], ptr %143, i64 0, i64 0
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.DBF, ptr %145, i32 0, i32 4
  %147 = load i32, ptr %146, align 8, !tbaa !21
  %148 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.6, ptr noundef %144, i32 noundef %147, ptr noundef %148)
  %149 = load ptr, ptr %9, align 8, !tbaa !5
  %150 = load ptr, ptr %10, align 8, !tbaa !5
  %151 = load ptr, ptr %8, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.FIELD_RECORD, ptr %151, i32 0, i32 3
  %153 = load i8, ptr %152, align 4, !tbaa !23
  %154 = zext i8 %153 to i64
  %155 = call ptr @strncpy(ptr noundef %149, ptr noundef %150, i64 noundef %154) #6
  br label %156

156:                                              ; preds = %141, %133
  br label %157

157:                                              ; preds = %156, %118
  br label %266

158:                                              ; preds = %81, %81
  %159 = load ptr, ptr %10, align 8, !tbaa !5
  %160 = call double @str_chkd(ptr noundef %159)
  store double %160, ptr %11, align 8, !tbaa !24
  %161 = fcmp une double %160, 0x7FF0000000000000
  br i1 %161, label %162, label %217

162:                                              ; preds = %158
  %163 = load ptr, ptr %9, align 8, !tbaa !5
  %164 = load ptr, ptr %8, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.FIELD_RECORD, ptr %164, i32 0, i32 3
  %166 = load i8, ptr %165, align 4, !tbaa !23
  %167 = zext i8 %166 to i32
  %168 = load ptr, ptr %8, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.FIELD_RECORD, ptr %168, i32 0, i32 4
  %170 = load i8, ptr %169, align 1, !tbaa !26
  %171 = zext i8 %170 to i32
  %172 = load double, ptr %11, align 8, !tbaa !24
  %173 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %163, ptr noundef @.str.7, i32 noundef %167, i32 noundef %171, double noundef %172) #6
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = load ptr, ptr %8, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.FIELD_RECORD, ptr %175, i32 0, i32 3
  %177 = load i8, ptr %176, align 4, !tbaa !23
  %178 = zext i8 %177 to i64
  %179 = getelementptr inbounds i8, ptr %174, i64 %178
  %180 = load i8, ptr %179, align 1, !tbaa !16
  %181 = sext i8 %180 to i32
  %182 = icmp ne i32 %181, 0
  br i1 %182, label %206, label %183

183:                                              ; preds = %162
  %184 = load ptr, ptr %8, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.FIELD_RECORD, ptr %184, i32 0, i32 4
  %186 = load i8, ptr %185, align 1, !tbaa !26
  %187 = zext i8 %186 to i32
  %188 = icmp sgt i32 %187, 0
  br i1 %188, label %189, label %216

189:                                              ; preds = %183
  %190 = load ptr, ptr %9, align 8, !tbaa !5
  %191 = load ptr, ptr %8, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.FIELD_RECORD, ptr %191, i32 0, i32 3
  %193 = load i8, ptr %192, align 4, !tbaa !23
  %194 = zext i8 %193 to i32
  %195 = load ptr, ptr %8, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.FIELD_RECORD, ptr %195, i32 0, i32 4
  %197 = load i8, ptr %196, align 1, !tbaa !26
  %198 = zext i8 %197 to i32
  %199 = sub nsw i32 %194, %198
  %200 = sub nsw i32 %199, 1
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds i8, ptr %190, i64 %201
  %203 = load i8, ptr %202, align 1, !tbaa !16
  %204 = sext i8 %203 to i32
  %205 = icmp ne i32 %204, 46
  br i1 %205, label %206, label %216

206:                                              ; preds = %189, %162
  %207 = load ptr, ptr %7, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.FIELD_RECORD, ptr %207, i32 0, i32 0
  %209 = getelementptr inbounds [11 x i8], ptr %208, i64 0, i64 0
  %210 = load ptr, ptr %4, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.DBF, ptr %210, i32 0, i32 4
  %212 = load i32, ptr %211, align 8, !tbaa !21
  %213 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.8, ptr noundef %209, i32 noundef %212, ptr noundef %213)
  %214 = load ptr, ptr %9, align 8, !tbaa !5
  %215 = call ptr @strcpy(ptr noundef %214, ptr noundef @.str.9) #6
  br label %216

216:                                              ; preds = %206, %189, %183
  br label %232

217:                                              ; preds = %158
  %218 = load ptr, ptr %7, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.FIELD_RECORD, ptr %218, i32 0, i32 0
  %220 = getelementptr inbounds [11 x i8], ptr %219, i64 0, i64 0
  %221 = load ptr, ptr %4, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.DBF, ptr %221, i32 0, i32 4
  %223 = load i32, ptr %222, align 8, !tbaa !21
  %224 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.10, ptr noundef %220, i32 noundef %223, ptr noundef %224)
  %225 = load ptr, ptr %9, align 8, !tbaa !5
  %226 = load ptr, ptr %10, align 8, !tbaa !5
  %227 = load ptr, ptr %8, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.FIELD_RECORD, ptr %227, i32 0, i32 3
  %229 = load i8, ptr %228, align 4, !tbaa !23
  %230 = zext i8 %229 to i64
  %231 = call ptr @strncpy(ptr noundef %225, ptr noundef %226, i64 noundef %230) #6
  br label %232

232:                                              ; preds = %217, %216
  br label %266

233:                                              ; preds = %81
  %234 = load i8, ptr %6, align 1, !tbaa !16
  %235 = zext i8 %234 to i32
  %236 = load ptr, ptr %8, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.FIELD_RECORD, ptr %236, i32 0, i32 3
  %238 = load i8, ptr %237, align 4, !tbaa !23
  %239 = zext i8 %238 to i32
  %240 = icmp sgt i32 %235, %239
  br i1 %240, label %241, label %249

241:                                              ; preds = %233
  %242 = load ptr, ptr %7, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.FIELD_RECORD, ptr %242, i32 0, i32 0
  %244 = getelementptr inbounds [11 x i8], ptr %243, i64 0, i64 0
  %245 = load ptr, ptr %4, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.DBF, ptr %245, i32 0, i32 4
  %247 = load i32, ptr %246, align 8, !tbaa !21
  %248 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.11, ptr noundef %244, i32 noundef %247, ptr noundef %248)
  br label %249

249:                                              ; preds = %241, %233
  %250 = load ptr, ptr %10, align 8, !tbaa !5
  call void @iso885915_to_oem858(ptr noundef %250)
  %251 = load ptr, ptr %9, align 8, !tbaa !5
  %252 = load ptr, ptr %8, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.FIELD_RECORD, ptr %252, i32 0, i32 3
  %254 = load i8, ptr %253, align 4, !tbaa !23
  %255 = zext i8 %254 to i32
  %256 = load ptr, ptr %10, align 8, !tbaa !5
  %257 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %251, ptr noundef @.str.12, i32 noundef %255, ptr noundef %256) #6
  br label %266

258:                                              ; preds = %81
  %259 = load ptr, ptr %7, align 8, !tbaa !5
  %260 = getelementptr inbounds %struct.FIELD_RECORD, ptr %259, i32 0, i32 0
  %261 = getelementptr inbounds [11 x i8], ptr %260, i64 0, i64 0
  %262 = load ptr, ptr %4, align 8, !tbaa !5
  %263 = getelementptr inbounds %struct.DBF, ptr %262, i32 0, i32 4
  %264 = load i32, ptr %263, align 8, !tbaa !21
  %265 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str.13, ptr noundef %261, i32 noundef %264, ptr noundef %265)
  br label %266

266:                                              ; preds = %258, %249, %232, %157, %109, %81
  br label %267

267:                                              ; preds = %266, %74
  br label %268

268:                                              ; preds = %267
  %269 = load i8, ptr %5, align 1, !tbaa !16
  %270 = add i8 %269, 1
  store i8 %270, ptr %5, align 1, !tbaa !16
  br label %31, !llvm.loop !27

271:                                              ; preds = %70, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #6
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #4

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(ptr noundef, ptr noundef, ...) #5

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #5

declare double @str_chkd(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #5

declare void @iso885915_to_oem858(ptr noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 willreturn memory(read) "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 "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 }
attributes #7 = { nounwind willreturn memory(read) }

!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 2104}
!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 2078}
!15 = !{!10, !13, i64 2122}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !7, i64 2088}
!18 = !{!10, !6, i64 2096}
!19 = !{!20, !11, i64 12}
!20 = !{!"FIELD_RECORD", !7, i64 0, !7, i64 11, !11, i64 12, !7, i64 16, !7, i64 17, !7, i64 18}
!21 = !{!10, !11, i64 2064}
!22 = !{!20, !7, i64 11}
!23 = !{!20, !7, i64 16}
!24 = !{!25, !25, i64 0}
!25 = !{!"double", !7, i64 0}
!26 = !{!20, !7, i64 17}
!27 = distinct !{!27, !28}
!28 = !{!"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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @rdb_2dbf(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 2104
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 2078
  %9 = load i8, ptr %8, align 2, !tbaa !13
  %.not = icmp eq i8 %9, 0
  %10 = select i1 %.not, i8 32, i8 0
  %11 = getelementptr inbounds i8, ptr %0, i64 2122
  %12 = load i16, ptr %11, align 2, !tbaa !14
  %13 = zext i16 %12 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %7, i8 %10, i64 %13, i1 false)
  %14 = getelementptr inbounds i8, ptr %1, i64 2088
  %15 = load i8, ptr %14, align 8, !tbaa !15
  %.not85 = icmp eq i8 %15, 0
  br i1 %.not85, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %16 = getelementptr inbounds i8, ptr %0, i64 2096
  %17 = getelementptr inbounds i8, ptr %1, i64 2096
  %18 = getelementptr inbounds i8, ptr %1, i64 2104
  %19 = getelementptr inbounds i8, ptr %1, i64 2064
  br label %20

20:                                               ; preds = %.lr.ph, %121
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %121 ]
  %21 = load ptr, ptr %16, align 8, !tbaa !16
  %22 = getelementptr inbounds %struct.FIELD_RECORD, ptr %21, i64 %indvars.iv
  %23 = load ptr, ptr %17, align 8, !tbaa !16
  %24 = getelementptr inbounds %struct.FIELD_RECORD, ptr %23, i64 %indvars.iv
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %22, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %25, i64 %28
  %30 = load ptr, ptr %18, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %24, i64 12
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %30, i64 %33
  %35 = icmp eq ptr %30, null
  br i1 %35, label %36, label %38

36:                                               ; preds = %20
  %37 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str, i32 noundef %37) #7
  br label %.loopexit

38:                                               ; preds = %20
  %39 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %34) #8
  %40 = trunc i64 %39 to i32
  %41 = and i32 %40, 255
  %.not79 = icmp eq i32 %41, 0
  br i1 %.not79, label %121, label %42

42:                                               ; preds = %38
  %43 = getelementptr inbounds i8, ptr %22, i64 11
  %44 = load i8, ptr %43, align 1, !tbaa !20
  switch i8 %44, label %119 [
    i8 76, label %45
    i8 68, label %54
    i8 78, label %76
    i8 70, label %76
    i8 67, label %108
    i8 88, label %121
  ]

45:                                               ; preds = %42
  %46 = icmp eq i32 %41, 1
  br i1 %46, label %47, label %52

47:                                               ; preds = %45
  %48 = load i8, ptr %34, align 1, !tbaa !21
  %49 = sext i8 %48 to i32
  %50 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %49) #8
  %.not83 = icmp eq ptr %50, null
  br i1 %.not83, label %52, label %51

51:                                               ; preds = %47
  store i8 %48, ptr %29, align 1, !tbaa !21
  br label %121

52:                                               ; preds = %47, %45
  %53 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.2, ptr noundef nonnull %24, i32 noundef %53, ptr noundef nonnull %34) #7
  store i8 70, ptr %29, align 1, !tbaa !21
  br label %121

54:                                               ; preds = %42
  %trunc = trunc i64 %39 to i8
  switch i8 %trunc, label %70 [
    i8 6, label %55
    i8 8, label %62
  ]

55:                                               ; preds = %54
  %56 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %34, ptr noundef nonnull @.str.3, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5) #7
  %57 = icmp eq i32 %56, 3
  br i1 %57, label %58, label %70

58:                                               ; preds = %55
  %59 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) @.str.4) #7
  %60 = getelementptr inbounds i8, ptr %29, i64 2
  %61 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %60, ptr noundef nonnull dereferenceable(1) %34, i64 noundef 6) #7
  br label %121

62:                                               ; preds = %54
  %63 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %34, ptr noundef nonnull @.str.5, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5) #7
  %64 = icmp eq i32 %63, 3
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = getelementptr inbounds i8, ptr %22, i64 16
  %67 = load i8, ptr %66, align 4, !tbaa !22
  %68 = zext i8 %67 to i64
  %69 = call ptr @strncpy(ptr noundef %29, ptr noundef nonnull %34, i64 noundef %68) #7
  br label %121

70:                                               ; preds = %55, %54, %62
  %71 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.6, ptr noundef nonnull %24, i32 noundef %71, ptr noundef nonnull %34) #7
  %72 = getelementptr inbounds i8, ptr %22, i64 16
  %73 = load i8, ptr %72, align 4, !tbaa !22
  %74 = zext i8 %73 to i64
  %75 = call ptr @strncpy(ptr noundef %29, ptr noundef nonnull %34, i64 noundef %74) #7
  br label %121

76:                                               ; preds = %42, %42
  %77 = call double @str_chkd(ptr noundef nonnull %34) #7
  %78 = fcmp une double %77, 0x7FF0000000000000
  br i1 %78, label %79, label %102

79:                                               ; preds = %76
  %80 = getelementptr inbounds i8, ptr %22, i64 16
  %81 = load i8, ptr %80, align 4, !tbaa !22
  %82 = zext i8 %81 to i32
  %83 = getelementptr inbounds i8, ptr %22, i64 17
  %84 = load i8, ptr %83, align 1, !tbaa !23
  %85 = zext i8 %84 to i32
  %86 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %82, i32 noundef %85, double noundef %77) #7
  %87 = load i8, ptr %80, align 4, !tbaa !22
  %88 = zext i8 %87 to i64
  %89 = getelementptr inbounds i8, ptr %29, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !21
  %.not80 = icmp eq i8 %90, 0
  br i1 %.not80, label %91, label %99

91:                                               ; preds = %79
  %92 = load i8, ptr %83, align 1, !tbaa !23
  %.not81 = icmp eq i8 %92, 0
  br i1 %.not81, label %121, label %93

93:                                               ; preds = %91
  %94 = zext i8 %92 to i64
  %95 = xor i64 %94, -1
  %96 = getelementptr i8, ptr %29, i64 %95
  %97 = getelementptr i8, ptr %96, i64 %88
  %98 = load i8, ptr %97, align 1, !tbaa !21
  %.not82 = icmp eq i8 %98, 46
  br i1 %.not82, label %121, label %99

99:                                               ; preds = %93, %79
  %100 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.8, ptr noundef nonnull %24, i32 noundef %100, ptr noundef nonnull %34) #7
  %101 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) @.str.9) #7
  br label %121

102:                                              ; preds = %76
  %103 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.10, ptr noundef nonnull %24, i32 noundef %103, ptr noundef nonnull %34) #7
  %104 = getelementptr inbounds i8, ptr %22, i64 16
  %105 = load i8, ptr %104, align 4, !tbaa !22
  %106 = zext i8 %105 to i64
  %107 = call ptr @strncpy(ptr noundef %29, ptr noundef nonnull %34, i64 noundef %106) #7
  br label %121

108:                                              ; preds = %42
  %109 = getelementptr inbounds i8, ptr %22, i64 16
  %110 = load i8, ptr %109, align 4, !tbaa !22
  %111 = zext i8 %110 to i32
  %112 = icmp ugt i32 %41, %111
  br i1 %112, label %113, label %115

113:                                              ; preds = %108
  %114 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.11, ptr noundef nonnull %24, i32 noundef %114, ptr noundef nonnull %34) #7
  br label %115

115:                                              ; preds = %113, %108
  call void @iso885915_to_oem858(ptr noundef nonnull %34) #7
  %116 = load i8, ptr %109, align 4, !tbaa !22
  %117 = zext i8 %116 to i32
  %118 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %117, ptr noundef nonnull %34) #7
  br label %121

119:                                              ; preds = %42
  %120 = load i32, ptr %19, align 8, !tbaa !19
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str.13, ptr noundef nonnull %24, i32 noundef %120, ptr noundef nonnull %34) #7
  br label %121

121:                                              ; preds = %38, %102, %99, %93, %91, %58, %70, %65, %51, %52, %119, %115, %42
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %122 = load i8, ptr %14, align 8, !tbaa !15
  %123 = zext i8 %122 to i64
  %124 = icmp ult i64 %indvars.iv.next, %123
  br i1 %124, label %20, label %.loopexit, !llvm.loop !24

.loopexit:                                        ; preds = %121, %2, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  ret i32 0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #6

declare double @str_chkd(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

declare void @iso885915_to_oem858(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { 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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 willreturn memory(read) }

!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 2104}
!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 2078}
!14 = !{!6, !12, i64 2122}
!15 = !{!6, !7, i64 2088}
!16 = !{!6, !9, i64 2096}
!17 = !{!18, !10, i64 12}
!18 = !{!"FIELD_RECORD", !7, i64 0, !7, i64 11, !10, i64 12, !7, i64 16, !7, i64 17, !7, i64 18}
!19 = !{!6, !10, i64 2064}
!20 = !{!18, !7, i64 11}
!21 = !{!7, !7, i64 0}
!22 = !{!18, !7, i64 16}
!23 = !{!18, !7, i64 17}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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