; LLVM IR from mbheinen/bpa-ipf-tsp :: cflow (convtbl)

; 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.fld_table = type { i8, i32, i32, i32, i32, i32 }

@_ft = external global [27 x [26 x %struct.fld_table]], align 16
@record = external hidden global i32, align 4
@field = external hidden global i32, align 4
@cv_error = external dso_local global i32, align 4
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local float @a2f(ptr noundef, i32 noundef, i32 noundef) #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden void @conv_error(i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @a2l(ptr noundef, i32 noundef) #0

declare i32 @printf(ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cv_rec_a2b(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %13, ptr @record, align 4, !tbaa !9
  store i32 0, ptr @cv_error, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %118, %3
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %16
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [26 x %struct.fld_table], ptr %17, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.fld_table, ptr %20, i32 0, i32 4
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %121

24:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %26
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [26 x %struct.fld_table], ptr %27, i64 0, i64 %29
  store ptr %30, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.fld_table, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %31, i64 %35
  store ptr %36, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.fld_table, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !14
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i8, ptr %37, i64 %41
  store ptr %42, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.fld_table, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !14
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %43, i64 %47
  store ptr %48, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.fld_table, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !15
  store i32 %51, ptr %12, align 4, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %52, ptr @field, align 4, !tbaa !9
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.fld_table, ptr %53, i32 0, i32 0
  %55 = load i8, ptr %54, align 4, !tbaa !16
  %56 = sext i8 %55 to i32
  switch i32 %56, label %114 [
    i32 115, label %57
    i32 102, label %96
    i32 108, label %106
  ]

57:                                               ; preds = %24
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.fld_table, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 4, !tbaa !15
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.fld_table, ptr %61, i32 0, i32 4
  %63 = load i32, ptr %62, align 4, !tbaa !11
  %64 = icmp sgt i32 %60, %63
  br i1 %64, label %65, label %75

65:                                               ; preds = %57
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.fld_table, ptr %66, i32 0, i32 4
  %68 = load i32, ptr %67, align 4, !tbaa !11
  store i32 %68, ptr %12, align 4, !tbaa !9
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.fld_table, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !15
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %69, i8 0, i64 %74, i1 false)
  br label %86

75:                                               ; preds = %57
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.fld_table, ptr %76, i32 0, i32 4
  %78 = load i32, ptr %77, align 4, !tbaa !11
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.fld_table, ptr %79, i32 0, i32 2
  %81 = load i32, ptr %80, align 4, !tbaa !15
  %82 = icmp sgt i32 %78, %81
  br i1 %82, label %83, label %85

83:                                               ; preds = %75
  %84 = load i32, ptr %12, align 4, !tbaa !9
  call void @conv_error(i32 noundef %84, i32 noundef 3)
  br label %85

85:                                               ; preds = %83, %75
  br label %86

86:                                               ; preds = %85, %65
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  %89 = load i32, ptr %12, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = call ptr @strncpy(ptr noundef %87, ptr noundef %88, i64 noundef %90) #5
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = load i32, ptr %12, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %92, i64 %94
  store i8 0, ptr %95, align 1, !tbaa !17
  br label %118

96:                                               ; preds = %24
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.fld_table, ptr %98, i32 0, i32 4
  %100 = load i32, ptr %99, align 4, !tbaa !11
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.fld_table, ptr %101, i32 0, i32 5
  %103 = load i32, ptr %102, align 4, !tbaa !18
  %104 = call float @a2f(ptr noundef %97, i32 noundef %100, i32 noundef %103)
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  store float %104, ptr %105, align 4, !tbaa !19
  br label %118

106:                                              ; preds = %24
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.fld_table, ptr %108, i32 0, i32 4
  %110 = load i32, ptr %109, align 4, !tbaa !11
  %111 = call i64 @a2l(ptr noundef %107, i32 noundef %110)
  %112 = trunc i64 %111 to i32
  %113 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %112, ptr %113, align 4, !tbaa !9
  br label %118

114:                                              ; preds = %24
  %115 = load i32, ptr %6, align 4, !tbaa !9
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %115, i32 noundef %116)
  br label %118

118:                                              ; preds = %114, %106, %96, %86
  %119 = load i32, ptr %7, align 4, !tbaa !9
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %14, !llvm.loop !21

121:                                              ; preds = %14
  %122 = load i32, ptr @cv_error, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 %122
}

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"fld_table", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!13 = !{!12, !10, i64 12}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !10, i64 20}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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.fld_table = type { i8, i32, i32, i32, i32, i32 }

@_ft = external local_unnamed_addr global [27 x [26 x %struct.fld_table]], align 16
@record = external hidden local_unnamed_addr global i32, align 4
@field = external hidden local_unnamed_addr global i32, align 4
@cv_error = external dso_local local_unnamed_addr global i32, align 4
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local float @a2f(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @conv_error(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @a2l(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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

; Function Attrs: nounwind uwtable
define dso_local i32 @cv_rec_a2b(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  store i32 %2, ptr @record, align 4, !tbaa !5
  store i32 0, ptr @cv_error, align 4, !tbaa !5
  %4 = sext i32 %2 to i64
  %5 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %4, i64 1
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3, %44
  %indvars.iv = phi i64 [ %indvars.iv.next, %44 ], [ 1, %3 ]
  %9 = phi i32 [ %47, %44 ], [ %7, %3 ]
  %10 = phi ptr [ %45, %44 ], [ %5, %3 ]
  %11 = getelementptr inbounds i8, ptr %10, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %1, i64 %13
  %15 = getelementptr inbounds i8, ptr %10, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i8, ptr %0, i64 %17
  %19 = getelementptr inbounds i8, ptr %10, i64 8
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %21, ptr @field, align 4, !tbaa !5
  %22 = load i8, ptr %10, align 4, !tbaa !14
  switch i8 %22, label %42 [
    i8 115, label %23
    i8 102, label %35
    i8 108, label %39
  ]

23:                                               ; preds = %.lr.ph
  %24 = icmp sgt i32 %20, %9
  br i1 %24, label %25, label %28

25:                                               ; preds = %23
  %26 = add nuw nsw i32 %20, 1
  %27 = zext nneg i32 %26 to i64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %18, i8 0, i64 %27, i1 false)
  br label %31

28:                                               ; preds = %23
  %29 = icmp sgt i32 %9, %20
  br i1 %29, label %30, label %31

30:                                               ; preds = %28
  tail call void @conv_error(i32 noundef %20, i32 noundef 3)
  br label %31

31:                                               ; preds = %28, %30, %25
  %.0 = phi i32 [ %9, %25 ], [ %20, %30 ], [ %20, %28 ]
  %32 = sext i32 %.0 to i64
  %33 = tail call ptr @strncpy(ptr noundef %18, ptr noundef %14, i64 noundef %32) #4
  %34 = getelementptr inbounds i8, ptr %18, i64 %32
  store i8 0, ptr %34, align 1, !tbaa !15
  br label %44

35:                                               ; preds = %.lr.ph
  %36 = getelementptr inbounds i8, ptr %10, i64 20
  %37 = load i32, ptr %36, align 4, !tbaa !16
  %38 = tail call float @a2f(ptr noundef %14, i32 noundef %9, i32 noundef %37)
  store float %38, ptr %18, align 4, !tbaa !17
  br label %44

39:                                               ; preds = %.lr.ph
  %40 = tail call i64 @a2l(ptr noundef %14, i32 noundef %9)
  %41 = trunc i64 %40 to i32
  store i32 %41, ptr %18, align 4, !tbaa !5
  br label %44

42:                                               ; preds = %.lr.ph
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %2, i32 noundef %21)
  br label %44

44:                                               ; preds = %42, %39, %35, %31
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %45 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %4, i64 %indvars.iv.next
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  %47 = load i32, ptr %46, align 8, !tbaa !9
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %44
  %.pre = load i32, ptr @cv_error, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %49 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ 0, %3 ]
  ret i32 %49
}

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"fld_table", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!11 = !{!10, !6, i64 12}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !6, i64 20}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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