; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core (soloud_file)

; 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.SoLoud::MemoryFile" = type <{ %"class.SoLoud::File", ptr, i32, i32, i8, [7 x i8] }>
%"class.SoLoud::File" = type { ptr }

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6SoLoud10MemoryFile13openFileToMemEPNS_4FileE(ptr noundef nonnull align 8 dereferenceable(25) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  store i32 1, ptr %3, align 4
  br label %49

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 4
  %12 = load i8, ptr %11, align 8, !tbaa !9, !range !14, !noundef !15
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %20

14:                                               ; preds = %10
  %15 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = icmp eq ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @_ZdaPv(ptr noundef %16) #3
  br label %19

19:                                               ; preds = %18, %14
  br label %20

20:                                               ; preds = %19, %10
  %21 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 1
  store ptr null, ptr %21, align 8, !tbaa !16
  %22 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 3
  store i32 0, ptr %22, align 4, !tbaa !17
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %23, align 8, !tbaa !18
  %25 = getelementptr inbounds ptr, ptr %24, i64 4
  %26 = load ptr, ptr %25, align 8
  %27 = call noundef i32 %26(ptr noundef nonnull align 8 dereferenceable(8) %23)
  %28 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 2
  store i32 %27, ptr %28, align 8, !tbaa !20
  %29 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !20
  %31 = zext i32 %30 to i64
  %32 = call noalias noundef nonnull ptr @_Znam(i64 noundef %31) #4
  %33 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 1
  store ptr %32, ptr %33, align 8, !tbaa !16
  %34 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %20
  store i32 5, ptr %3, align 4
  br label %49

38:                                               ; preds = %20
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 2
  %43 = load i32, ptr %42, align 8, !tbaa !20
  %44 = load ptr, ptr %39, align 8, !tbaa !18
  %45 = getelementptr inbounds ptr, ptr %44, i64 3
  %46 = load ptr, ptr %45, align 8
  %47 = call noundef i32 %46(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef %41, i32 noundef %43)
  %48 = getelementptr inbounds %"class.SoLoud::MemoryFile", ptr %6, i32 0, i32 4
  store i8 1, ptr %48, align 8, !tbaa !9
  store i32 0, ptr %3, align 4
  br label %49

49:                                               ; preds = %38, %37, %9
  %50 = load i32, ptr %3, align 4
  ret i32 %50
}

attributes #0 = { nobuiltin nounwind "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 = { nobuiltin 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 #2 = { mustprogress 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 #3 = { builtin nounwind }
attributes #4 = { builtin 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++ TBAA"}
!9 = !{!10, !13, i64 24}
!10 = !{!"_ZTSN6SoLoud10MemoryFileE", !11, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !13, i64 24}
!11 = !{!"_ZTSN6SoLoud4FileE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !6, i64 8}
!17 = !{!10, !12, i64 20}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!10, !12, i64 16}


; 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN6SoLoud10MemoryFile13openFileToMemEPNS_4FileE(ptr nocapture noundef nonnull align 8 dereferenceable(25) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %26, label %3

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i8, ptr %4, align 8, !tbaa !5, !range !13, !noundef !14
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %7, label %12

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !15
  %10 = icmp eq ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void @_ZdaPv(ptr noundef nonnull %9) #3
  br label %12

12:                                               ; preds = %7, %11, %3
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 0, ptr %14, align 4, !tbaa !16
  %15 = load ptr, ptr %1, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %15, i64 32
  %17 = load ptr, ptr %16, align 8
  %18 = tail call noundef i32 %17(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %18, ptr %19, align 8, !tbaa !19
  %20 = zext i32 %18 to i64
  %21 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %20) #4
  store ptr %21, ptr %13, align 8, !tbaa !15
  %22 = load ptr, ptr %1, align 8, !tbaa !17
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  %24 = load ptr, ptr %23, align 8
  %25 = tail call noundef i32 %24(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %21, i32 noundef %18)
  store i8 1, ptr %4, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %2, %12
  %.0 = phi i32 [ 0, %12 ], [ 1, %2 ]
  ret i32 %.0
}

attributes #0 = { nobuiltin nounwind "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 = { nobuiltin 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 #2 = { mustprogress 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 #3 = { builtin nounwind }
attributes #4 = { builtin 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, !12, i64 24}
!6 = !{!"_ZTSN6SoLoud10MemoryFileE", !7, i64 0, !8, i64 8, !11, i64 16, !11, i64 20, !12, i64 24}
!7 = !{!"_ZTSN6SoLoud4FileE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !8, i64 8}
!16 = !{!6, !11, i64 20}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !10, i64 0}
!19 = !{!6, !11, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass