; LLVM IR from sp-nitech/SPTK :: src/input/input_source_from_array.ll (ZN4sptk20InputSourceFromArrayC2EbiiPd)

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

%"class.sptk::InputSourceFromArray" = type <{ %"class.sptk::InputSourceInterface", i8, [3 x i8], i32, i32, [4 x i8], ptr, i32, i8, [3 x i8] }>
%"class.sptk::InputSourceInterface" = type { ptr }

@_ZTVN4sptk20InputSourceFromArrayE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk20InputSourceFromArrayC2EbiiPd(ptr noundef nonnull align 8 dereferenceable(37) %0, i1 noundef zeroext %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %11 = zext i1 %1 to i8
  store i8 %11, ptr %7, align 1, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store i32 %3, ptr %9, align 4, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8
  call void @_ZN4sptk20InputSourceInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #2
  store ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTVN4sptk20InputSourceFromArrayE, i32 0, i32 0, i32 2), ptr %12, align 8, !tbaa !13
  %13 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 1
  %14 = load i8, ptr %7, align 1, !tbaa !9, !range !15, !noundef !16
  %15 = trunc i8 %14 to i1
  %16 = zext i1 %15 to i8
  store i8 %16, ptr %13, align 8, !tbaa !17
  %17 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 3
  %18 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %18, ptr %17, align 4, !tbaa !20
  %19 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 4
  %20 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %20, ptr %19, align 8, !tbaa !21
  %21 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 6
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %22, ptr %21, align 8, !tbaa !22
  %23 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 7
  store i32 0, ptr %23, align 8, !tbaa !23
  %24 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 8
  store i8 1, ptr %24, align 4, !tbaa !24
  %25 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 3
  %26 = load i32, ptr %25, align 4, !tbaa !20
  %27 = icmp sle i32 %26, 0
  br i1 %27, label %36, label %28

28:                                               ; preds = %5
  %29 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 4
  %30 = load i32, ptr %29, align 8, !tbaa !21
  %31 = icmp sle i32 %30, 0
  br i1 %31, label %36, label %32

32:                                               ; preds = %28
  %33 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 6
  %34 = load ptr, ptr %33, align 8, !tbaa !22
  %35 = icmp eq ptr null, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %32, %28, %5
  %37 = getelementptr inbounds %"class.sptk::InputSourceFromArray", ptr %12, i32 0, i32 8
  store i8 0, ptr %37, align 4, !tbaa !24
  br label %38

38:                                               ; preds = %36, %32
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk20InputSourceInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !10, i64 8}
!18 = !{!"_ZTSN4sptk20InputSourceFromArrayE", !19, i64 0, !10, i64 8, !12, i64 12, !12, i64 16, !6, i64 24, !12, i64 32, !10, i64 36}
!19 = !{!"_ZTSN4sptk20InputSourceInterfaceE"}
!20 = !{!18, !12, i64 12}
!21 = !{!18, !12, i64 16}
!22 = !{!18, !6, i64 24}
!23 = !{!18, !12, i64 32}
!24 = !{!18, !10, i64 36}


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

@_ZTVN4sptk20InputSourceFromArrayE = external dso_local unnamed_addr constant { [7 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk20InputSourceFromArrayC2EbiiPd(ptr noundef nonnull align 8 dereferenceable(37) %0, i1 noundef zeroext %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) unnamed_addr #0 align 2 {
  %6 = zext i1 %1 to i8
  tail call void @_ZN4sptk20InputSourceInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #2
  store ptr getelementptr inbounds inrange(-16, 40) (i8, ptr @_ZTVN4sptk20InputSourceFromArrayE, i64 16), ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %6, ptr %7, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %2, ptr %8, align 4, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %3, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %4, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %11, align 8, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %0, i64 36
  %13 = icmp sgt i32 %2, 0
  %14 = icmp sgt i32 %3, 0
  %or.cond.not9 = and i1 %13, %14
  %15 = icmp ne ptr %4, null
  %or.cond6.not = and i1 %or.cond.not9, %15
  %spec.store.select = zext i1 %or.cond6.not to i8
  store i8 %spec.store.select, ptr %12, align 4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk20InputSourceInterfaceC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ZTSN4sptk20InputSourceFromArrayE", !10, i64 0, !11, i64 8, !13, i64 12, !13, i64 16, !14, i64 24, !13, i64 32, !11, i64 36}
!10 = !{!"_ZTSN4sptk20InputSourceInterfaceE"}
!11 = !{!"bool", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"int", !12, i64 0}
!14 = !{!"any pointer", !12, i64 0}
!15 = !{!9, !13, i64 12}
!16 = !{!9, !13, i64 16}
!17 = !{!9, !14, i64 24}
!18 = !{!9, !13, i64 32}


; Effective O3 passes: DSEPass,EarlyCSEPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass