; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/flac-src/src/test_libFLAC (crc)

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

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @test_crc() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [32768 x i8], align 16
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 32768, ptr %3) #4
  call void @llvm.memset.p0.i64(ptr align 16 %3, i8 0, i64 32768, i1 false)
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %21, %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp ult i32 %6, 32768
  br i1 %7, label %8, label %24

8:                                                ; preds = %5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = urem i32 %9, 256
  %11 = trunc i32 %10 to i8
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sub i32 %12, 1
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = call zeroext i8 @crc8_update_ref(i8 noundef zeroext %11, i8 noundef zeroext %16)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 %19
  store i8 %17, ptr %20, align 1, !tbaa !9
  br label %21

21:                                               ; preds = %8
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !10

24:                                               ; preds = %5
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %26 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 0
  %27 = call i32 @test_crc8(ptr noundef %26, i64 noundef 32768)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %52

30:                                               ; preds = %24
  %31 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 0
  %32 = call i32 @test_crc16(ptr noundef %31, i64 noundef 32768)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %52

35:                                               ; preds = %30
  %36 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 0
  %37 = call i32 @test_crc16_update(ptr noundef %36, i64 noundef 32768)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %52

40:                                               ; preds = %35
  %41 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 0
  %42 = call i32 @test_crc16_32bit_words(ptr noundef %41, i64 noundef 8192)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %52

45:                                               ; preds = %40
  %46 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 0
  %47 = call i32 @test_crc16_64bit_words(ptr noundef %46, i64 noundef 4096)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %52

50:                                               ; preds = %45
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %52

52:                                               ; preds = %50, %49, %44, %39, %34, %29
  call void @llvm.lifetime.end.p0(i64 32768, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %53 = load i32, ptr %1, align 4
  ret i32 %53
}

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @crc8_update_ref(i8 noundef zeroext, i8 noundef zeroext) #0

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc8(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16_update(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16_32bit_words(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16_64bit_words(ptr noundef, i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @test_crc() local_unnamed_addr #0 {
  %1 = alloca [32768 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32768) %1, i8 0, i64 32768, i1 false)
  br label %2

2:                                                ; preds = %0, %2
  %3 = phi i8 [ 0, %0 ], [ %5, %2 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %2 ]
  %4 = trunc i64 %indvars.iv to i8
  %5 = tail call zeroext i8 @crc8_update_ref(i8 noundef zeroext %4, i8 noundef zeroext %3)
  %6 = getelementptr inbounds [32768 x i8], ptr %1, i64 0, i64 %indvars.iv
  store i8 %5, ptr %6, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 32768
  br i1 %exitcond.not, label %7, label %2, !llvm.loop !8

7:                                                ; preds = %2
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %9 = call i32 @test_crc8(ptr noundef nonnull %1, i64 noundef 32768)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %20, label %10

10:                                               ; preds = %7
  %11 = call i32 @test_crc16(ptr noundef nonnull %1, i64 noundef 32768)
  %.not7 = icmp eq i32 %11, 0
  br i1 %.not7, label %20, label %12

12:                                               ; preds = %10
  %13 = call i32 @test_crc16_update(ptr noundef nonnull %1, i64 noundef 32768)
  %.not8 = icmp eq i32 %13, 0
  br i1 %.not8, label %20, label %14

14:                                               ; preds = %12
  %15 = call i32 @test_crc16_32bit_words(ptr noundef nonnull %1, i64 noundef 8192)
  %.not9 = icmp eq i32 %15, 0
  br i1 %.not9, label %20, label %16

16:                                               ; preds = %14
  %17 = call i32 @test_crc16_64bit_words(ptr noundef nonnull %1, i64 noundef 4096)
  %.not10 = icmp eq i32 %17, 0
  br i1 %.not10, label %20, label %18

18:                                               ; preds = %16
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %20

20:                                               ; preds = %16, %14, %12, %10, %7, %18
  %.06 = phi i32 [ 1, %18 ], [ 0, %7 ], [ 0, %10 ], [ 0, %12 ], [ 0, %14 ], [ 0, %16 ]
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %1) #4
  ret i32 %.06
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @crc8_update_ref(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc8(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16_update(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16_32bit_words(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_crc16_64bit_words(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass