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

@tmpbuf = external hidden global [200 x i8], align 16
@_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: 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: inlinehint nounwind willreturn memory(read) uwtable
declare double @atof(ptr noundef nonnull) #1

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i64 @atol(ptr noundef nonnull) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @f2a(float noundef, i32 noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @put_fld_a(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %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
  %9 = alloca ptr, align 8
  %10 = 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) #7
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = sdiv i32 %11, 256
  store i32 %12, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = srem i32 %13, 256
  store i32 %14, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %15 = load i32, ptr %7, 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 %8, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [26 x %struct.fld_table], ptr %17, i64 0, i64 %19
  store ptr %20, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.fld_table, ptr %21, i32 0, i32 4
  %23 = load i32, ptr %22, align 4, !tbaa !11
  store i32 %23, ptr %10, align 4, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %24, ptr @record, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %25, ptr @field, align 4, !tbaa !9
  store i32 0, ptr @cv_error, align 4, !tbaa !9
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.fld_table, ptr %26, i32 0, i32 0
  %28 = load i8, ptr %27, align 4, !tbaa !13
  %29 = sext i8 %28 to i32
  switch i32 %29, label %64 [
    i32 115, label %30
    i32 102, label %50
    i32 108, label %59
  ]

30:                                               ; preds = %3
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.fld_table, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call i64 @strlen(ptr noundef %34) #8
  %36 = trunc i64 %35 to i32
  %37 = icmp sgt i32 %33, %36
  br i1 %37, label %38, label %46

38:                                               ; preds = %30
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.fld_table, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !14
  store i32 %41, ptr %10, align 4, !tbaa !9
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.fld_table, ptr %42, i32 0, i32 4
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  call void @llvm.memset.p0.i64(ptr align 16 @tmpbuf, i8 32, i64 %45, i1 false)
  br label %46

46:                                               ; preds = %38, %30
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = call i64 @strlen(ptr noundef %48) #8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @tmpbuf, ptr align 1 %47, i64 %49, i1 false)
  br label %68

50:                                               ; preds = %3
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call double @atof(ptr noundef %51) #8
  %53 = fptrunc double %52 to float
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.fld_table, ptr %55, i32 0, i32 5
  %57 = load i32, ptr %56, align 4, !tbaa !15
  %58 = call ptr @f2a(float noundef %53, i32 noundef %54, i32 noundef %57)
  br label %68

59:                                               ; preds = %3
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = call i64 @atol(ptr noundef %60) #8
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = call ptr @l2a(i64 noundef %61, i32 noundef %62)
  br label %68

64:                                               ; preds = %3
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %65, i32 noundef %66)
  br label %68

68:                                               ; preds = %64, %59, %50, %46
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.fld_table, ptr %70, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !16
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %69, i64 %73
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %74, ptr align 16 @tmpbuf, i64 %76, i1 false)
  %77 = load i32, ptr @cv_error, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  ret i32 %77
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint nounwind willreturn memory(read) 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 #2 = { 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 #3 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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, !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 20}
!16 = !{!12, !10, i64 12}


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

@tmpbuf = external hidden local_unnamed_addr global [200 x i8], align 16
@_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: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare double @atof(ptr nocapture noundef nonnull) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i64 @atol(ptr nocapture noundef nonnull) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @put_fld_a(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = sdiv i32 %2, 256
  %5 = srem i32 %2, 256
  %6 = sext i32 %4 to i64
  %7 = sext i32 %5 to i64
  %8 = getelementptr inbounds [27 x [26 x %struct.fld_table]], ptr @_ft, i64 0, i64 %6, i64 %7
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load i32, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr @record, align 4, !tbaa !10
  store i32 %5, ptr @field, align 4, !tbaa !10
  store i32 0, ptr @cv_error, align 4, !tbaa !10
  %11 = load i8, ptr %8, align 8, !tbaa !11
  switch i8 %11, label %31 [
    i8 115, label %12
    i8 102, label %22
    i8 108, label %28
  ]

12:                                               ; preds = %3
  %13 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %14 = trunc i64 %13 to i32
  %15 = icmp sgt i32 %10, %14
  br i1 %15, label %16, label %20

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %8, i64 8
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = sext i32 %10 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @tmpbuf, i8 32, i64 %19, i1 false)
  br label %20

20:                                               ; preds = %16, %12
  %.0 = phi i32 [ %18, %16 ], [ %10, %12 ]
  %21 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @tmpbuf, ptr align 1 %1, i64 %21, i1 false)
  br label %33

22:                                               ; preds = %3
  %23 = tail call double @atof(ptr noundef %1) #6
  %24 = fptrunc double %23 to float
  %25 = getelementptr inbounds i8, ptr %8, i64 20
  %26 = load i32, ptr %25, align 4, !tbaa !13
  %27 = tail call ptr @f2a(float noundef %24, i32 noundef %10, i32 noundef %26)
  br label %33

28:                                               ; preds = %3
  %29 = tail call i64 @atol(ptr nocapture noundef %1) #6
  %30 = tail call ptr @l2a(i64 noundef %29, i32 noundef %10)
  br label %33

31:                                               ; preds = %3
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %4, i32 noundef %5)
  br label %33

33:                                               ; preds = %31, %28, %22, %20
  %.1 = phi i32 [ %10, %31 ], [ %10, %28 ], [ %10, %22 ], [ %.0, %20 ]
  %34 = getelementptr inbounds i8, ptr %8, i64 12
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr %0, i64 %36
  %38 = sext i32 %.1 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %37, ptr nonnull align 16 @tmpbuf, i64 %38, i1 false)
  %39 = load i32, ptr @cv_error, align 4, !tbaa !10
  ret i32 %39
}

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

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

attributes #0 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 = { 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 #2 = { 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 #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 16}
!6 = !{!"fld_table", !7, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !9, i64 8}
!13 = !{!6, !9, i64 20}
!14 = !{!6, !9, i64 12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass