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

; 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: nounwind uwtable
define dso_local i32 @cmd_mkdir(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 %81

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 %80

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 2, ptr %43, align 8, !tbaa !12
  br label %44

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

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

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

78:                                               ; preds = %65
  br label %79

79:                                               ; preds = %78
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %80

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

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

; 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

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: nounwind uwtable
define dso_local range(i32 -8, 1) i32 @cmd_mkdir(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 %22, label %6

6:                                                ; preds = %4
  %calloc = tail call dereferenceable_or_null(88) ptr @calloc(i64 1, i64 88)
  %.not22 = icmp eq ptr %calloc, null
  br i1 %.not22, label %22, 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 2, ptr %calloc, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %5, i64 64
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %calloc, i64 72
  store ptr %16, ptr %17, align 8, !tbaa !13
  %.not23 = icmp eq ptr %16, null
  br i1 %.not23, label %20, label %18

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

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

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

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