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

; 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

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

; Function Attrs: allocsize(0)
declare ptr @malloc(i64 noundef) #2

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

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

declare ptr @strzcpy(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @cmd_touch(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
  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) #5
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = call ptr @resolve_node_wrapper(ptr noundef %13, ptr noundef %14, ptr noundef %15)
  store ptr %16, ptr %10, align 8, !tbaa !5
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %21 = call ptr @malloc(i64 noundef 88) #6
  store ptr %21, ptr %12, align 8, !tbaa !5
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 -3, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %83

25:                                               ; preds = %20
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %26, i8 0, i64 88, i1 false)
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = call i64 @strnlen(ptr noundef %27, i64 noundef 50)
  %29 = add i64 %28, 1
  %30 = trunc i64 %29 to i8
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.node, ptr %31, i32 0, i32 1
  store i8 %30, ptr %32, align 1, !tbaa !9
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.node, ptr %33, i32 0, i32 2
  %35 = getelementptr inbounds [50 x i8], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.node, ptr %37, i32 0, i32 1
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %40 = zext i8 %39 to i64
  %41 = call ptr @strzcpy(ptr noundef %35, ptr noundef %36, i64 noundef %40)
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.node, ptr %42, i32 0, i32 0
  store i8 1, ptr %43, align 8, !tbaa !12
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.node, ptr %44, i32 0, i32 3
  %46 = getelementptr inbounds %struct.file, ptr %45, i32 0, i32 1
  store i64 0, ptr %46, align 8, !tbaa !13
  br label %47

47:                                               ; preds = %25
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.node, ptr %48, i32 0, i32 3
  %50 = getelementptr inbounds %struct.folder, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.anon, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.node, ptr %53, i32 0, i32 4
  %55 = getelementptr inbounds %struct.anon.0, ptr %54, i32 0, i32 0
  store ptr %52, ptr %55, align 8, !tbaa !14
  %56 = icmp ne ptr %52, null
  br i1 %56, label %57, label %68

57:                                               ; preds = %47
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.node, ptr %58, i32 0, i32 4
  %60 = getelementptr inbounds %struct.anon.0, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.node, ptr %61, i32 0, i32 3
  %63 = getelementptr inbounds %struct.folder, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.anon, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = getelementptr inbounds %struct.node, ptr %65, i32 0, i32 4
  %67 = getelementptr inbounds %struct.anon.0, ptr %66, i32 0, i32 1
  store ptr %60, ptr %67, align 8, !tbaa !15
  br label %68

68:                                               ; preds = %57, %47
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.node, ptr %70, i32 0, i32 3
  %72 = getelementptr inbounds %struct.folder, ptr %71, i32 0, i32 1
  %73 = getelementptr inbounds %struct.anon, ptr %72, i32 0, i32 0
  store ptr %69, ptr %73, align 8, !tbaa !13
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.node, ptr %74, i32 0, i32 3
  %76 = getelementptr inbounds %struct.folder, ptr %75, i32 0, i32 1
  %77 = getelementptr inbounds %struct.anon, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.node, ptr %78, i32 0, i32 4
  %80 = getelementptr inbounds %struct.anon.0, ptr %79, i32 0, i32 1
  store ptr %77, ptr %80, align 8, !tbaa !15
  br label %81

81:                                               ; preds = %68
  br label %82

82:                                               ; preds = %81
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %83

83:                                               ; preds = %82, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %84

84:                                               ; preds = %83, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %85 = load i32, ptr %5, align 4
  ret i32 %85
}

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 }
attributes #6 = { 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, !7, i64 1}
!10 = !{!"node", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 56, !11, i64 72}
!11 = !{!"", !6, i64 0, !6, i64 8}
!12 = !{!10, !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !6, i64 72}
!15 = !{!10, !6, i64 80}


; 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 uwtable
declare hidden ptr @resolve_node_wrapper(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare ptr @strzcpy(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -8, 1) i32 @cmd_touch(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %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 %23, label %6

6:                                                ; preds = %4
  %calloc = tail call dereferenceable_or_null(88) ptr @calloc(i64 1, i64 88)
  %.not23 = icmp eq ptr %calloc, null
  br i1 %.not23, label %23, label %7

7:                                                ; preds = %6
  %8 = tail call i64 @strnlen(ptr noundef nonnull dereferenceable(1) %3, i64 noundef 50)
  %9 = trunc i64 %8 to i8
  %10 = add i8 %9, 1
  %11 = getelementptr inbounds i8, ptr %calloc, i64 1
  store i8 %10, ptr %11, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %calloc, i64 2
  %13 = zext i8 %10 to i64
  %14 = tail call ptr @strzcpy(ptr noundef nonnull %12, ptr noundef %3, i64 noundef %13) #4
  store i8 1, ptr %calloc, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %calloc, i64 64
  store i64 0, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %5, i64 64
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %calloc, i64 72
  store ptr %17, ptr %18, align 8, !tbaa !13
  %.not24 = icmp eq ptr %17, null
  br i1 %.not24, label %21, label %19

19:                                               ; preds = %7
  %20 = getelementptr inbounds i8, ptr %17, i64 80
  store ptr %18, ptr %20, align 8, !tbaa !14
  br label %21

21:                                               ; preds = %19, %7
  store ptr %calloc, ptr %16, align 8, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %calloc, i64 80
  store ptr %16, ptr %22, align 8, !tbaa !14
  br label %23

23:                                               ; preds = %21, %6, %4
  %.1 = phi i32 [ -8, %4 ], [ 0, %21 ], [ -3, %6 ]
  ret i32 %.1
}

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

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 = { 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 = { "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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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, !7, i64 1}
!6 = !{!"node", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 56, !9, i64 72}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !10, i64 0, !10, i64 8}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 72}
!14 = !{!6, !10, i64 80}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass