; LLVM IR from itchio/go-brotli :: fuzz (decode_fuzzer)

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @LLVMFuzzerTestOneInput(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  %19 = load i64, ptr %4, align 8, !tbaa !9
  %20 = icmp ugt i64 %19, 0
  br i1 %20, label %21, label %30

21:                                               ; preds = %2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = sub i64 %23, 1
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = zext i8 %26 to i32
  %28 = and i32 %27, 7
  %29 = sext i32 %28 to i64
  store i64 %29, ptr %5, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %21, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %31, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1024, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %32 = call noalias noundef nonnull ptr @_Znam(i64 noundef 1024) #6
  store ptr %32, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = icmp eq i64 %33, 0
  %35 = zext i1 %34 to i64
  %36 = select i1 %34, i32 67108864, i32 16777216
  %37 = sext i32 %36 to i64
  store i64 %37, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %38 = call ptr @BrotliDecoderCreateInstance(ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %38, ptr %11, align 8, !tbaa !5
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = icmp eq i64 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %30
  %42 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %42, ptr %5, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %41, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %90, %43
  %45 = load i64, ptr %12, align 8, !tbaa !9
  %46 = load i64, ptr %4, align 8, !tbaa !9
  %47 = icmp ult i64 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 2, ptr %13, align 4
  br label %91

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %50 = load i64, ptr %12, align 8, !tbaa !9
  %51 = load i64, ptr %5, align 8, !tbaa !9
  %52 = add i64 %50, %51
  store i64 %52, ptr %14, align 8, !tbaa !9
  %53 = load i64, ptr %14, align 8, !tbaa !9
  %54 = load i64, ptr %4, align 8, !tbaa !9
  %55 = icmp ugt i64 %53, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %49
  %57 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %57, ptr %14, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %56, %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %59 = load i64, ptr %14, align 8, !tbaa !9
  %60 = load i64, ptr %12, align 8, !tbaa !9
  %61 = sub i64 %59, %60
  store i64 %61, ptr %15, align 8, !tbaa !9
  %62 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %62, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 3, ptr %16, align 4, !tbaa !14
  br label %63

63:                                               ; preds = %77, %58
  %64 = load i32, ptr %16, align 4, !tbaa !14
  %65 = icmp eq i32 %64, 3
  br i1 %65, label %66, label %78

66:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store i64 1024, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %67, ptr %18, align 8, !tbaa !5
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = call i32 @BrotliDecoderDecompressStream(ptr noundef %68, ptr noundef %15, ptr noundef %6, ptr noundef %17, ptr noundef %18, ptr noundef %10)
  store i32 %69, ptr %16, align 4, !tbaa !14
  %70 = load i64, ptr %10, align 8, !tbaa !9
  %71 = load i64, ptr %9, align 8, !tbaa !9
  %72 = icmp ugt i64 %70, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %66
  store i32 5, ptr %13, align 4
  br label %75

74:                                               ; preds = %66
  store i32 0, ptr %13, align 4
  br label %75

75:                                               ; preds = %74, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  %76 = load i32, ptr %13, align 4
  switch i32 %76, label %98 [
    i32 0, label %77
    i32 5, label %78
  ]

77:                                               ; preds = %75
  br label %63, !llvm.loop !16

78:                                               ; preds = %75, %63
  %79 = load i64, ptr %10, align 8, !tbaa !9
  %80 = load i64, ptr %9, align 8, !tbaa !9
  %81 = icmp ugt i64 %79, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %78
  store i32 2, ptr %13, align 4
  br label %88

83:                                               ; preds = %78
  %84 = load i32, ptr %16, align 4, !tbaa !14
  %85 = icmp ne i32 %84, 2
  br i1 %85, label %86, label %87

86:                                               ; preds = %83
  store i32 2, ptr %13, align 4
  br label %88

87:                                               ; preds = %83
  store i32 0, ptr %13, align 4
  br label %88

88:                                               ; preds = %87, %86, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  %89 = load i32, ptr %13, align 4
  switch i32 %89, label %91 [
    i32 0, label %90
  ]

90:                                               ; preds = %88
  br label %44, !llvm.loop !18

91:                                               ; preds = %88, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %92

92:                                               ; preds = %91
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  call void @BrotliDecoderDestroyInstance(ptr noundef %93)
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  %95 = icmp eq ptr %94, null
  br i1 %95, label %97, label %96

96:                                               ; preds = %92
  call void @_ZdaPv(ptr noundef %94) #7
  br label %97

97:                                               ; preds = %96, %92
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 0

98:                                               ; preds = %75
  unreachable
}

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

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

declare ptr @BrotliDecoderCreateInstance(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @BrotliDecoderDecompressStream(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

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

declare void @BrotliDecoderDestroyInstance(ptr noundef) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_ZTS19BrotliDecoderResult", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 uwtable
define dso_local noundef i32 @LLVMFuzzerTestOneInput(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %14, label %8

8:                                                ; preds = %2
  %9 = getelementptr i8, ptr %0, i64 %1
  %10 = getelementptr i8, ptr %9, i64 -1
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = and i8 %11, 7
  %13 = zext nneg i8 %12 to i64
  br label %14

14:                                               ; preds = %8, %2
  %.030 = phi i64 [ %13, %8 ], [ 0, %2 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  store ptr %0, ptr %3, align 8, !tbaa !8
  %15 = tail call noalias noundef nonnull dereferenceable(1024) ptr @_Znam(i64 noundef 1024) #7
  %16 = icmp eq i64 %.030, 0
  %17 = select i1 %16, i64 67108864, i64 16777216
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store i64 0, ptr %4, align 8, !tbaa !10
  %18 = tail call ptr @BrotliDecoderCreateInstance(ptr noundef null, ptr noundef null, ptr noundef null)
  %spec.select = select i1 %16, i64 %1, i64 %.030
  %.not40 = icmp eq i64 %1, 0
  br i1 %.not40, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %14, %28
  %.02938 = phi i64 [ %spec.select36, %28 ], [ 0, %14 ]
  %19 = add i64 %.02938, %spec.select
  %spec.select36 = call i64 @llvm.umin.i64(i64 %19, i64 %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %20 = sub i64 %spec.select36, %.02938
  store i64 %20, ptr %5, align 8, !tbaa !10
  br label %21

21:                                               ; preds = %21, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  store i64 1024, ptr %6, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  store ptr %15, ptr %7, align 8, !tbaa !8
  %22 = call i32 @BrotliDecoderDecompressStream(ptr noundef %18, ptr noundef nonnull %5, ptr noundef nonnull %3, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %4)
  %23 = load i64, ptr %4, align 8, !tbaa !10
  %24 = icmp ule i64 %23, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %25 = icmp eq i32 %22, 3
  %or.cond = select i1 %24, i1 %25, i1 false
  br i1 %or.cond, label %21, label %26

26:                                               ; preds = %21
  %27 = icmp ugt i64 %23, %17
  br i1 %27, label %.critedge, label %28

28:                                               ; preds = %26
  %.not35 = icmp eq i32 %22, 2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  %29 = icmp ult i64 %19, %1
  %or.cond41 = select i1 %.not35, i1 %29, i1 false
  br i1 %or.cond41, label %.lr.ph, label %.loopexit, !llvm.loop !12

.critedge:                                        ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %.loopexit

.loopexit:                                        ; preds = %28, %14, %.critedge
  call void @BrotliDecoderDestroyInstance(ptr noundef %18)
  call void @_ZdaPv(ptr noundef nonnull %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 0
}

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

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

declare ptr @BrotliDecoderCreateInstance(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @BrotliDecoderDecompressStream(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare void @BrotliDecoderDestroyInstance(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #5

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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