; LLVM IR from likle/cwalk :: test (relative_test)

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

@__const.relative_check.relative_paths = external hidden unnamed_addr constant [6 x ptr], align 16
@__const.relative_check.absolute_paths = external hidden unnamed_addr constant [6 x ptr], align 16

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

declare void @cwk_path_set_style(i32 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 i32 @relative_check() #2 {
  %1 = alloca i32, align 4
  %2 = alloca [6 x ptr], align 16
  %3 = alloca [6 x ptr], align 16
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 48, ptr %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.relative_check.relative_paths, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.relative_check.absolute_paths, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @cwk_path_set_style(i32 noundef 1)
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %16, %0
  %7 = load i64, ptr %4, align 8, !tbaa !5
  %8 = icmp ult i64 %7, 6
  br i1 %8, label %9, label %19

9:                                                ; preds = %6
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds [6 x ptr], ptr %2, i64 0, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = call zeroext i1 @cwk_path_is_relative(ptr noundef %12)
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  store i32 1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %34

15:                                               ; preds = %9
  br label %16

16:                                               ; preds = %15
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = add i64 %17, 1
  store i64 %18, ptr %4, align 8, !tbaa !5
  br label %6, !llvm.loop !11

19:                                               ; preds = %6
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %30, %19
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = icmp ult i64 %21, 6
  br i1 %22, label %23, label %33

23:                                               ; preds = %20
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds [6 x ptr], ptr %3, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = call zeroext i1 @cwk_path_is_relative(ptr noundef %26)
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  store i32 1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %34

29:                                               ; preds = %23
  br label %30

30:                                               ; preds = %29
  %31 = load i64, ptr %4, align 8, !tbaa !5
  %32 = add i64 %31, 1
  store i64 %32, ptr %4, align 8, !tbaa !5
  br label %20, !llvm.loop !13

33:                                               ; preds = %20
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %34

34:                                               ; preds = %33, %28, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %2) #4
  %35 = load i32, ptr %1, align 4
  ret i32 %35
}

; 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) #3

declare zeroext i1 @cwk_path_is_relative(ptr noundef) #1

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


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

@__const.relative_check.relative_paths = external hidden unnamed_addr constant [6 x ptr], align 16
@__const.relative_check.absolute_paths = external hidden unnamed_addr constant [6 x ptr], align 16

declare void @cwk_path_set_style(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @relative_check() local_unnamed_addr #1 {
  tail call void @cwk_path_set_style(i32 noundef 1) #2
  %1 = load ptr, ptr @__const.relative_check.relative_paths, align 16, !tbaa !5
  %2 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %1) #2
  br i1 %2, label %3, label %.loopexit

3:                                                ; preds = %0
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.relative_paths, i64 8), align 8, !tbaa !5
  %5 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %4) #2
  br i1 %5, label %6, label %.loopexit

6:                                                ; preds = %3
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.relative_paths, i64 16), align 16, !tbaa !5
  %8 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %7) #2
  br i1 %8, label %9, label %.loopexit

9:                                                ; preds = %6
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.relative_paths, i64 24), align 8, !tbaa !5
  %11 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %10) #2
  br i1 %11, label %12, label %.loopexit

12:                                               ; preds = %9
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.relative_paths, i64 32), align 16, !tbaa !5
  %14 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %13) #2
  br i1 %14, label %15, label %.loopexit

15:                                               ; preds = %12
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.relative_paths, i64 40), align 8, !tbaa !5
  %17 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %16) #2
  br i1 %17, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %15
  %18 = load ptr, ptr @__const.relative_check.absolute_paths, align 16, !tbaa !5
  %19 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %18) #2
  br i1 %19, label %.loopexit, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.absolute_paths, i64 8), align 8, !tbaa !5
  %21 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %20) #2
  br i1 %21, label %.loopexit, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.absolute_paths, i64 16), align 16, !tbaa !5
  %23 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %22) #2
  br i1 %23, label %.loopexit, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.absolute_paths, i64 24), align 8, !tbaa !5
  %25 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %24) #2
  br i1 %25, label %.loopexit, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %26 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.absolute_paths, i64 32), align 16, !tbaa !5
  %27 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %26) #2
  br i1 %27, label %.loopexit, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.relative_check.absolute_paths, i64 40), align 8, !tbaa !5
  %29 = tail call zeroext i1 @cwk_path_is_relative(ptr noundef %28) #2
  %spec.select = zext i1 %29 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.5, %0, %3, %6, %9, %12, %15, %.preheader.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4
  %.07 = phi i32 [ 1, %.preheader.preheader ], [ 1, %.preheader.1 ], [ 1, %.preheader.2 ], [ 1, %.preheader.3 ], [ 1, %.preheader.4 ], [ 1, %15 ], [ 1, %12 ], [ 1, %9 ], [ 1, %6 ], [ 1, %3 ], [ 1, %0 ], [ %spec.select, %.preheader.5 ]
  ret i32 %.07
}

declare zeroext i1 @cwk_path_is_relative(ptr noundef) local_unnamed_addr #0

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass