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

; Function Attrs: nounwind uwtable
define dso_local i32 @put_fld_b(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 2
  %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 %69 [
    i32 115, label %30
    i32 102, label %55
    i32 108, label %64
  ]

30:                                               ; preds = %3
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.fld_table, ptr %31, i32 0, i32 2
  %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 %43

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 !11
  %42 = sext i32 %41 to i64
  call void @llvm.memset.p0.i64(ptr align 16 @tmpbuf, i8 0, i64 %42, i1 false)
  br label %46

43:                                               ; preds = %30
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %10, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %43, %38
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @tmpbuf, ptr align 1 %47, i64 %49, i1 false)
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.fld_table, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200 x i8], ptr @tmpbuf, i64 0, i64 %53
  store i8 0, ptr %54, align 1, !tbaa !14
  br label %73

55:                                               ; preds = %3
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call double @atof(ptr noundef %56) #8
  %58 = fptrunc double %57 to float
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.fld_table, ptr %60, i32 0, i32 5
  %62 = load i32, ptr %61, align 4, !tbaa !15
  %63 = call ptr @f2a(float noundef %58, i32 noundef %59, i32 noundef %62)
  br label %73

64:                                               ; preds = %3
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = call i64 @atol(ptr noundef %65) #8
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = call ptr @l2a(i64 noundef %66, i32 noundef %67)
  br label %73

69:                                               ; preds = %3
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %70, i32 noundef %71)
  br label %73

73:                                               ; preds = %69, %64, %55, %46
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.fld_table, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !16
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %74, i64 %78
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %79, ptr align 16 @tmpbuf, i64 %81, i1 false)
  %82 = 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 %82
}

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 8}
!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 = !{!7, !7, i64 0}
!15 = !{!12, !10, i64 20}
!16 = !{!12, !10, i64 4}


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

; Function Attrs: nounwind uwtable
define dso_local i32 @put_fld_b(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 8
  %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 %18

16:                                               ; preds = %12
  %17 = sext i32 %10 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @tmpbuf, i8 0, i64 %17, i1 false)
  br label %20

18:                                               ; preds = %12
  %19 = add nsw i32 %10, 1
  %.pre = sext i32 %19 to i64
  %.pre25 = sext i32 %10 to i64
  br label %20

20:                                               ; preds = %18, %16
  %.pre-phi26 = phi i64 [ %.pre25, %18 ], [ %17, %16 ]
  %.pre-phi = phi i64 [ %.pre, %18 ], [ %17, %16 ]
  %.0 = phi i32 [ %19, %18 ], [ %10, %16 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @tmpbuf, ptr align 1 %1, i64 %.pre-phi, i1 false)
  %21 = getelementptr inbounds [200 x i8], ptr @tmpbuf, i64 0, i64 %.pre-phi26
  store i8 0, ptr %21, align 1, !tbaa !12
  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 4
  %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
}

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 8}
!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 = !{!7, !7, i64 0}
!13 = !{!6, !9, i64 20}
!14 = !{!6, !9, i64 4}


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