; LLVM IR from stivalaa/EstimNetDirected :: src/Random123-1.09/examples (kat_c)

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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @nameclean(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %7, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i64 @strlen(ptr noundef %9) #5
  %11 = getelementptr inbounds i8, ptr %8, i64 %10
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %12, ptr %4, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %17, %1
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call ptr @strstr(ptr noundef %14, ptr noundef @.str) #5
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %24

17:                                               ; preds = %13
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i32 1
  store ptr %19, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %18, align 1, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i32 1
  store ptr %21, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %20, align 1, !tbaa !9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i32 1
  store ptr %23, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %22, align 1, !tbaa !9
  br label %13, !llvm.loop !10

24:                                               ; preds = %13
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %25, ptr %4, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %30, %24
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call ptr @strstr(ptr noundef %27, ptr noundef @.str.1) #5
  store ptr %28, ptr %4, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %37

30:                                               ; preds = %26
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %31, i32 1
  store ptr %32, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %31, align 1, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i32 1
  store ptr %34, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %33, align 1, !tbaa !9
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i32 1
  store ptr %36, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %35, align 1, !tbaa !9
  br label %26, !llvm.loop !12

37:                                               ; preds = %26
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %38, ptr %4, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %43, %37
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = call ptr @strchr(ptr noundef %40, i32 noundef 64) #5
  store ptr %41, ptr %4, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %46

43:                                               ; preds = %39
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %44, align 1, !tbaa !9
  br label %39, !llvm.loop !13

46:                                               ; preds = %39
  br label %47

47:                                               ; preds = %85, %46
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = call i64 @strcspn(ptr noundef %48, ptr noundef @.str.2) #5
  store i64 %49, ptr %6, align 8, !tbaa !14
  %50 = icmp ugt i64 %49, 0
  br i1 %50, label %51, label %86

51:                                               ; preds = %47
  %52 = load i64, ptr %6, align 8, !tbaa !14
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 %52
  store ptr %54, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = call i64 @strspn(ptr noundef %55, ptr noundef @.str.2) #5
  store i64 %56, ptr %6, align 8, !tbaa !14
  %57 = load i64, ptr %6, align 8, !tbaa !14
  %58 = icmp ugt i64 %57, 0
  br i1 %58, label %59, label %85

59:                                               ; preds = %51
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i64, ptr %6, align 8, !tbaa !14
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  store ptr %62, ptr %4, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i32 1
  store ptr %64, ptr %3, align 8, !tbaa !5
  store i8 32, ptr %63, align 1, !tbaa !9
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = icmp ugt ptr %65, %66
  br i1 %67, label %68, label %84

68:                                               ; preds = %59
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = ptrtoint ptr %71 to i64
  %74 = ptrtoint ptr %72 to i64
  %75 = sub i64 %73, %74
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %69, ptr align 1 %70, i64 %75, i1 false)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = ptrtoint ptr %76 to i64
  %79 = ptrtoint ptr %77 to i64
  %80 = sub i64 %78, %79
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = sub i64 0, %80
  %83 = getelementptr inbounds i8, ptr %81, i64 %82
  store ptr %83, ptr %5, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %68, %59
  br label %85

85:                                               ; preds = %84, %51
  br label %47, !llvm.loop !16

86:                                               ; preds = %47
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %87
}

; 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 i64 @strlen(ptr noundef) #2

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

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

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

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

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

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

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


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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef ptr @nameclean(ptr noundef returned %0) local_unnamed_addr #0 {
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 %2
  %4 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str) #3
  %.not51 = icmp eq ptr %4, null
  br i1 %.not51, label %.preheader50, label %.lr.ph

.preheader50:                                     ; preds = %.lr.ph, %1
  %5 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str.1) #3
  %.not4552 = icmp eq ptr %5, null
  br i1 %.not4552, label %.preheader49, label %.lr.ph53

.lr.ph:                                           ; preds = %1, %.lr.ph
  %6 = phi ptr [ %10, %.lr.ph ], [ %4, %1 ]
  %7 = getelementptr inbounds i8, ptr %6, i64 1
  store i8 32, ptr %6, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %6, i64 2
  store i8 32, ptr %7, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %6, i64 3
  store i8 32, ptr %8, align 1, !tbaa !5
  %10 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str) #3
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %.preheader50, label %.lr.ph, !llvm.loop !8

.preheader49:                                     ; preds = %.lr.ph53, %.preheader50
  %11 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %0, i32 noundef 64) #3
  %.not4654 = icmp eq ptr %11, null
  br i1 %.not4654, label %.preheader, label %.lr.ph55

.lr.ph53:                                         ; preds = %.preheader50, %.lr.ph53
  %12 = phi ptr [ %16, %.lr.ph53 ], [ %5, %.preheader50 ]
  %13 = getelementptr inbounds i8, ptr %12, i64 1
  store i8 32, ptr %12, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %12, i64 2
  store i8 32, ptr %13, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %12, i64 3
  store i8 32, ptr %14, align 1, !tbaa !5
  %16 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %15, ptr noundef nonnull dereferenceable(1) @.str.1) #3
  %.not45 = icmp eq ptr %16, null
  br i1 %.not45, label %.preheader49, label %.lr.ph53, !llvm.loop !10

.preheader:                                       ; preds = %.lr.ph55, %.preheader49
  %17 = tail call i64 @strcspn(ptr noundef %0, ptr noundef nonnull @.str.2) #3
  %.not4756 = icmp eq i64 %17, 0
  br i1 %.not4756, label %._crit_edge, label %.lr.ph59

.lr.ph55:                                         ; preds = %.preheader49, %.lr.ph55
  %18 = phi ptr [ %20, %.lr.ph55 ], [ %11, %.preheader49 ]
  %19 = getelementptr inbounds i8, ptr %18, i64 1
  store i8 32, ptr %18, align 1, !tbaa !5
  %20 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %19, i32 noundef 64) #3
  %.not46 = icmp eq ptr %20, null
  br i1 %.not46, label %.preheader, label %.lr.ph55, !llvm.loop !11

.lr.ph59:                                         ; preds = %.preheader, %34
  %21 = phi i64 [ %35, %34 ], [ %17, %.preheader ]
  %.058 = phi ptr [ %.1, %34 ], [ %3, %.preheader ]
  %.03557 = phi ptr [ %.136, %34 ], [ %0, %.preheader ]
  %22 = getelementptr inbounds i8, ptr %.03557, i64 %21
  %23 = tail call i64 @strspn(ptr noundef nonnull %22, ptr noundef nonnull @.str.2) #3
  %.not48 = icmp eq i64 %23, 0
  br i1 %.not48, label %34, label %24

24:                                               ; preds = %.lr.ph59
  %25 = getelementptr inbounds i8, ptr %22, i64 1
  store i8 32, ptr %22, align 1, !tbaa !5
  %26 = icmp sgt i64 %23, 1
  br i1 %26, label %27, label %34

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %22, i64 %23
  %29 = ptrtoint ptr %.058 to i64
  %30 = ptrtoint ptr %25 to i64
  %31 = sub i64 %29, %30
  tail call void @llvm.memmove.p0.p0.i64(ptr nonnull align 1 %25, ptr nonnull align 1 %28, i64 %31, i1 false)
  %32 = sub nsw i64 1, %23
  %33 = getelementptr inbounds i8, ptr %.058, i64 %32
  br label %34

34:                                               ; preds = %24, %27, %.lr.ph59
  %.136 = phi ptr [ %25, %27 ], [ %25, %24 ], [ %22, %.lr.ph59 ]
  %.1 = phi ptr [ %33, %27 ], [ %.058, %24 ], [ %.058, %.lr.ph59 ]
  %35 = tail call i64 @strcspn(ptr noundef %.136, ptr noundef nonnull @.str.2) #3
  %.not47 = icmp eq i64 %35, 0
  br i1 %.not47, label %._crit_edge, label %.lr.ph59, !llvm.loop !12

._crit_edge:                                      ; preds = %34, %.preheader
  ret ptr %0
}

; 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 memory(argmem: read)
declare ptr @strstr(ptr noundef, ptr nocapture noundef) local_unnamed_addr #1

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

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

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

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

attributes #0 = { nofree nounwind memory(readwrite, inaccessiblemem: none) 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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}
!11 = distinct !{!11, !9}
!12 = distinct !{!12, !9}


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