; 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 }
%struct.anon = type { [3 x i8], i32, i32 }
%struct.pf_rec = type { %union.input_data, %union.solution_data }
%union.input_data = type { %struct.pf_branch }
%struct.pf_branch = type { [3 x i8], [4 x i8], [9 x i8], float, i32, [9 x i8], float, i8, i32, float, i32, float, float, float, float, float, float, float, float, [9 x i8], [4 x i8], [4 x i8], float, float, float }
%union.solution_data = type { %struct.pf_xdata_soln }
%struct.pf_xdata_soln = type { [3 x i8], i32, i32, float, i32, i32, float, i32, i32, float, i32, i32, float, i32, i32, float, i32, i32, float, i32, i32, float, i32, i32, float }
%struct.pf_AC_bus = type { [3 x i8], [4 x i8], [9 x i8], float, [3 x i8], i32, float, float, float, float, float, float, float, float, float, float, [9 x i8], float, i8, float }

@_ft = external global [27 x [26 x %struct.fld_table]], align 16
@tb = external dso_local global [24 x %struct.anon], align 16
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [44 x i8], align 1
@__PRETTY_FUNCTION__.cv_pfs_b2a = external hidden unnamed_addr constant [31 x i8], align 1

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

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

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

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
declare dso_local i32 @cv_rec_b2a(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local i32 @cv_pfs_b2a(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %66, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [24 x %struct.anon], ptr @tb, i64 0, i64 %11
  %13 = getelementptr inbounds %struct.anon, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %69

16:                                               ; preds = %9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [24 x %struct.anon], ptr @tb, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.anon, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds [3 x i8], ptr %20, i64 0, i64 0
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.pf_rec, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.pf_AC_bus, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds [3 x i8], ptr %24, i64 0, i64 0
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [24 x %struct.anon], ptr @tb, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds [3 x i8], ptr %29, i64 0, i64 0
  %31 = call i64 @strlen(ptr noundef %30) #7
  %32 = call i32 @strncmp(ptr noundef %21, ptr noundef %25, i64 noundef %31) #7
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %66

34:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [24 x %struct.anon], ptr @tb, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %40
  %42 = getelementptr inbounds [26 x %struct.fld_table], ptr %41, i64 0, i64 0
  %43 = getelementptr inbounds %struct.fld_table, ptr %42, i32 0, i32 4
  %44 = load i32, ptr %43, align 16, !tbaa !13
  store i32 %44, ptr %7, align 4, !tbaa !9
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 400
  br i1 %46, label %47, label %48

47:                                               ; preds = %34
  br label %49

48:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.17, i32 noundef 446, ptr noundef @__PRETTY_FUNCTION__.cv_pfs_b2a) #8
  unreachable

49:                                               ; preds = %47
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %50, i8 32, i64 %52, i1 false)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %53, i64 %55
  store i8 0, ptr %56, align 1, !tbaa !15
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.pf_rec, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [24 x %struct.anon], ptr @tb, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.anon, ptr %62, i32 0, i32 2
  %64 = load i32, ptr %63, align 4, !tbaa !11
  %65 = call i32 @cv_rec_b2a(ptr noundef %57, ptr noundef %59, i32 noundef %64)
  store i32 %65, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %72

66:                                               ; preds = %16
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !16

69:                                               ; preds = %9
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, ptr noundef %70)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %72

72:                                               ; preds = %69, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %73 = load i32, ptr %3, align 4
  ret i32 %73
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { noreturn 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) }
attributes #8 = { noreturn 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 8}
!12 = !{!"", !7, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!14, !10, i64 16}
!14 = !{!"fld_table", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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 }
%struct.anon = type { [3 x i8], i32, i32 }

@_ft = external local_unnamed_addr global [27 x [26 x %struct.fld_table]], align 16
@tb = external dso_local global [24 x %struct.anon], align 16
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [44 x i8], align 1
@__PRETTY_FUNCTION__.cv_pfs_b2a = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture 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
declare dso_local i32 @cv_rec_b2a(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local i32 @cv_pfs_b2a(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @tb, i64 8), align 8, !tbaa !5
  %.not21 = icmp eq i32 %3, 0
  br i1 %.not21, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @tb) #5
  %5 = tail call i32 @strncmp(ptr noundef nonnull @tb, ptr noundef %1, i64 noundef %4) #5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %.lr.ph._crit_edge, label %.lr.ph34

.lr.ph34:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv33 = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv33, 1
  %7 = getelementptr inbounds [24 x %struct.anon], ptr @tb, i64 0, i64 %indvars.iv.next
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

.lr.ph:                                           ; preds = %.lr.ph34
  %10 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %7) #5
  %11 = tail call i32 @strncmp(ptr noundef nonnull %7, ptr noundef %1, i64 noundef %10) #5
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %.lr.ph._crit_edge, label %.lr.ph34, !llvm.loop !10

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa31 = phi i32 [ %3, %.lr.ph.preheader ], [ %9, %.lr.ph ]
  %.lcssa = phi ptr [ @tb, %.lr.ph.preheader ], [ %7, %.lr.ph ]
  %13 = sext i32 %.lcssa31 to i64
  %14 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %13, i64 0, i32 4
  %15 = load i32, ptr %14, align 16, !tbaa !12
  %16 = icmp slt i32 %15, 400
  br i1 %16, label %18, label %17

17:                                               ; preds = %.lr.ph._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.17, i32 noundef 446, ptr noundef nonnull @__PRETTY_FUNCTION__.cv_pfs_b2a) #6
  unreachable

18:                                               ; preds = %.lr.ph._crit_edge
  %19 = getelementptr inbounds i8, ptr %.lcssa, i64 8
  %20 = sext i32 %15 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %0, i8 32, i64 %20, i1 false)
  %21 = getelementptr inbounds i8, ptr %0, i64 %20
  store i8 0, ptr %21, align 1, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %1, i64 120
  %23 = load i32, ptr %19, align 4, !tbaa !5
  %24 = tail call i32 @cv_rec_b2a(ptr noundef %0, ptr noundef nonnull %22, i32 noundef %23)
  br label %26

._crit_edge:                                      ; preds = %.lr.ph34, %2
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, ptr noundef %0)
  br label %26

26:                                               ; preds = %._crit_edge, %18
  %.0 = phi i32 [ %24, %18 ], [ -1, %._crit_edge ]
  ret i32 %.0
}

attributes #0 = { 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 #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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { noreturn 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 willreturn memory(read) }
attributes #6 = { noreturn 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, !9, i64 8}
!6 = !{!"", !7, i64 0, !9, i64 4, !9, i64 8}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !9, i64 16}
!13 = !{!"fld_table", !7, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20}
!14 = !{!7, !7, i64 0}


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