; LLVM IR from ihucos/plash :: mount (validate_changesdir)

; 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.11 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [47 x i8], align 1

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

declare i32 @pl_fatal(ptr noundef, ...) #1

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

7:                                                ; preds = %46, %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %8, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = icmp ne i8 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %7
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %49

14:                                               ; preds = %7
  store i32 0, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %32, %14
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = icmp ugt i64 66, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %35

19:                                               ; preds = %15
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = sext i8 %23 to i32
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = getelementptr inbounds [67 x i8], ptr @.str.11, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = sext i8 %27 to i32
  %29 = icmp eq i32 %24, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %19
  store i32 1, ptr %3, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %30, %19
  br label %32

32:                                               ; preds = %31
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %6, align 8, !tbaa !9
  br label %15, !llvm.loop !14

35:                                               ; preds = %18
  %36 = load i32, ptr %3, align 4, !tbaa !12
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %45, label %38

38:                                               ; preds = %35
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = load i64, ptr %4, align 8, !tbaa !9
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = sext i8 %42 to i32
  %44 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.12, i32 noundef %43)
  br label %45

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

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

49:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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.11 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [47 x i8], align 1

declare i32 @pl_fatal(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @validate_changesdir(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %.not15 = icmp eq i8 %2, 0
  br i1 %.not15, label %._crit_edge, label %.preheader.preheader

.preheader.preheader:                             ; preds = %1
  %3 = load i8, ptr @.str.11, align 1, !tbaa !5
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @.str.11, i64 1), align 1, !tbaa !5
  %5 = load <64 x i8>, ptr getelementptr inbounds (i8, ptr @.str.11, i64 2), align 1, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %18
  %6 = phi i8 [ %21, %18 ], [ %2, %.preheader.preheader ]
  %.01016 = phi i64 [ %19, %18 ], [ 0, %.preheader.preheader ]
  %7 = icmp ne i8 %6, %3
  %8 = icmp ne i8 %6, %4
  %9 = insertelement <64 x i8> poison, i8 %6, i64 0
  %10 = shufflevector <64 x i8> %9, <64 x i8> poison, <64 x i32> zeroinitializer
  %11 = icmp ne <64 x i8> %10, %5
  %12 = freeze <64 x i1> %11
  %13 = bitcast <64 x i1> %12 to i64
  %14 = icmp eq i64 %13, -1
  %.fr = freeze i1 %8
  %op.rdx = and i1 %14, %.fr
  %op.rdx67 = select i1 %op.rdx, i1 %7, i1 false
  br i1 %op.rdx67, label %15, label %18

._crit_edge:                                      ; preds = %18, %1
  ret void

15:                                               ; preds = %.preheader
  %16 = sext i8 %6 to i32
  %17 = tail call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.12, i32 noundef %16) #2
  br label %18

18:                                               ; preds = %.preheader, %15
  %19 = add i64 %.01016, 1
  %20 = getelementptr inbounds i8, ptr %0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %.not = icmp eq i8 %21, 0
  br i1 %.not, label %._crit_edge, label %.preheader, !llvm.loop !8
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass