; LLVM IR from zeux/meshoptimizer :: tools/codecfuzz.ll (Z13fuzzRoundtripPKhmmi)

; 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.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [43 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13fuzzRoundtripPKhmmi(ptr noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = udiv i64 %16, %17
  store i64 %18, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = call i64 @meshopt_encodeVertexBufferBound(i64 noundef %19, i64 noundef %20)
  store i64 %21, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %22 = load i64, ptr %10, align 8, !tbaa !9
  %23 = call noalias ptr @malloc(i64 noundef %22) #8
  store ptr %23, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = mul i64 %24, %25
  %27 = call noalias ptr @malloc(i64 noundef %26) #8
  store ptr %27, ptr %12, align 8, !tbaa !5
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %4
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br label %33

33:                                               ; preds = %30, %4
  %34 = phi i1 [ false, %4 ], [ %32, %30 ]
  br i1 %34, label %35, label %36

35:                                               ; preds = %33
  br label %38

36:                                               ; preds = %33
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 27, ptr noundef @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #9
  unreachable

37:                                               ; No predecessors!
  br label %38

38:                                               ; preds = %37, %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = load i64, ptr %10, align 8, !tbaa !9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = load i32, ptr %8, align 4, !tbaa !11
  %45 = call i64 @meshopt_encodeVertexBufferLevel(ptr noundef %39, i64 noundef %40, ptr noundef %41, i64 noundef %42, i64 noundef %43, i32 noundef %44, i32 noundef -1)
  store i64 %45, ptr %13, align 8, !tbaa !9
  %46 = load i64, ptr %13, align 8, !tbaa !9
  %47 = icmp ugt i64 %46, 0
  br i1 %47, label %48, label %52

48:                                               ; preds = %38
  %49 = load i64, ptr %13, align 8, !tbaa !9
  %50 = load i64, ptr %10, align 8, !tbaa !9
  %51 = icmp ule i64 %49, %50
  br label %52

52:                                               ; preds = %48, %38
  %53 = phi i1 [ false, %38 ], [ %51, %48 ]
  br i1 %53, label %54, label %55

54:                                               ; preds = %52
  br label %57

55:                                               ; preds = %52
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 30, ptr noundef @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #9
  unreachable

56:                                               ; No predecessors!
  br label %57

57:                                               ; preds = %56, %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = load i64, ptr %10, align 8, !tbaa !9
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  %61 = load i64, ptr %13, align 8, !tbaa !9
  %62 = sub i64 0, %61
  %63 = getelementptr inbounds i8, ptr %60, i64 %62
  %64 = load i64, ptr %13, align 8, !tbaa !9
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load i64, ptr %9, align 8, !tbaa !9
  %67 = load i64, ptr %7, align 8, !tbaa !9
  %68 = load i32, ptr %8, align 4, !tbaa !11
  %69 = call i64 @meshopt_encodeVertexBufferLevel(ptr noundef %63, i64 noundef %64, ptr noundef %65, i64 noundef %66, i64 noundef %67, i32 noundef %68, i32 noundef -1)
  store i64 %69, ptr %14, align 8, !tbaa !9
  %70 = load i64, ptr %14, align 8, !tbaa !9
  %71 = load i64, ptr %13, align 8, !tbaa !9
  %72 = icmp eq i64 %70, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %57
  br label %76

74:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 35, ptr noundef @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #9
  unreachable

75:                                               ; No predecessors!
  br label %76

76:                                               ; preds = %75, %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load i64, ptr %9, align 8, !tbaa !9
  %79 = load i64, ptr %7, align 8, !tbaa !9
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = load i64, ptr %10, align 8, !tbaa !9
  %82 = getelementptr inbounds i8, ptr %80, i64 %81
  %83 = load i64, ptr %13, align 8, !tbaa !9
  %84 = sub i64 0, %83
  %85 = getelementptr inbounds i8, ptr %82, i64 %84
  %86 = load i64, ptr %13, align 8, !tbaa !9
  %87 = call i32 @meshopt_decodeVertexBuffer(ptr noundef %77, i64 noundef %78, i64 noundef %79, ptr noundef %85, i64 noundef %86)
  store i32 %87, ptr %15, align 4, !tbaa !11
  %88 = load i32, ptr %15, align 4, !tbaa !11
  %89 = icmp eq i32 %88, 0
  br i1 %89, label %90, label %91

90:                                               ; preds = %76
  br label %93

91:                                               ; preds = %76
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 38, ptr noundef @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #9
  unreachable

92:                                               ; No predecessors!
  br label %93

93:                                               ; preds = %92, %90
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = load i64, ptr %9, align 8, !tbaa !9
  %97 = load i64, ptr %7, align 8, !tbaa !9
  %98 = mul i64 %96, %97
  %99 = call i32 @memcmp(ptr noundef %94, ptr noundef %95, i64 noundef %98) #10
  %100 = icmp eq i32 %99, 0
  br i1 %100, label %101, label %102

101:                                              ; preds = %93
  br label %104

102:                                              ; preds = %93
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 40, ptr noundef @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #9
  unreachable

103:                                              ; No predecessors!
  br label %104

104:                                              ; preds = %103, %101
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %105) #7
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %106) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  ret void
}

declare i64 @meshopt_encodeVertexBufferBound(i64 noundef, i64 noundef) #5

declare i64 @meshopt_encodeVertexBufferLevel(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #5

declare i32 @meshopt_decodeVertexBuffer(ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef) #5

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #6

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 = { noreturn 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 "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 = { 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 #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 willreturn memory(read) "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind willreturn memory(read) }

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; 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.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [43 x i8], align 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 #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13fuzzRoundtripPKhmmi(ptr noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = udiv i64 %1, %2
  %6 = tail call i64 @meshopt_encodeVertexBufferBound(i64 noundef %5, i64 noundef %2)
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #6
  %8 = mul i64 %5, %2
  %9 = tail call noalias ptr @malloc(i64 noundef %8) #6
  %10 = icmp ne ptr %7, null
  %11 = icmp ne ptr %9, null
  %12 = and i1 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 27, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #7
  unreachable

14:                                               ; preds = %4
  %15 = tail call i64 @meshopt_encodeVertexBufferLevel(ptr noundef nonnull %7, i64 noundef %6, ptr noundef %0, i64 noundef %5, i64 noundef %2, i32 noundef %3, i32 noundef -1)
  %16 = add i64 %15, -1
  %17 = icmp ult i64 %16, %6
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 30, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #7
  unreachable

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %7, i64 %6
  %21 = sub i64 0, %15
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  %23 = tail call i64 @meshopt_encodeVertexBufferLevel(ptr noundef nonnull %22, i64 noundef %15, ptr noundef %0, i64 noundef %5, i64 noundef %2, i32 noundef %3, i32 noundef -1)
  %24 = icmp eq i64 %23, %15
  br i1 %24, label %26, label %25

25:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 35, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #7
  unreachable

26:                                               ; preds = %19
  %27 = tail call i32 @meshopt_decodeVertexBuffer(ptr noundef nonnull %9, i64 noundef %5, i64 noundef %2, ptr noundef nonnull %22, i64 noundef %15)
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 38, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #7
  unreachable

30:                                               ; preds = %26
  %bcmp = tail call i32 @bcmp(ptr %0, ptr nonnull %9, i64 %8)
  %31 = icmp eq i32 %bcmp, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %30
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 40, ptr noundef nonnull @__PRETTY_FUNCTION__._Z13fuzzRoundtripPKhmmi) #7
  unreachable

33:                                               ; preds = %30
  tail call void @free(ptr noundef nonnull %9) #8
  tail call void @free(ptr noundef nonnull %7) #8
  ret void
}

declare i64 @meshopt_encodeVertexBufferBound(i64 noundef, i64 noundef) local_unnamed_addr #4

declare i64 @meshopt_encodeVertexBufferLevel(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

declare i32 @meshopt_decodeVertexBuffer(ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5

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 = { noreturn 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 nounwind willreturn allockind("free") 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 #3 = { 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 #4 = { "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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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)"}


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