; LLVM IR from bjourne/fast_snn_fpga :: src (paths)

; 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 ptr @paths_normalize(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  %9 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call i64 @strlen(ptr noundef %10) #7
  store i64 %11, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %12 = load i64, ptr %3, align 8, !tbaa !9
  %13 = add i64 %12, 2
  %14 = call noalias ptr @malloc(i64 noundef %13) #8
  store ptr %14, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %15 = load i64, ptr %3, align 8, !tbaa !9
  %16 = call noalias ptr @malloc(i64 noundef %15) #8
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #6
  store i8 1, ptr %8, align 1, !tbaa !11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 0
  %19 = load i8, ptr %18, align 1, !tbaa !13
  %20 = sext i8 %19 to i32
  %21 = icmp eq i32 %20, 47
  br i1 %21, label %22, label %27

22:                                               ; preds = %1
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 0
  store i8 47, ptr %24, align 1, !tbaa !13
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = add i64 %25, 1
  store i64 %26, ptr %6, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %22, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %86, %27
  %29 = load i64, ptr %9, align 8, !tbaa !9
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = icmp ule i64 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %89

33:                                               ; preds = %28
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = load i64, ptr %3, align 8, !tbaa !9
  %36 = icmp eq i64 %34, %35
  br i1 %36, label %44, label %37

37:                                               ; preds = %33
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = load i64, ptr %9, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %38, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !13
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, 47
  br i1 %43, label %44, label %75

44:                                               ; preds = %37, %33
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = icmp ugt i64 %45, 0
  br i1 %46, label %47, label %74

47:                                               ; preds = %44
  %48 = load i64, ptr %7, align 8, !tbaa !9
  %49 = icmp eq i64 %48, 1
  br i1 %49, label %50, label %56

50:                                               ; preds = %47
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 0
  %53 = load i8, ptr %52, align 1, !tbaa !13
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 46
  br i1 %55, label %74, label %56

56:                                               ; preds = %50, %47
  %57 = load i8, ptr %8, align 1, !tbaa !11, !range !14, !noundef !15
  %58 = trunc i8 %57 to i1
  br i1 %58, label %65, label %59

59:                                               ; preds = %56
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load i64, ptr %6, align 8, !tbaa !9
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  store i8 47, ptr %62, align 1, !tbaa !13
  %63 = load i64, ptr %6, align 8, !tbaa !9
  %64 = add i64 %63, 1
  store i64 %64, ptr %6, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %59, %56
  store i8 0, ptr %8, align 1, !tbaa !11
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load i64, ptr %6, align 8, !tbaa !9
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %68, ptr align 1 %69, i64 %70, i1 false)
  %71 = load i64, ptr %7, align 8, !tbaa !9
  %72 = load i64, ptr %6, align 8, !tbaa !9
  %73 = add i64 %72, %71
  store i64 %73, ptr %6, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %65, %50, %44
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %85

75:                                               ; preds = %37
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = load i64, ptr %9, align 8, !tbaa !9
  %78 = getelementptr inbounds i8, ptr %76, i64 %77
  %79 = load i8, ptr %78, align 1, !tbaa !13
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load i64, ptr %7, align 8, !tbaa !9
  %82 = getelementptr inbounds i8, ptr %80, i64 %81
  store i8 %79, ptr %82, align 1, !tbaa !13
  %83 = load i64, ptr %7, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %7, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %75, %74
  br label %86

86:                                               ; preds = %85
  %87 = load i64, ptr %9, align 8, !tbaa !9
  %88 = add i64 %87, 1
  store i64 %88, ptr %9, align 8, !tbaa !9
  br label %28, !llvm.loop !16

89:                                               ; preds = %32
  %90 = load i64, ptr %6, align 8, !tbaa !9
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %98, label %92

92:                                               ; preds = %89
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = load i64, ptr %6, align 8, !tbaa !9
  %95 = getelementptr inbounds i8, ptr %93, i64 %94
  store i8 46, ptr %95, align 1, !tbaa !13
  %96 = load i64, ptr %6, align 8, !tbaa !9
  %97 = add i64 %96, 1
  store i64 %97, ptr %6, align 8, !tbaa !9
  br label %98

98:                                               ; preds = %92, %89
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = load i64, ptr %6, align 8, !tbaa !9
  %101 = getelementptr inbounds i8, ptr %99, i64 %100
  store i8 0, ptr %101, align 1, !tbaa !13
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %102) #6
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret ptr %103
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

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 allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"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: nounwind memory(readwrite, argmem: read) uwtable
define dso_local noalias noundef ptr @paths_normalize(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #5
  %3 = add i64 %2, 2
  %4 = tail call noalias ptr @malloc(i64 noundef %3) #6
  %5 = tail call noalias ptr @malloc(i64 noundef %2) #6
  %6 = load i8, ptr %0, align 1, !tbaa !5
  %7 = icmp eq i8 %6, 47
  br i1 %7, label %8, label %.preheader

.preheader:                                       ; preds = %8, %1
  %.14247.ph = phi i64 [ 0, %1 ], [ 1, %8 ]
  br label %10

8:                                                ; preds = %1
  store i8 47, ptr %4, align 1, !tbaa !5
  br label %.preheader

9:                                                ; preds = %30
  %.not45 = icmp eq i64 %.4, 0
  br i1 %.not45, label %32, label %33

10:                                               ; preds = %.preheader, %30
  %.050 = phi i64 [ %31, %30 ], [ 0, %.preheader ]
  %.03849 = phi i1 [ %.2, %30 ], [ true, %.preheader ]
  %.03948 = phi i64 [ %.140, %30 ], [ 0, %.preheader ]
  %.14247 = phi i64 [ %.4, %30 ], [ %.14247.ph, %.preheader ]
  %11 = icmp eq i64 %.050, %2
  br i1 %11, label %16, label %12

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 %.050
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = icmp eq i8 %14, 47
  br i1 %15, label %16, label %27

16:                                               ; preds = %12, %10
  switch i64 %.03948, label %20 [
    i64 0, label %30
    i64 1, label %17
  ]

17:                                               ; preds = %16
  %18 = load i8, ptr %5, align 1, !tbaa !5
  %19 = icmp eq i8 %18, 46
  br i1 %19, label %30, label %20

20:                                               ; preds = %16, %17
  br i1 %.03849, label %24, label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds i8, ptr %4, i64 %.14247
  store i8 47, ptr %22, align 1, !tbaa !5
  %23 = add i64 %.14247, 1
  br label %24

24:                                               ; preds = %21, %20
  %.243 = phi i64 [ %.14247, %20 ], [ %23, %21 ]
  %25 = getelementptr inbounds i8, ptr %4, i64 %.243
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %25, ptr align 1 %5, i64 %.03948, i1 false)
  %26 = add i64 %.243, %.03948
  br label %30

27:                                               ; preds = %12
  %28 = getelementptr inbounds i8, ptr %5, i64 %.03948
  store i8 %14, ptr %28, align 1, !tbaa !5
  %29 = add i64 %.03948, 1
  br label %30

30:                                               ; preds = %17, %24, %16, %27
  %.4 = phi i64 [ %.14247, %27 ], [ %.14247, %17 ], [ %26, %24 ], [ %.14247, %16 ]
  %.140 = phi i64 [ %29, %27 ], [ 0, %17 ], [ 0, %24 ], [ %.03948, %16 ]
  %.2 = phi i1 [ %.03849, %27 ], [ %.03849, %17 ], [ false, %24 ], [ %.03849, %16 ]
  %31 = add i64 %.050, 1
  %.not = icmp ugt i64 %31, %2
  br i1 %.not, label %9, label %10, !llvm.loop !8

32:                                               ; preds = %9
  store i8 46, ptr %4, align 1, !tbaa !5
  br label %33

33:                                               ; preds = %32, %9
  %.5 = phi i64 [ %.4, %9 ], [ 1, %32 ]
  %34 = getelementptr inbounds i8, ptr %4, i64 %.5
  store i8 0, ptr %34, align 1, !tbaa !5
  tail call void @free(ptr noundef %5) #7
  ret ptr %4
}

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { nounwind memory(readwrite, argmem: 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 #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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind willreturn memory(read) }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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"}


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