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

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

@p_cmdfil_c.rname = external hidden global [16 x i8], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @p_cmdfil_c(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [61 x i8], align 16
  %6 = alloca [133 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 61, ptr %5) #9
  call void @llvm.lifetime.start.p0(i64 133, ptr %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  store i32 0, ptr %7, align 4, !tbaa !9
  %14 = getelementptr inbounds [61 x i8], ptr %5, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %14, i8 0, i64 61, i1 false)
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = call ptr @strchr(ptr noundef %15, i32 noundef 10) #10
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call ptr @strtok(ptr noundef %17, ptr noundef @.str) #9
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = call ptr @strtok(ptr noundef null, ptr noundef @.str) #9
  store ptr %19, ptr %8, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %87, %2
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ult ptr %21, %22
  br i1 %23, label %24, label %27

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

27:                                               ; preds = %24, %20
  %28 = phi i1 [ false, %20 ], [ %26, %24 ]
  br i1 %28, label %29, label %89

29:                                               ; preds = %27
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %30, ptr %10, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %71, %29
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %74

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = sext i8 %38 to i32
  %40 = call i1 @llvm.is.constant.i32(i32 %39)
  br i1 %40, label %41, label %61

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load i8, ptr %42, align 1, !tbaa !11
  %44 = sext i8 %43 to i32
  store i32 %44, ptr %12, align 4, !tbaa !9
  %45 = load i32, ptr %12, align 4, !tbaa !9
  %46 = icmp slt i32 %45, -128
  br i1 %46, label %50, label %47

47:                                               ; preds = %41
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = icmp sgt i32 %48, 255
  br i1 %49, label %50, label %52

50:                                               ; preds = %47, %41
  %51 = load i32, ptr %12, align 4, !tbaa !9
  br label %59

52:                                               ; preds = %47
  %53 = call ptr @__ctype_toupper_loc() #11
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %54, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %52, %50
  %60 = phi i32 [ %51, %50 ], [ %58, %52 ]
  store i32 %60, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  br label %66

61:                                               ; preds = %36
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load i8, ptr %62, align 1, !tbaa !11
  %64 = sext i8 %63 to i32
  %65 = call i32 @toupper(i32 noundef %64) #10
  store i32 %65, ptr %11, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %61, %59
  %67 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %67, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = trunc i32 %68 to i8
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  store i8 %69, ptr %70, align 1, !tbaa !11
  br label %71

71:                                               ; preds = %66
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i32 1
  store ptr %73, ptr %10, align 8, !tbaa !5
  br label %31, !llvm.loop !12

74:                                               ; preds = %31
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = call i32 @strncmp(ptr noundef %75, ptr noundef @.str.1, i64 noundef 4) #10
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %87

78:                                               ; preds = %74
  %79 = call ptr @strtok(ptr noundef null, ptr noundef @.str) #9
  store ptr %79, ptr %8, align 8, !tbaa !5
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %86

82:                                               ; preds = %78
  %83 = getelementptr inbounds [61 x i8], ptr %5, i64 0, i64 0
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = call ptr @strcpy(ptr noundef %83, ptr noundef %84) #9
  br label %86

86:                                               ; preds = %82, %78
  br label %87

87:                                               ; preds = %86, %74
  %88 = call ptr @strtok(ptr noundef null, ptr noundef @.str) #9
  store ptr %88, ptr %8, align 8, !tbaa !5
  br label %20, !llvm.loop !14

89:                                               ; preds = %27
  %90 = getelementptr inbounds [61 x i8], ptr %5, i64 0, i64 0
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = call i32 @prs_cmdfil(ptr noundef %90, ptr noundef %91, ptr noundef %92)
  store i32 %93, ptr %7, align 4, !tbaa !9
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = icmp eq i32 %94, 0
  br i1 %95, label %96, label %99

96:                                               ; preds = %89
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !9
  call void @apnd_stat_cw(ptr noundef %97, i32 noundef %98, ptr noundef @p_cmdfil_c.rname)
  br label %99

99:                                               ; preds = %96, %89
  %100 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 133, ptr %6) #9
  call void @llvm.lifetime.end.p0(i64 61, ptr %5) #9
  ret i32 %100
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare ptr @strtok(ptr noundef, ptr noundef) #4

; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
declare i1 @llvm.is.constant.i32(i32) #5

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() #6

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @toupper(i32 noundef) #7

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

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @prs_cmdfil(ptr noundef, ptr noundef, ptr noundef) #0

declare void @apnd_stat_cw(ptr noundef, i32 noundef, ptr noundef) #8

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { nounwind willreturn memory(none) "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 #7 = { 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 #8 = { "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 #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { nounwind willreturn memory(none) }

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


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

@p_cmdfil_c.rname = external hidden global [16 x i8], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @p_cmdfil_c(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca [61 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 61, ptr nonnull %3) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(61) %3, i8 0, i64 61, i1 false)
  %4 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %0, i32 noundef 10) #9
  %5 = tail call ptr @strtok(ptr noundef %0, ptr noundef nonnull @.str) #8
  %6 = tail call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str) #8
  %7 = icmp ult ptr %6, %4
  %8 = icmp ne ptr %6, null
  %9 = and i1 %7, %8
  br i1 %9, label %.preheader, label %._crit_edge36

.preheader:                                       ; preds = %2, %23
  %.035 = phi ptr [ %24, %23 ], [ %6, %2 ]
  %10 = load i8, ptr %.035, align 1, !tbaa !5
  %.not33 = icmp eq i8 %10, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %11 = phi i8 [ %16, %.lr.ph ], [ %10, %.preheader ]
  %.02834 = phi ptr [ %15, %.lr.ph ], [ %.035, %.preheader ]
  %12 = sext i8 %11 to i32
  %13 = call i32 @toupper(i32 noundef %12) #9
  %14 = trunc i32 %13 to i8
  store i8 %14, ptr %.02834, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.02834, i64 1
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not = icmp eq i8 %16, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %17 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %.035, ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef 4) #9
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %._crit_edge
  %20 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str) #8
  %.not32 = icmp eq ptr %20, null
  br i1 %.not32, label %23, label %21

21:                                               ; preds = %19
  %22 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %20) #8
  br label %23

23:                                               ; preds = %19, %21, %._crit_edge
  %24 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str) #8
  %25 = icmp ult ptr %24, %4
  %26 = icmp ne ptr %24, null
  %27 = and i1 %25, %26
  br i1 %27, label %.preheader, label %._crit_edge36, !llvm.loop !10

._crit_edge36:                                    ; preds = %23, %2
  %28 = call i32 @prs_cmdfil(ptr noundef nonnull %3, ptr noundef %0, ptr noundef %1)
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %._crit_edge36
  call void @apnd_stat_cw(ptr noundef %1, i32 noundef 0, ptr noundef nonnull @p_cmdfil_c.rname) #8
  br label %31

31:                                               ; preds = %30, %._crit_edge36
  call void @llvm.lifetime.end.p0(i64 61, ptr nonnull %3) #8
  ret i32 %28
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn
declare ptr @strtok(ptr noundef, ptr nocapture noundef readonly) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @toupper(i32 noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local i32 @prs_cmdfil(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @apnd_stat_cw(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #7

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { mustprogress nofree nounwind willreturn "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 = { 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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #7 = { "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 #8 = { nounwind }
attributes #9 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerConstantIntrinsicsPass,SROAPass,SimplifyCFGPass,TailCallElimPass