; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/vorbis-src/vq (bookutil)

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

@lbufsize = external hidden global i32, align 4
@linebuffer = external hidden global ptr, align 8

; 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 uwtable
define dso_local ptr @get_line(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call i32 @feof(ptr noundef %8) #6
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %81

12:                                               ; preds = %1
  br label %13

13:                                               ; preds = %80, %12
  br label %14

14:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %67, %14
  %16 = load i32, ptr %6, align 4, !tbaa !11
  %17 = icmp ne i32 %16, 0
  %18 = xor i1 %17, true
  br i1 %18, label %19, label %68

19:                                               ; preds = %15
  %20 = load i64, ptr %4, align 8, !tbaa !9
  %21 = add nsw i64 %20, 1
  %22 = load i32, ptr @lbufsize, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = icmp sge i64 %21, %23
  br i1 %24, label %25, label %40

25:                                               ; preds = %19
  %26 = load i32, ptr @lbufsize, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %32, label %28

28:                                               ; preds = %25
  store i32 1024, ptr @lbufsize, align 4, !tbaa !11
  %29 = load i32, ptr @lbufsize, align 4, !tbaa !11
  %30 = sext i32 %29 to i64
  %31 = call noalias ptr @malloc(i64 noundef %30) #7
  store ptr %31, ptr @linebuffer, align 8, !tbaa !5
  br label %39

32:                                               ; preds = %25
  %33 = load i32, ptr @lbufsize, align 4, !tbaa !11
  %34 = mul nsw i32 %33, 2
  store i32 %34, ptr @lbufsize, align 4, !tbaa !11
  %35 = load ptr, ptr @linebuffer, align 8, !tbaa !5
  %36 = load i32, ptr @lbufsize, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = call ptr @realloc(ptr noundef %35, i64 noundef %37) #8
  store ptr %38, ptr @linebuffer, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %32, %28
  br label %40

40:                                               ; preds = %39, %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call i32 @fgetc(ptr noundef %41)
  %43 = sext i32 %42 to i64
  store i64 %43, ptr %7, align 8, !tbaa !9
  %44 = load i64, ptr %7, align 8, !tbaa !9
  switch i64 %44, label %54 [
    i64 -1, label %45
    i64 10, label %50
  ]

45:                                               ; preds = %40
  %46 = load i64, ptr %4, align 8, !tbaa !9
  %47 = icmp eq i64 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %65

49:                                               ; preds = %45
  br label %50

50:                                               ; preds = %49, %40
  %51 = load ptr, ptr @linebuffer, align 8, !tbaa !5
  %52 = load i64, ptr %4, align 8, !tbaa !9
  %53 = getelementptr inbounds i8, ptr %51, i64 %52
  store i8 0, ptr %53, align 1, !tbaa !13
  store i32 1, ptr %6, align 4, !tbaa !11
  br label %64

54:                                               ; preds = %40
  %55 = load i64, ptr %7, align 8, !tbaa !9
  %56 = trunc i64 %55 to i8
  %57 = load ptr, ptr @linebuffer, align 8, !tbaa !5
  %58 = load i64, ptr %4, align 8, !tbaa !9
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %4, align 8, !tbaa !9
  %60 = getelementptr inbounds i8, ptr %57, i64 %58
  store i8 %56, ptr %60, align 1, !tbaa !13
  %61 = load ptr, ptr @linebuffer, align 8, !tbaa !5
  %62 = load i64, ptr %4, align 8, !tbaa !9
  %63 = getelementptr inbounds i8, ptr %61, i64 %62
  store i8 0, ptr %63, align 1, !tbaa !13
  br label %64

64:                                               ; preds = %54, %50
  store i32 0, ptr %5, align 4
  br label %65

65:                                               ; preds = %64, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %66 = load i32, ptr %5, align 4
  switch i32 %66, label %78 [
    i32 0, label %67
  ]

67:                                               ; preds = %65
  br label %15, !llvm.loop !14

68:                                               ; preds = %15
  %69 = load ptr, ptr @linebuffer, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 0
  %71 = load i8, ptr %70, align 1, !tbaa !13
  %72 = sext i8 %71 to i32
  %73 = icmp eq i32 %72, 35
  br i1 %73, label %74, label %75

74:                                               ; preds = %68
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %77

75:                                               ; preds = %68
  %76 = load ptr, ptr @linebuffer, align 8, !tbaa !5
  store ptr %76, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %78

77:                                               ; preds = %74
  store i32 0, ptr %5, align 4
  br label %78

78:                                               ; preds = %77, %75, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %79 = load i32, ptr %5, align 4
  switch i32 %79, label %81 [
    i32 0, label %80
  ]

80:                                               ; preds = %78
  br label %13

81:                                               ; preds = %78, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %82 = load ptr, ptr %2, align 8
  ret ptr %82
}

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #2

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

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

declare i32 @fgetc(ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #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 = { "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind allocsize(1) }

!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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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

@lbufsize = external hidden local_unnamed_addr global i32, align 4
@linebuffer = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @get_line(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @feof(ptr noundef %0) #4
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %.preheader, label %.thread31

.preheader:                                       ; preds = %1, %.preheader.backedge
  %.11936 = phi i64 [ %.11936.be, %.preheader.backedge ], [ 0, %1 ]
  %3 = add nuw nsw i64 %.11936, 1
  %4 = load i32, ptr @lbufsize, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %.not25 = icmp slt i64 %3, %5
  br i1 %.not25, label %14, label %6

6:                                                ; preds = %.preheader
  %.not26 = icmp eq i32 %4, 0
  br i1 %.not26, label %7, label %9

7:                                                ; preds = %6
  store i32 1024, ptr @lbufsize, align 4, !tbaa !5
  %8 = tail call noalias dereferenceable_or_null(1024) ptr @malloc(i64 noundef 1024) #5
  br label %.sink.split

9:                                                ; preds = %6
  %10 = shl nsw i32 %4, 1
  store i32 %10, ptr @lbufsize, align 4, !tbaa !5
  %11 = load ptr, ptr @linebuffer, align 8, !tbaa !9
  %12 = sext i32 %10 to i64
  %13 = tail call ptr @realloc(ptr noundef %11, i64 noundef %12) #6
  br label %.sink.split

.sink.split:                                      ; preds = %9, %7
  %.sink = phi ptr [ %8, %7 ], [ %13, %9 ]
  store ptr %.sink, ptr @linebuffer, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %.sink.split, %.preheader
  %15 = tail call i32 @fgetc(ptr noundef %0)
  switch i32 %15, label %18 [
    i32 -1, label %16
    i32 10, label %.loopexit
  ]

16:                                               ; preds = %14
  %17 = icmp eq i64 %.11936, 0
  br i1 %17, label %.thread31, label %.loopexit

18:                                               ; preds = %14
  %19 = trunc i32 %15 to i8
  %20 = load ptr, ptr @linebuffer, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %20, i64 %.11936
  store i8 %19, ptr %21, align 1, !tbaa !11
  %22 = load ptr, ptr @linebuffer, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 %3
  store i8 0, ptr %23, align 1, !tbaa !11
  br label %.preheader.backedge

.preheader.backedge:                              ; preds = %18, %.loopexit
  %.11936.be = phi i64 [ %3, %18 ], [ 0, %.loopexit ]
  br label %.preheader, !llvm.loop !12

.loopexit:                                        ; preds = %14, %16
  %24 = load ptr, ptr @linebuffer, align 8, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %24, i64 %.11936
  store i8 0, ptr %25, align 1, !tbaa !11
  %26 = load ptr, ptr @linebuffer, align 8, !tbaa !9
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = icmp eq i8 %27, 35
  br i1 %28, label %.preheader.backedge, label %.thread31

.thread31:                                        ; preds = %.loopexit, %16, %1
  %.4 = phi ptr [ null, %1 ], [ %26, %.loopexit ], [ null, %16 ]
  ret ptr %.4
}

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; 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

; Function Attrs: nofree nounwind
declare noundef i32 @fgetc(ptr nocapture noundef) local_unnamed_addr #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 = { nofree 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 #2 = { 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 #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 }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind allocsize(1) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass