; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/ogg-src/src (framing)

; 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.ogg_sync_state = type { ptr, i32, i32, i32, i32, i32, i32 }

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ogg_sync_clear(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ogg_sync_check(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @ogg_sync_buffer(ptr noundef %0, i64 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call i32 @ogg_sync_check(ptr noundef %9)
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  br label %118

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ogg_sync_state, ptr %14, i32 0, i32 3
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %49

18:                                               ; preds = %13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ogg_sync_state, ptr %19, i32 0, i32 3
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ogg_sync_state, ptr %22, i32 0, i32 2
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = sub nsw i32 %24, %21
  store i32 %25, ptr %23, align 4, !tbaa !14
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ogg_sync_state, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %46

30:                                               ; preds = %18
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ogg_sync_state, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ogg_sync_state, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ogg_sync_state, ptr %37, i32 0, i32 3
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %36, i64 %40
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ogg_sync_state, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !14
  %45 = sext i32 %44 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %33, ptr align 1 %41, i64 %45, i1 false)
  br label %46

46:                                               ; preds = %30, %18
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ogg_sync_state, ptr %47, i32 0, i32 3
  store i32 0, ptr %48, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %46, %13
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ogg_sync_state, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !16
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ogg_sync_state, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 4, !tbaa !14
  %57 = sub nsw i32 %53, %56
  %58 = sext i32 %57 to i64
  %59 = icmp sgt i64 %50, %58
  br i1 %59, label %60, label %109

60:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %61 = load i64, ptr %5, align 8, !tbaa !9
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ogg_sync_state, ptr %62, i32 0, i32 2
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = sub nsw i32 2147479551, %64
  %66 = sext i32 %65 to i64
  %67 = icmp sgt i64 %61, %66
  br i1 %67, label %68, label %71

68:                                               ; preds = %60
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = call i32 @ogg_sync_clear(ptr noundef %69)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %106

71:                                               ; preds = %60
  %72 = load i64, ptr %5, align 8, !tbaa !9
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ogg_sync_state, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 4, !tbaa !14
  %76 = sext i32 %75 to i64
  %77 = add nsw i64 %72, %76
  %78 = add nsw i64 %77, 4096
  store i64 %78, ptr %6, align 8, !tbaa !9
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ogg_sync_state, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !15
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %89

83:                                               ; preds = %71
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ogg_sync_state, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = load i64, ptr %6, align 8, !tbaa !9
  %88 = call ptr @realloc(ptr noundef %86, i64 noundef %87) #6
  store ptr %88, ptr %7, align 8, !tbaa !5
  br label %92

89:                                               ; preds = %71
  %90 = load i64, ptr %6, align 8, !tbaa !9
  %91 = call noalias ptr @malloc(i64 noundef %90) #7
  store ptr %91, ptr %7, align 8, !tbaa !5
  br label %92

92:                                               ; preds = %89, %83
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %98, label %95

95:                                               ; preds = %92
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = call i32 @ogg_sync_clear(ptr noundef %96)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %106

98:                                               ; preds = %92
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.ogg_sync_state, ptr %100, i32 0, i32 0
  store ptr %99, ptr %101, align 8, !tbaa !15
  %102 = load i64, ptr %6, align 8, !tbaa !9
  %103 = trunc i64 %102 to i32
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ogg_sync_state, ptr %104, i32 0, i32 1
  store i32 %103, ptr %105, align 8, !tbaa !16
  store i32 0, ptr %8, align 4
  br label %106

106:                                              ; preds = %98, %95, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %107 = load i32, ptr %8, align 4
  switch i32 %107, label %120 [
    i32 0, label %108
    i32 1, label %118
  ]

108:                                              ; preds = %106
  br label %109

109:                                              ; preds = %108, %49
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.ogg_sync_state, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !15
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.ogg_sync_state, ptr %113, i32 0, i32 2
  %115 = load i32, ptr %114, align 4, !tbaa !14
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds i8, ptr %112, i64 %116
  store ptr %117, ptr %3, align 8
  br label %118

118:                                              ; preds = %109, %106, %12
  %119 = load ptr, ptr %3, align 8
  ret ptr %119

120:                                              ; preds = %106
  unreachable
}

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind allocsize(1) "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 = { nounwind allocsize(1) }
attributes #7 = { nounwind 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 16}
!12 = !{!"", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 12}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !13, i64 8}


; 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 nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ogg_sync_clear(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ogg_sync_check(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @ogg_sync_buffer(ptr noundef %0, i64 noundef %1) local_unnamed_addr #2 {
  %3 = tail call i32 @ogg_sync_check(ptr noundef %0)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %.thread

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not37 = icmp eq i32 %6, 0
  br i1 %.not37, label %18, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = sub nsw i32 %9, %6
  store i32 %10, ptr %8, align 4, !tbaa !11
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %7
  %13 = load ptr, ptr %0, align 8, !tbaa !12
  %14 = sext i32 %6 to i64
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  %16 = zext nneg i32 %10 to i64
  tail call void @llvm.memmove.p0.p0.i64(ptr align 1 %13, ptr nonnull align 1 %15, i64 %16, i1 false)
  br label %17

17:                                               ; preds = %12, %7
  store i32 0, ptr %5, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %17, %4
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = sub nsw i32 %20, %22
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %24, %1
  br i1 %25, label %26, label %._crit_edge

._crit_edge:                                      ; preds = %18
  %.pre = load ptr, ptr %0, align 8, !tbaa !12
  br label %46

26:                                               ; preds = %18
  %27 = sub nsw i32 2147479551, %22
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %28, %1
  br i1 %29, label %30, label %32

30:                                               ; preds = %26
  %31 = tail call i32 @ogg_sync_clear(ptr noundef nonnull %0)
  br label %.thread

32:                                               ; preds = %26
  %33 = sext i32 %22 to i64
  %34 = add nsw i64 %1, 4096
  %35 = add nsw i64 %34, %33
  %36 = load ptr, ptr %0, align 8, !tbaa !12
  %.not38 = icmp eq ptr %36, null
  br i1 %.not38, label %39, label %37

37:                                               ; preds = %32
  %38 = tail call ptr @realloc(ptr noundef nonnull %36, i64 noundef %35) #4
  br label %41

39:                                               ; preds = %32
  %40 = tail call noalias ptr @malloc(i64 noundef %35) #5
  br label %41

41:                                               ; preds = %39, %37
  %.031 = phi ptr [ %38, %37 ], [ %40, %39 ]
  %.not39 = icmp eq ptr %.031, null
  br i1 %.not39, label %42, label %44

42:                                               ; preds = %41
  %43 = tail call i32 @ogg_sync_clear(ptr noundef nonnull %0)
  br label %.thread

44:                                               ; preds = %41
  store ptr %.031, ptr %0, align 8, !tbaa !12
  %45 = trunc i64 %35 to i32
  store i32 %45, ptr %19, align 8, !tbaa !13
  %.pre42 = load i32, ptr %21, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %._crit_edge, %44
  %47 = phi i32 [ %22, %._crit_edge ], [ %.pre42, %44 ]
  %48 = phi ptr [ %.pre, %._crit_edge ], [ %.031, %44 ]
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  br label %.thread

.thread:                                          ; preds = %42, %30, %2, %46
  %.1 = phi ptr [ %50, %46 ], [ null, %2 ], [ null, %30 ], [ null, %42 ]
  ret ptr %.1
}

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { nounwind allocsize(1) }
attributes #5 = { nounwind 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, !10, i64 16}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 12}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass