; LLVM IR from tenok-rtos/tenok :: user/shell (shell)

; 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.shell = type { i32, i32, i32, [50 x i8], [50 x i8], [50 x i8], i8, i32, i32, i32, ptr, i32, i32, i8, ptr, %struct.list_head, ptr, ptr, i32 }
%struct.list_head = type { ptr, ptr }

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @INIT_LIST_HEAD(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @shell_init_minimal(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.shell, ptr %3, i32 0, i32 4
  %5 = getelementptr inbounds [50 x i8], ptr %4, i64 0, i64 0
  store i8 0, ptr %5, align 2, !tbaa !9
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.shell, ptr %6, i32 0, i32 2
  store i32 0, ptr %7, align 8, !tbaa !10
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.shell, ptr %8, i32 0, i32 0
  store i32 0, ptr %9, align 8, !tbaa !15
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.shell, ptr %10, i32 0, i32 3
  %12 = getelementptr inbounds [50 x i8], ptr %11, i64 0, i64 0
  store i8 0, ptr %12, align 4, !tbaa !9
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.shell, ptr %13, i32 0, i32 1
  store i32 0, ptr %14, align 4, !tbaa !16
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.shell, ptr %15, i32 0, i32 17
  store ptr null, ptr %16, align 8, !tbaa !17
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.shell, ptr %17, i32 0, i32 18
  store i32 0, ptr %18, align 8, !tbaa !18
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.shell, ptr %19, i32 0, i32 14
  store ptr null, ptr %20, align 8, !tbaa !19
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.shell, ptr %21, i32 0, i32 12
  store i32 0, ptr %22, align 4, !tbaa !20
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.shell, ptr %23, i32 0, i32 11
  store i32 0, ptr %24, align 8, !tbaa !21
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.shell, ptr %25, i32 0, i32 13
  store i8 0, ptr %26, align 8, !tbaa !22
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.shell, ptr %27, i32 0, i32 6
  store i8 0, ptr %28, align 2, !tbaa !23
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.shell, ptr %29, i32 0, i32 10
  store ptr null, ptr %30, align 8, !tbaa !24
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.shell, ptr %31, i32 0, i32 9
  store i32 0, ptr %32, align 4, !tbaa !25
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.shell, ptr %33, i32 0, i32 8
  store i32 0, ptr %34, align 8, !tbaa !26
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.shell, ptr %35, i32 0, i32 15
  call void @INIT_LIST_HEAD(ptr noundef %36)
  ret void
}

attributes #0 = { inlinehint 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 = { 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" }

!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, !12, i64 8}
!11 = !{!"shell", !12, i64 0, !12, i64 4, !12, i64 8, !7, i64 12, !7, i64 62, !7, i64 112, !13, i64 162, !12, i64 164, !12, i64 168, !12, i64 172, !6, i64 176, !12, i64 184, !12, i64 188, !13, i64 192, !6, i64 200, !14, i64 208, !6, i64 224, !6, i64 232, !12, i64 240}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"list_head", !6, i64 0, !6, i64 8}
!15 = !{!11, !12, i64 0}
!16 = !{!11, !12, i64 4}
!17 = !{!11, !6, i64 232}
!18 = !{!11, !12, i64 240}
!19 = !{!11, !6, i64 200}
!20 = !{!11, !12, i64 188}
!21 = !{!11, !12, i64 184}
!22 = !{!11, !13, i64 192}
!23 = !{!11, !13, i64 162}
!24 = !{!11, !6, i64 176}
!25 = !{!11, !12, i64 172}
!26 = !{!11, !12, i64 168}


; 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: inlinehint nounwind uwtable
declare hidden void @INIT_LIST_HEAD(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @shell_init_minimal(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 62
  store i8 0, ptr %2, align 2, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 232
  store ptr null, ptr %3, align 8, !tbaa !8
  %4 = getelementptr inbounds i8, ptr %0, i64 240
  store i32 0, ptr %4, align 8, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %0, i64 200
  store ptr null, ptr %5, align 8, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 162
  store i8 0, ptr %6, align 2, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %0, i64 168
  %8 = getelementptr inbounds i8, ptr %0, i64 208
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(13) %0, i8 0, i64 13, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(25) %7, i8 0, i64 25, i1 false)
  tail call void @INIT_LIST_HEAD(ptr noundef nonnull %8)
  ret void
}

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

attributes #0 = { inlinehint 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !12, i64 232}
!9 = !{!"shell", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 12, !6, i64 62, !6, i64 112, !11, i64 162, !10, i64 164, !10, i64 168, !10, i64 172, !12, i64 176, !10, i64 184, !10, i64 188, !11, i64 192, !12, i64 200, !13, i64 208, !12, i64 224, !12, i64 232, !10, i64 240}
!10 = !{!"int", !6, i64 0}
!11 = !{!"_Bool", !6, i64 0}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!"list_head", !12, i64 0, !12, i64 8}
!14 = !{!9, !10, i64 240}
!15 = !{!9, !12, i64 200}
!16 = !{!9, !11, i64 162}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass