; LLVM IR from blat-blatnik/GPU-Life :: main (findFilePartOfPath)

; 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 void @findFilePartOfPath(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 0, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  store i64 0, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %47, %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = sext i8 %15 to i32
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %50

18:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %19, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  store i8 %22, ptr %8, align 1, !tbaa !11
  %23 = load i8, ptr %8, align 1, !tbaa !11
  %24 = sext i8 %23 to i32
  %25 = icmp eq i32 %24, 47
  br i1 %25, label %34, label %26

26:                                               ; preds = %18
  %27 = load i8, ptr %8, align 1, !tbaa !11
  %28 = sext i8 %27 to i32
  %29 = icmp eq i32 %28, 92
  br i1 %29, label %34, label %30

30:                                               ; preds = %26
  %31 = load i8, ptr %8, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 58
  br i1 %33, label %34, label %38

34:                                               ; preds = %30, %26, %18
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = add i64 %35, 1
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %36, ptr %37, align 8, !tbaa !9
  br label %46

38:                                               ; preds = %30
  %39 = load i8, ptr %8, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 46
  br i1 %41, label %42, label %45

42:                                               ; preds = %38
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  store i64 %43, ptr %44, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %42, %38
  br label %46

46:                                               ; preds = %45, %34
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %7, align 8, !tbaa !9
  %49 = add i64 %48, 1
  store i64 %49, ptr %7, align 8, !tbaa !9
  br label %11, !llvm.loop !12

50:                                               ; preds = %11
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp eq i64 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %50
  %55 = load i64, ptr %7, align 8, !tbaa !9
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  store i64 %55, ptr %56, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %54, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

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 }

!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", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @findFilePartOfPath(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  store i64 0, ptr %1, align 8, !tbaa !5
  store i64 0, ptr %2, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %10, %3
  %.0 = phi i64 [ 0, %3 ], [ %11, %10 ]
  %5 = getelementptr inbounds i8, ptr %0, i64 %.0
  %6 = load i8, ptr %5, align 1, !tbaa !9
  switch i8 %6, label %10 [
    i8 0, label %12
    i8 92, label %7
    i8 58, label %7
    i8 47, label %7
    i8 46, label %9
  ]

7:                                                ; preds = %4, %4, %4
  %8 = add i64 %.0, 1
  store i64 %8, ptr %1, align 8, !tbaa !5
  br label %10

9:                                                ; preds = %4
  store i64 %.0, ptr %2, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %4, %9, %7
  %11 = add i64 %.0, 1
  br label %4, !llvm.loop !10

12:                                               ; preds = %4
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store i64 %.0, ptr %2, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %12
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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" }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass