; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (stringop)

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

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

13:                                               ; preds = %31, %4
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load i64, ptr %10, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %14, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !11
  store i8 %17, ptr %9, align 1, !tbaa !11
  %18 = icmp ne i8 %17, 0
  br i1 %18, label %19, label %34

19:                                               ; preds = %13
  %20 = load i8, ptr %9, align 1, !tbaa !11
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 92
  br i1 %22, label %27, label %23

23:                                               ; preds = %19
  %24 = load i8, ptr %9, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 47
  br i1 %26, label %27, label %30

27:                                               ; preds = %23, %19
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = add i64 %28, 1
  store i64 %29, ptr %11, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %27, %23
  br label %31

31:                                               ; preds = %30
  %32 = load i64, ptr %10, align 8, !tbaa !9
  %33 = add i64 %32, 1
  store i64 %33, ptr %10, align 8, !tbaa !9
  br label %13, !llvm.loop !12

34:                                               ; preds = %13
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call i64 @strlen(ptr noundef %35) #4
  store i64 %36, ptr %12, align 8, !tbaa !9
  %37 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %37, ptr %10, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %59, %34
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = load i64, ptr %11, align 8, !tbaa !9
  %41 = icmp ugt i64 %39, %40
  br i1 %41, label %42, label %62

42:                                               ; preds = %38
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = sub i64 %44, 1
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = icmp eq i32 %48, 46
  br i1 %49, label %50, label %58

50:                                               ; preds = %42
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = icmp ugt i64 %51, 0
  br i1 %52, label %53, label %58

53:                                               ; preds = %50
  %54 = load i64, ptr %8, align 8, !tbaa !9
  %55 = add i64 %54, -1
  store i64 %55, ptr %8, align 8, !tbaa !9
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = sub i64 %56, 1
  store i64 %57, ptr %12, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %53, %50, %42
  br label %59

59:                                               ; preds = %58
  %60 = load i64, ptr %10, align 8, !tbaa !9
  %61 = add i64 %60, -1
  store i64 %61, ptr %10, align 8, !tbaa !9
  br label %38, !llvm.loop !14

62:                                               ; preds = %38
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load i64, ptr %11, align 8, !tbaa !9
  %67 = getelementptr inbounds i8, ptr %65, i64 %66
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load i64, ptr %12, align 8, !tbaa !9
  %70 = getelementptr inbounds i8, ptr %68, i64 %69
  %71 = call i64 @vl_string_copy_sub(ptr noundef %63, i64 noundef %64, ptr noundef %67, ptr noundef %70)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  ret i64 %71
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !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"

; Function Attrs: nounwind uwtable
define dso_local i64 @vl_string_basename(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  br label %.outer

.outer:                                           ; preds = %8, %4
  %.025.ph = phi i64 [ %9, %8 ], [ 0, %4 ]
  br label %5

5:                                                ; preds = %.outer, %._crit_edge36
  %.027 = phi i64 [ %.pre, %._crit_edge36 ], [ %.025.ph, %.outer ]
  %6 = getelementptr inbounds i8, ptr %2, i64 %.027
  %7 = load i8, ptr %6, align 1, !tbaa !5
  switch i8 %7, label %._crit_edge36 [
    i8 0, label %10
    i8 92, label %8
    i8 47, label %8
  ]

._crit_edge36:                                    ; preds = %5
  %.pre = add i64 %.027, 1
  br label %5, !llvm.loop !8

8:                                                ; preds = %5, %5
  %9 = add i64 %.027, 1
  br label %.outer, !llvm.loop !8

10:                                               ; preds = %5
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #2
  %12 = icmp ugt i64 %11, %.025.ph
  br i1 %12, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %10
  %13 = sub i64 %11, %.025.ph
  %.neg = add i64 %.025.ph, 1
  %xtraiter = and i64 %13, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %14 = add i64 %11, -1
  %15 = getelementptr inbounds i8, ptr %2, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = icmp eq i8 %16, 46
  %18 = icmp ne i64 %3, 0
  %or.cond4.prol = and i1 %17, %18
  %19 = sext i1 %or.cond4.prol to i64
  %spec.select.prol = add i64 %19, %3
  %spec.select32.prol = select i1 %or.cond4.prol, i64 %14, i64 %11
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.035.unr = phi i64 [ %11, %.lr.ph.preheader ], [ %spec.select32.prol, %.lr.ph.prol ]
  %.12834.unr = phi i64 [ %11, %.lr.ph.preheader ], [ %14, %.lr.ph.prol ]
  %.02933.unr = phi i64 [ %3, %.lr.ph.preheader ], [ %spec.select.prol, %.lr.ph.prol ]
  %spec.select32.lcssa.unr = phi i64 [ poison, %.lr.ph.preheader ], [ %spec.select32.prol, %.lr.ph.prol ]
  %20 = icmp eq i64 %11, %.neg
  br i1 %20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.035 = phi i64 [ %spec.select32.1, %.lr.ph ], [ %.035.unr, %.lr.ph.prol.loopexit ]
  %.12834 = phi i64 [ %27, %.lr.ph ], [ %.12834.unr, %.lr.ph.prol.loopexit ]
  %.02933 = phi i64 [ %spec.select.1, %.lr.ph ], [ %.02933.unr, %.lr.ph.prol.loopexit ]
  %21 = add i64 %.12834, -1
  %22 = getelementptr inbounds i8, ptr %2, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = icmp eq i8 %23, 46
  %25 = icmp ne i64 %.02933, 0
  %or.cond4 = select i1 %24, i1 %25, i1 false
  %26 = sext i1 %or.cond4 to i64
  %spec.select = add i64 %.02933, %26
  %spec.select32 = select i1 %or.cond4, i64 %21, i64 %.035
  %27 = add i64 %.12834, -2
  %28 = getelementptr inbounds i8, ptr %2, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %30 = icmp eq i8 %29, 46
  %31 = icmp ne i64 %spec.select, 0
  %or.cond4.1 = select i1 %30, i1 %31, i1 false
  %32 = sext i1 %or.cond4.1 to i64
  %spec.select.1 = add i64 %spec.select, %32
  %spec.select32.1 = select i1 %or.cond4.1, i64 %27, i64 %spec.select32
  %33 = icmp ugt i64 %27, %.025.ph
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %10
  %.0.lcssa = phi i64 [ %11, %10 ], [ %spec.select32.lcssa.unr, %.lr.ph.prol.loopexit ], [ %spec.select32.1, %.lr.ph ]
  %34 = getelementptr inbounds i8, ptr %2, i64 %.025.ph
  %35 = getelementptr inbounds i8, ptr %2, i64 %.0.lcssa
  %36 = tail call i64 @vl_string_copy_sub(ptr noundef %0, i64 noundef %1, ptr noundef %34, ptr noundef %35)
  ret i64 %36
}

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

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

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 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 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,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass