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

; 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.TOKN = type { i32, [200 x ptr] }

@debug_fp = external dso_local global ptr, align 8
@.str.80 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.89 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr 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: nounwind willreturn memory(read)
declare ptr @strstr(ptr noundef, ptr noundef) #2

; 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
define dso_local i32 @get_tokens(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call ptr @strstr(ptr noundef %11, ptr noundef @.str.80) #5
  store ptr %12, ptr %10, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %16, %4
  %14 = load ptr, ptr %10, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %20

16:                                               ; preds = %13
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  store i8 32, ptr %17, align 1, !tbaa !11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call ptr @strstr(ptr noundef %18, ptr noundef @.str.80) #5
  store ptr %19, ptr %10, align 8, !tbaa !5
  br label %13, !llvm.loop !12

20:                                               ; preds = %13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call ptr @strstr(ptr noundef %21, ptr noundef @.str.81) #5
  store ptr %22, ptr %10, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %26, %20
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  store i8 32, ptr %27, align 1, !tbaa !11
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call ptr @strstr(ptr noundef %28, ptr noundef @.str.81) #5
  store ptr %29, ptr %10, align 8, !tbaa !5
  br label %23, !llvm.loop !14

30:                                               ; preds = %23
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call ptr @strtok_x(ptr noundef %31, ptr noundef @.str.89)
  store ptr %32, ptr %10, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %57, %30
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %66

36:                                               ; preds = %33
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TOKN, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [200 x ptr], ptr %39, i64 0, i64 %41
  store ptr %37, ptr %42, align 8, !tbaa !5
  %43 = load ptr, ptr @debug_fp, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %57

45:                                               ; preds = %36
  %46 = load ptr, ptr @debug_fp, align 8, !tbaa !5
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TOKN, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200 x ptr], ptr %51, i64 0, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.90, ptr noundef %47, i32 noundef %48, i32 noundef %49, ptr noundef %55) #4
  br label %57

57:                                               ; preds = %45, %36
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %9, align 4, !tbaa !9
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.TOKN, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200 x ptr], ptr %61, i64 0, i64 %63
  store ptr null, ptr %64, align 8, !tbaa !5
  %65 = call ptr @strtok_x(ptr noundef null, ptr noundef @.str.89)
  store ptr %65, ptr %10, align 8, !tbaa !5
  br label %33, !llvm.loop !15

66:                                               ; preds = %33
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TOKN, ptr %68, i32 0, i32 0
  store i32 %67, ptr %69, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @strtok_x(ptr noundef, ptr noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = !{!17, !10, i64 0}
!17 = !{!"", !10, i64 0, !7, i64 8}


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

@debug_fp = external dso_local local_unnamed_addr global ptr, align 8
@.str.80 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.89 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [37 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strstr(ptr noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @get_tokens(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str.80) #3
  %.not27 = icmp eq ptr %5, null
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.028 = phi ptr [ %6, %.lr.ph ], [ %5, %4 ]
  store i8 32, ptr %.028, align 1, !tbaa !5
  %6 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str.80) #3
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %4
  %7 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str.81) #3
  %.not2429 = icmp eq ptr %7, null
  br i1 %.not2429, label %._crit_edge33, label %.lr.ph32

.lr.ph32:                                         ; preds = %._crit_edge, %.lr.ph32
  %.130 = phi ptr [ %8, %.lr.ph32 ], [ %7, %._crit_edge ]
  store i8 32, ptr %.130, align 1, !tbaa !5
  %8 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str.81) #3
  %.not24 = icmp eq ptr %8, null
  br i1 %.not24, label %._crit_edge33, label %.lr.ph32, !llvm.loop !10

._crit_edge33:                                    ; preds = %.lr.ph32, %._crit_edge
  %9 = tail call ptr @strtok_x(ptr noundef %0, ptr noundef nonnull @.str.89)
  %.not2534 = icmp eq ptr %9, null
  br i1 %.not2534, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %._crit_edge33
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  br label %11

11:                                               ; preds = %.lr.ph38, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph38 ], [ %indvars.iv.next, %17 ]
  %.236 = phi ptr [ %9, %.lr.ph38 ], [ %19, %17 ]
  %12 = getelementptr inbounds [200 x ptr], ptr %10, i64 0, i64 %indvars.iv
  store ptr %.236, ptr %12, align 8, !tbaa !11
  %13 = load ptr, ptr @debug_fp, align 8, !tbaa !11
  %.not26 = icmp eq ptr %13, null
  br i1 %.not26, label %17, label %14

14:                                               ; preds = %11
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %13, ptr noundef nonnull @.str.90, ptr noundef %2, i32 noundef %3, i32 noundef %15, ptr noundef nonnull %.236) #4
  br label %17

17:                                               ; preds = %14, %11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = getelementptr inbounds [200 x ptr], ptr %10, i64 0, i64 %indvars.iv.next
  store ptr null, ptr %18, align 8, !tbaa !11
  %19 = tail call ptr @strtok_x(ptr noundef null, ptr noundef nonnull @.str.89)
  %.not25 = icmp eq ptr %19, null
  br i1 %.not25, label %._crit_edge39.loopexit, label %11, !llvm.loop !13

._crit_edge39.loopexit:                           ; preds = %17
  %20 = trunc nuw i64 %indvars.iv.next to i32
  br label %._crit_edge39

._crit_edge39:                                    ; preds = %._crit_edge39.loopexit, %._crit_edge33
  %.022.lcssa = phi i32 [ 0, %._crit_edge33 ], [ %20, %._crit_edge39.loopexit ]
  store i32 %.022.lcssa, ptr %1, align 8, !tbaa !14
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @strtok_x(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #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) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !6, i64 0}
!13 = distinct !{!13, !9}
!14 = !{!15, !16, i64 0}
!15 = !{!"", !16, i64 0, !6, i64 8}
!16 = !{!"int", !6, i64 0}


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