; LLVM IR from marcinbor85/microshell :: src/src (ush_commands)

; 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.ush_node_object = type { ptr, i64, ptr, ptr, ptr, ptr }
%struct.ush_object = type { ptr, i32, i32, i32, ptr, i64, i64, i32, i64, i64, i64, i8, ptr, ptr, ptr, %struct.ush_node_object, ptr, ptr, ptr, i64, i64, ptr, i64, i32, i32, ptr, ptr, ptr, i64, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local i32 @ush_commands_add(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %16, %4
  %11 = load i64, ptr %9, align 8, !tbaa !9
  %12 = load i64, ptr %8, align 8, !tbaa !9
  %13 = icmp ult i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %19

15:                                               ; preds = %10
  br label %16

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

19:                                               ; preds = %14
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ush_node_object, ptr %21, i32 0, i32 0
  store ptr %20, ptr %22, align 8, !tbaa !13
  %23 = load i64, ptr %8, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ush_node_object, ptr %24, i32 0, i32 1
  store i64 %23, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ush_node_object, ptr %26, i32 0, i32 2
  store ptr null, ptr %27, align 8, !tbaa !16
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ush_object, ptr %28, i32 0, i32 12
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ush_node_object, ptr %31, i32 0, i32 5
  store ptr %30, ptr %32, align 8, !tbaa !21
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ush_object, ptr %34, i32 0, i32 12
  store ptr %33, ptr %35, align 8, !tbaa !17
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"ush_node_object", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !6, i64 16}
!17 = !{!18, !6, i64 88}
!18 = !{!"ush_object", !6, i64 0, !19, i64 8, !19, i64 12, !19, i64 16, !6, i64 24, !10, i64 32, !10, i64 40, !19, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !20, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !14, i64 112, !6, i64 160, !6, i64 168, !6, i64 176, !10, i64 184, !10, i64 192, !6, i64 200, !10, i64 208, !19, i64 216, !19, i64 220, !6, i64 224, !6, i64 232, !6, i64 240, !10, i64 248, !10, i64 256, !10, i64 264}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_Bool", !7, i64 0}
!21 = !{!14, !6, i64 40}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @ush_commands_add(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  store ptr %2, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %3, ptr %5, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr null, ptr %6, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %1, i64 40
  store ptr %8, ptr %9, align 8, !tbaa !17
  store ptr %1, ptr %7, align 8, !tbaa !13
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 0}
!6 = !{!"ush_node_object", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!14, !7, i64 88}
!14 = !{!"ush_object", !7, i64 0, !15, i64 8, !15, i64 12, !15, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !15, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !16, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !6, i64 112, !7, i64 160, !7, i64 168, !7, i64 176, !10, i64 184, !10, i64 192, !7, i64 200, !10, i64 208, !15, i64 216, !15, i64 220, !7, i64 224, !7, i64 232, !7, i64 240, !10, i64 248, !10, i64 256, !10, i64 264}
!15 = !{!"int", !8, i64 0}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!6, !7, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass