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

; 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] }

@__const.dbf_2rdb.adsillegals = external hidden unnamed_addr constant [74 x i8], align 16
@.str = external hidden unnamed_addr constant [71 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @dbf_2rdb(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca [257 x i8], align 16
  %13 = alloca i32, align 4
  %14 = alloca [74 x i8], align 16
  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 8, 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 257, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 74, ptr %14) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %14, ptr align 16 @__const.dbf_2rdb.adsillegals, i64 74, i1 false)
  store i32 0, ptr %13, align 4, !tbaa !9
  %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 !11
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DBF, ptr %18, i32 0, i32 17
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = load i8, ptr %20, align 1, !tbaa !15
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i32 1
  store ptr %23, ptr %8, align 8, !tbaa !5
  store i8 %21, ptr %22, align 1, !tbaa !15
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i32 1
  store ptr %25, ptr %8, align 8, !tbaa !5
  store i8 0, ptr %24, align 1, !tbaa !15
  store i8 0, ptr %5, align 1, !tbaa !15
  br label %26

26:                                               ; preds = %157, %2
  %27 = load i8, ptr %5, align 1, !tbaa !15
  %28 = zext i8 %27 to i32
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.DBF, ptr %29, i32 0, i32 15
  %31 = load i8, ptr %30, align 8, !tbaa !16
  %32 = zext i8 %31 to i32
  %33 = icmp slt i32 %28, %32
  br i1 %33, label %34, label %160

34:                                               ; preds = %26
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.DBF, ptr %35, i32 0, i32 16
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load i8, ptr %5, align 1, !tbaa !15
  %39 = zext i8 %38 to i64
  %40 = getelementptr inbounds %struct.FIELD_RECORD, ptr %37, i64 %39
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.DBF, ptr %41, i32 0, i32 16
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = load i8, ptr %5, align 1, !tbaa !15
  %45 = zext i8 %44 to i64
  %46 = getelementptr inbounds %struct.FIELD_RECORD, ptr %43, i64 %45
  store ptr %46, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.DBF, ptr %47, i32 0, i32 17
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.FIELD_RECORD, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !18
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %49, i64 %53
  store ptr %54, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.DBF, ptr %55, i32 0, i32 4
  %57 = load i32, ptr %56, align 8, !tbaa !20
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.DBF, ptr %58, i32 0, i32 4
  store i32 %57, ptr %59, align 8, !tbaa !20
  %60 = getelementptr inbounds [257 x i8], ptr %12, i64 0, i64 0
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.FIELD_RECORD, ptr %62, i32 0, i32 3
  %64 = load i8, ptr %63, align 4, !tbaa !21
  %65 = zext i8 %64 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %60, ptr align 1 %61, i64 %65, i1 false)
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.FIELD_RECORD, ptr %66, i32 0, i32 3
  %68 = load i8, ptr %67, align 4, !tbaa !21
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [257 x i8], ptr %12, i64 0, i64 %69
  store i8 0, ptr %70, align 1, !tbaa !15
  %71 = getelementptr inbounds [257 x i8], ptr %12, i64 0, i64 0
  store ptr %71, ptr %10, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.DBF, ptr %72, i32 0, i32 10
  %74 = load i8, ptr %73, align 4, !tbaa !22
  %75 = icmp ne i8 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %34
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = call ptr @str_trim(ptr noundef %77)
  store ptr %78, ptr %10, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %76, %34
  br label %80

80:                                               ; preds = %88, %79
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.DBF, ptr %82, i32 0, i32 6
  %84 = load i8, ptr %83, align 8, !tbaa !23
  %85 = sext i8 %84 to i32
  %86 = call ptr @strchr(ptr noundef %81, i32 noundef %85) #7
  store ptr %86, ptr %11, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %97

88:                                               ; preds = %80
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  store i8 32, ptr %89, align 1, !tbaa !15
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.FIELD_RECORD, ptr %90, i32 0, i32 0
  %92 = getelementptr inbounds [11 x i8], ptr %91, i64 0, i64 0
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.DBF, ptr %93, i32 0, i32 4
  %95 = load i32, ptr %94, align 8, !tbaa !20
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ...) @lib_mesg(ptr noundef @.str, ptr noundef %92, i32 noundef %95, ptr noundef %96)
  br label %80, !llvm.loop !24

97:                                               ; preds = %80
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.FIELD_RECORD, ptr %98, i32 0, i32 1
  %100 = load i8, ptr %99, align 1, !tbaa !26
  %101 = zext i8 %100 to i32
  switch i32 %101, label %156 [
    i32 68, label %102
    i32 78, label %111
    i32 70, label %111
    i32 76, label %112
    i32 67, label %129
    i32 77, label %156
  ]

102:                                              ; preds = %97
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.DBF, ptr %103, i32 0, i32 9
  %105 = load i8, ptr %104, align 1, !tbaa !27
  %106 = icmp ne i8 %105, 0
  br i1 %106, label %107, label %110

107:                                              ; preds = %102
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = getelementptr inbounds i8, ptr %108, i64 2
  store ptr %109, ptr %10, align 8, !tbaa !5
  br label %110

110:                                              ; preds = %107, %102
  br label %137

111:                                              ; preds = %97, %97
  br label %137

112:                                              ; preds = %97
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.DBF, ptr %113, i32 0, i32 11
  %115 = load i8, ptr %114, align 1, !tbaa !28
  %116 = icmp ne i8 %115, 0
  br i1 %116, label %117, label %128

117:                                              ; preds = %112
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = load i8, ptr %118, align 1, !tbaa !15
  %120 = sext i8 %119 to i32
  %121 = call ptr @strchr(ptr noundef @.str.1, i32 noundef %120) #7
  %122 = icmp ne ptr %121, null
  br i1 %122, label %123, label %125

123:                                              ; preds = %117
  %124 = load ptr, ptr %10, align 8, !tbaa !5
  store i8 49, ptr %124, align 1, !tbaa !15
  br label %127

125:                                              ; preds = %117
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  store i8 48, ptr %126, align 1, !tbaa !15
  br label %127

127:                                              ; preds = %125, %123
  br label %128

128:                                              ; preds = %127, %112
  br label %137

129:                                              ; preds = %97
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  call void @oem858_to_iso885915(ptr noundef %130)
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = getelementptr inbounds [74 x i8], ptr %14, i64 0, i64 0
  %133 = call ptr @strpbrk(ptr noundef %131, ptr noundef %132) #7
  %134 = icmp ne ptr %133, null
  br i1 %134, label %135, label %136

135:                                              ; preds = %129
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %136

136:                                              ; preds = %135, %129
  br label %137

137:                                              ; preds = %136, %128, %111, %110
  %138 = load ptr, ptr %8, align 8, !tbaa !5
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = call ptr @strcpy(ptr noundef %138, ptr noundef %139) #6
  %141 = load ptr, ptr %8, align 8, !tbaa !5
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.DBF, ptr %142, i32 0, i32 17
  %144 = load ptr, ptr %143, align 8, !tbaa !11
  %145 = ptrtoint ptr %141 to i64
  %146 = ptrtoint ptr %144 to i64
  %147 = sub i64 %145, %146
  %148 = trunc i64 %147 to i32
  %149 = load ptr, ptr %7, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.FIELD_RECORD, ptr %149, i32 0, i32 2
  store i32 %148, ptr %150, align 4, !tbaa !18
  %151 = load ptr, ptr %10, align 8, !tbaa !5
  %152 = call i64 @strlen(ptr noundef %151) #7
  %153 = add i64 %152, 1
  %154 = load ptr, ptr %8, align 8, !tbaa !5
  %155 = getelementptr inbounds i8, ptr %154, i64 %153
  store ptr %155, ptr %8, align 8, !tbaa !5
  br label %156

156:                                              ; preds = %137, %97, %97
  br label %157

157:                                              ; preds = %156
  %158 = load i8, ptr %5, align 1, !tbaa !15
  %159 = add i8 %158, 1
  store i8 %159, ptr %5, align 1, !tbaa !15
  br label %26, !llvm.loop !29

160:                                              ; preds = %26
  %161 = load i32, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 74, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 257, 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 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #6
  ret i32 %161
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @str_trim(ptr noundef) #3

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

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

declare void @oem858_to_iso885915(ptr noundef) #3

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

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

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

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


; 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] }

@__const.dbf_2rdb.adsillegals = external hidden unnamed_addr constant [74 x i8], align 16
@.str = external hidden unnamed_addr constant [71 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @dbf_2rdb(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [257 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 257, ptr nonnull %3) #6
  %4 = getelementptr inbounds i8, ptr %0, i64 2104
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 2104
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = load i8, ptr %7, align 1, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %5, i64 1
  store i8 %8, ptr %5, align 1, !tbaa !13
  store i8 0, ptr %9, align 1, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %1, i64 2088
  %11 = load i8, ptr %10, align 8, !tbaa !14
  %.not61 = icmp eq i8 %11, 0
  br i1 %.not61, label %._crit_edge60, label %.lr.ph59

.lr.ph59:                                         ; preds = %2
  %12 = getelementptr inbounds i8, ptr %5, i64 2
  %13 = getelementptr inbounds i8, ptr %0, i64 2096
  %14 = getelementptr inbounds i8, ptr %1, i64 2096
  %15 = getelementptr inbounds i8, ptr %1, i64 2064
  %16 = getelementptr inbounds i8, ptr %0, i64 2064
  %17 = getelementptr inbounds i8, ptr %0, i64 2076
  %18 = getelementptr inbounds i8, ptr %0, i64 2072
  %19 = getelementptr inbounds i8, ptr %0, i64 2077
  %20 = getelementptr inbounds i8, ptr %0, i64 2075
  br label %21

21:                                               ; preds = %.lr.ph59, %75
  %indvars.iv = phi i64 [ 0, %.lr.ph59 ], [ %indvars.iv.next, %75 ]
  %.057 = phi i32 [ 0, %.lr.ph59 ], [ %.2, %75 ]
  %.04555 = phi ptr [ %12, %.lr.ph59 ], [ %.146, %75 ]
  %22 = load ptr, ptr %13, align 8, !tbaa !15
  %23 = getelementptr inbounds %struct.FIELD_RECORD, ptr %22, i64 %indvars.iv
  %24 = load ptr, ptr %14, align 8, !tbaa !15
  %25 = getelementptr inbounds %struct.FIELD_RECORD, ptr %24, i64 %indvars.iv
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %25, i64 12
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %26, i64 %29
  %31 = load i32, ptr %15, align 8, !tbaa !18
  store i32 %31, ptr %16, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %25, i64 16
  %33 = load i8, ptr %32, align 4, !tbaa !19
  %34 = zext i8 %33 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %3, ptr align 1 %30, i64 %34, i1 false)
  %35 = load i8, ptr %32, align 4, !tbaa !19
  %36 = zext i8 %35 to i64
  %37 = getelementptr inbounds [257 x i8], ptr %3, i64 0, i64 %36
  store i8 0, ptr %37, align 1, !tbaa !13
  %38 = load i8, ptr %17, align 4, !tbaa !20
  %.not = icmp eq i8 %38, 0
  br i1 %.not, label %41, label %39

39:                                               ; preds = %21
  %40 = call ptr @str_trim(ptr noundef nonnull %3) #6
  br label %41

41:                                               ; preds = %39, %21
  %.043 = phi ptr [ %40, %39 ], [ %3, %21 ]
  %42 = load i8, ptr %18, align 8, !tbaa !21
  %43 = sext i8 %42 to i32
  %44 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.043, i32 noundef %43) #7
  %.not4854 = icmp eq ptr %44, null
  br i1 %.not4854, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %41, %.lr.ph
  %45 = phi ptr [ %49, %.lr.ph ], [ %44, %41 ]
  store i8 32, ptr %45, align 1, !tbaa !13
  %46 = load i32, ptr %15, align 8, !tbaa !18
  call void (ptr, ...) @lib_mesg(ptr noundef nonnull @.str, ptr noundef %25, i32 noundef %46, ptr noundef %.043) #6
  %47 = load i8, ptr %18, align 8, !tbaa !21
  %48 = sext i8 %47 to i32
  %49 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.043, i32 noundef %48) #7
  %.not48 = icmp eq ptr %49, null
  br i1 %.not48, label %._crit_edge, label %.lr.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph, %41
  %50 = getelementptr inbounds i8, ptr %23, i64 11
  %51 = load i8, ptr %50, align 1, !tbaa !24
  switch i8 %51, label %75 [
    i8 68, label %52
    i8 78, label %64
    i8 70, label %64
    i8 76, label %54
    i8 67, label %62
  ]

52:                                               ; preds = %._crit_edge
  %53 = load i8, ptr %20, align 1, !tbaa !25
  %.not52 = icmp eq i8 %53, 0
  %spec.select.idx.sroa.sel.idx.sroa.sel.idx = select i1 %.not52, i64 0, i64 2
  %spec.select.idx.sroa.sel.idx.sroa.sel = getelementptr inbounds i8, ptr %.043, i64 %spec.select.idx.sroa.sel.idx.sroa.sel.idx
  br label %64

54:                                               ; preds = %._crit_edge
  %55 = load i8, ptr %19, align 1, !tbaa !26
  %.not50 = icmp eq i8 %55, 0
  br i1 %.not50, label %64, label %56

56:                                               ; preds = %54
  %57 = load i8, ptr %.043, align 1, !tbaa !13
  %58 = sext i8 %57 to i32
  %59 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %58) #7
  %.not51 = icmp eq ptr %59, null
  br i1 %.not51, label %61, label %60

60:                                               ; preds = %56
  store i8 49, ptr %.043, align 1, !tbaa !13
  br label %64

61:                                               ; preds = %56
  store i8 48, ptr %.043, align 1, !tbaa !13
  br label %64

62:                                               ; preds = %._crit_edge
  call void @oem858_to_iso885915(ptr noundef %.043) #6
  %63 = call ptr @strpbrk(ptr noundef %.043, ptr noundef nonnull @__const.dbf_2rdb.adsillegals) #7
  %.not49 = icmp eq ptr %63, null
  %spec.select53 = select i1 %.not49, i32 %.057, i32 1
  br label %64

64:                                               ; preds = %62, %52, %54, %61, %60, %._crit_edge, %._crit_edge
  %.144 = phi ptr [ %.043, %60 ], [ %.043, %61 ], [ %.043, %54 ], [ %.043, %._crit_edge ], [ %.043, %._crit_edge ], [ %spec.select.idx.sroa.sel.idx.sroa.sel, %52 ], [ %.043, %62 ]
  %.1 = phi i32 [ %.057, %60 ], [ %.057, %61 ], [ %.057, %54 ], [ %.057, %._crit_edge ], [ %.057, %._crit_edge ], [ %.057, %52 ], [ %spec.select53, %62 ]
  %65 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %.04555, ptr noundef nonnull dereferenceable(1) %.144) #6
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = ptrtoint ptr %.04555 to i64
  %68 = ptrtoint ptr %66 to i64
  %69 = sub i64 %67, %68
  %70 = trunc i64 %69 to i32
  %71 = getelementptr inbounds i8, ptr %23, i64 12
  store i32 %70, ptr %71, align 4, !tbaa !16
  %72 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.144) #7
  %73 = add i64 %72, 1
  %74 = getelementptr inbounds i8, ptr %.04555, i64 %73
  br label %75

75:                                               ; preds = %._crit_edge, %64
  %.146 = phi ptr [ %.04555, %._crit_edge ], [ %74, %64 ]
  %.2 = phi i32 [ %.057, %._crit_edge ], [ %.1, %64 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %76 = load i8, ptr %10, align 8, !tbaa !14
  %77 = zext i8 %76 to i64
  %78 = icmp ult i64 %indvars.iv.next, %77
  br i1 %78, label %21, label %._crit_edge60, !llvm.loop !27

._crit_edge60:                                    ; preds = %75, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %.2, %75 ]
  call void @llvm.lifetime.end.p0(i64 257, ptr nonnull %3) #6
  ret i32 %.0.lcssa
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @str_trim(ptr noundef) local_unnamed_addr #3

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

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

declare void @oem858_to_iso885915(ptr noundef) local_unnamed_addr #3

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

; 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 #5

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

; 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: readwrite) }
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 = { 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 #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, !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 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 2088}
!15 = !{!6, !9, i64 2096}
!16 = !{!17, !10, i64 12}
!17 = !{!"FIELD_RECORD", !7, i64 0, !7, i64 11, !10, i64 12, !7, i64 16, !7, i64 17, !7, i64 18}
!18 = !{!6, !10, i64 2064}
!19 = !{!17, !7, i64 16}
!20 = !{!6, !7, i64 2076}
!21 = !{!6, !7, i64 2072}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!17, !7, i64 11}
!25 = !{!6, !7, i64 2075}
!26 = !{!6, !7, i64 2077}
!27 = distinct !{!27, !23}


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