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

@_pow = external hidden global [16 x double], align 16
@tmpbuf = external hidden global [200 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @f2a_(float noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [16 x double], ptr @_pow, i64 0, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fptrunc double %10 to float
  %12 = load float, ptr %4, align 4, !tbaa !5
  %13 = fmul float %12, %11
  store float %13, ptr %4, align 4, !tbaa !5
  %14 = load float, ptr %4, align 4, !tbaa !5
  %15 = load float, ptr %4, align 4, !tbaa !5
  %16 = fptosi float %15 to i64
  %17 = sitofp i64 %16 to float
  %18 = fsub float %14, %17
  %19 = fcmp oge float %18, 0.000000e+00
  br i1 %19, label %20, label %26

20:                                               ; preds = %3
  %21 = load float, ptr %4, align 4, !tbaa !5
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = fptosi float %22 to i64
  %24 = sitofp i64 %23 to float
  %25 = fsub float %21, %24
  br label %33

26:                                               ; preds = %3
  %27 = load float, ptr %4, align 4, !tbaa !5
  %28 = load float, ptr %4, align 4, !tbaa !5
  %29 = fptosi float %28 to i64
  %30 = sitofp i64 %29 to float
  %31 = fsub float %27, %30
  %32 = fneg float %31
  br label %33

33:                                               ; preds = %26, %20
  %34 = phi float [ %25, %20 ], [ %32, %26 ]
  %35 = fpext float %34 to double
  %36 = fcmp ogt double %35, 0x3E7AD7F29ABCAF48
  br i1 %36, label %37, label %47

37:                                               ; preds = %33
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = load float, ptr %4, align 4, !tbaa !5
  %40 = fpext float %39 to double
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [16 x double], ptr @_pow, i64 0, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = fdiv double %40, %44
  %46 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @tmpbuf, ptr noundef @.str.12, i32 noundef %38, double noundef %45) #3
  br label %52

47:                                               ; preds = %33
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = load float, ptr %4, align 4, !tbaa !5
  %50 = fptosi float %49 to i64
  %51 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @tmpbuf, ptr noundef @.str, i32 noundef %48, i64 noundef %50) #3
  br label %52

52:                                               ; preds = %47, %37
  %53 = call i64 @strlen(ptr noundef @tmpbuf) #4
  %54 = trunc i64 %53 to i32
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = icmp ne i32 %54, %55
  br i1 %56, label %57, label %60

57:                                               ; preds = %52
  %58 = call i64 @strlen(ptr noundef @tmpbuf) #4
  %59 = trunc i64 %58 to i32
  call void @conv_error(i32 noundef %59, i32 noundef 2)
  br label %60

60:                                               ; preds = %57, %52
  ret ptr @tmpbuf
}

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 = { 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 = { 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 #3 = { nounwind }
attributes #4 = { 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 = !{!"float", !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, !12, i64 0}
!12 = !{!"double", !7, i64 0}


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

@_pow = external hidden local_unnamed_addr global [16 x double], align 16
@tmpbuf = external hidden global [200 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) 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
define dso_local noundef nonnull ptr @f2a_(float noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = sext i32 %2 to i64
  %5 = getelementptr inbounds [16 x double], ptr @_pow, i64 0, i64 %4
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fptrunc double %6 to float
  %8 = fmul float %7, %0
  %9 = fptosi float %8 to i64
  %10 = sitofp i64 %9 to float
  %11 = fsub float %8, %10
  %12 = fcmp ult float %11, 0.000000e+00
  %13 = fneg float %11
  %14 = select i1 %12, float %13, float %11
  %15 = fpext float %14 to double
  %16 = fcmp ogt double %15, 0x3E7AD7F29ABCAF48
  br i1 %16, label %17, label %21

17:                                               ; preds = %3
  %18 = fpext float %8 to double
  %19 = fdiv double %18, %6
  %20 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @tmpbuf, ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %1, double noundef %19) #3
  br label %23

21:                                               ; preds = %3
  %22 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @tmpbuf, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1, i64 noundef %9) #3
  br label %23

23:                                               ; preds = %21, %17
  %24 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @tmpbuf) #4
  %25 = trunc i64 %24 to i32
  %.not = icmp eq i32 %25, %1
  br i1 %.not, label %27, label %26

26:                                               ; preds = %23
  tail call void @conv_error(i32 noundef %25, i32 noundef 2)
  br label %27

27:                                               ; preds = %26, %23
  ret ptr @tmpbuf
}

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 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 = { nounwind }
attributes #4 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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