; LLVM IR from narke/Aragveli :: src/extra/test-suite (tarfs-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"

%struct.node = type { i8, i8, [50 x i8], %union.anon, %struct.anon.0 }
%union.anon = type { %struct.folder }
%struct.folder = type { ptr, %struct.anon }
%struct.anon = type { ptr }
%struct.anon.0 = type { ptr, ptr }
%struct.file = type { ptr, i64 }

@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 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

; Function Attrs: nounwind uwtable
declare hidden ptr @resolve_node_wrapper(ptr noundef, ptr noundef, ptr noundef) #1

declare void @printf(ptr noundef, ...) #2

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

declare i64 @strnlen(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @cmd_cat(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = call ptr @resolve_node_wrapper(ptr noundef %14, ptr noundef %15, ptr noundef %16)
  store ptr %17, ptr %10, align 8, !tbaa !5
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %4
  store i32 -8, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %75

21:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.node, ptr %22, i32 0, i32 3
  %24 = getelementptr inbounds %struct.folder, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds %struct.anon, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %12, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %68, %21
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %73

30:                                               ; preds = %27
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.node, ptr %31, i32 0, i32 2
  %33 = getelementptr inbounds [50 x i8], ptr %32, i64 0, i64 0
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call i64 @strnlen(ptr noundef %35, i64 noundef 50)
  %37 = call i32 @strncmp(ptr noundef %33, ptr noundef %34, i64 noundef %36) #4
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %67, label %39

39:                                               ; preds = %30
  %40 = load ptr, ptr %12, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.node, ptr %40, i32 0, i32 0
  %42 = load i8, ptr %41, align 8, !tbaa !10
  %43 = zext i8 %42 to i32
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %67

45:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !13
  br label %46

46:                                               ; preds = %63, %45
  %47 = load i64, ptr %13, align 8, !tbaa !13
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.node, ptr %48, i32 0, i32 3
  %50 = getelementptr inbounds %struct.file, ptr %49, i32 0, i32 1
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = icmp ult i64 %47, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %46
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %66

54:                                               ; preds = %46
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.node, ptr %55, i32 0, i32 3
  %57 = getelementptr inbounds %struct.file, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = load i64, ptr %13, align 8, !tbaa !13
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !9
  %62 = sext i8 %61 to i32
  call void (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %62)
  br label %63

63:                                               ; preds = %54
  %64 = load i64, ptr %13, align 8, !tbaa !13
  %65 = add i64 %64, 1
  store i64 %65, ptr %13, align 8, !tbaa !13
  br label %46, !llvm.loop !15

66:                                               ; preds = %53
  call void (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %74

67:                                               ; preds = %39, %30
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.node, ptr %69, i32 0, i32 4
  %71 = getelementptr inbounds %struct.anon.0, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !17
  store ptr %72, ptr %12, align 8, !tbaa !5
  br label %27, !llvm.loop !18

73:                                               ; preds = %27
  store i32 -8, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %74

74:                                               ; preds = %73, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %75

75:                                               ; preds = %74, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %76 = load i32, ptr %5, align 4
  ret i32 %76
}

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 = { "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 "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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 0}
!11 = !{!"node", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 56, !12, i64 72}
!12 = !{!"", !6, i64 0, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!11, !6, i64 72}
!18 = distinct !{!18, !16}


; 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.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden ptr @resolve_node_wrapper(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @printf(ptr noundef, ...) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -8, 1) i32 @cmd_cat(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = tail call ptr @resolve_node_wrapper(ptr noundef %2, ptr noundef %0, ptr noundef %1)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.loopexit, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %5, i64 64
  %.01622 = load ptr, ptr %7, align 8, !tbaa !5
  %.not1923 = icmp eq ptr %.01622, null
  br i1 %.not1923, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %8 = tail call i64 @strnlen(ptr noundef nonnull dereferenceable(1) %3, i64 noundef 50)
  br label %9

9:                                                ; preds = %.lr.ph, %26
  %.01624 = phi ptr [ %.01622, %.lr.ph ], [ %.016, %26 ]
  %10 = getelementptr inbounds i8, ptr %.01624, i64 2
  %11 = tail call i32 @strncmp(ptr noundef nonnull %10, ptr noundef %3, i64 noundef %8) #3
  %.not20 = icmp eq i32 %11, 0
  br i1 %.not20, label %12, label %26

12:                                               ; preds = %9
  %13 = load i8, ptr %.01624, align 8, !tbaa !8
  %14 = icmp eq i8 %13, 1
  br i1 %14, label %.preheader, label %26

.preheader:                                       ; preds = %12
  %15 = getelementptr inbounds i8, ptr %.01624, i64 64
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %.not27 = icmp eq i64 %16, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph26

.lr.ph26:                                         ; preds = %.preheader
  %17 = getelementptr inbounds i8, ptr %.01624, i64 56
  br label %18

._crit_edge:                                      ; preds = %18, %.preheader
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str.4) #3
  br label %.loopexit

18:                                               ; preds = %.lr.ph26, %18
  %.025 = phi i64 [ 0, %.lr.ph26 ], [ %23, %18 ]
  %19 = load ptr, ptr %17, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 %.025
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = sext i8 %21 to i32
  tail call void (ptr, ...) @printf(ptr noundef nonnull @.str.3, i32 noundef %22) #3
  %23 = add nuw i64 %.025, 1
  %24 = load i64, ptr %15, align 8, !tbaa !5
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %18, label %._crit_edge, !llvm.loop !12

26:                                               ; preds = %9, %12
  %27 = getelementptr inbounds i8, ptr %.01624, i64 72
  %.016 = load ptr, ptr %27, align 8, !tbaa !5
  %.not19 = icmp eq ptr %.016, null
  br i1 %.not19, label %.loopexit, label %9, !llvm.loop !14

.loopexit:                                        ; preds = %26, %6, %._crit_edge, %4
  %.1 = phi i32 [ -8, %4 ], [ 0, %._crit_edge ], [ -8, %6 ], [ -8, %26 ]
  ret i32 %.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 = { "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 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"node", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 56, !10, i64 72}
!10 = !{!"", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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