; LLVM IR from octu0/blurry :: mt (libprepared_mtncc)

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

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

declare ptr @create_rgba_buffer(ptr noundef, i32 noundef, i32 noundef) #1

declare void @free_buf(ptr noundef) #1

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

declare ptr @create_double_array_buffer(ptr noundef, i32 noundef, i32 noundef) #1

declare ptr @create_float_array_buffer(ptr noundef, i32 noundef, i32 noundef) #1

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

24:                                               ; preds = %5
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %89

25:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = call ptr @create_float_array_buffer(ptr noundef %28, i32 noundef %31, i32 noundef %34)
  store ptr %35, ptr %14, align 8, !tbaa !5
  %36 = load ptr, ptr %14, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %40

38:                                               ; preds = %25
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free_buf(ptr noundef %39)
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %88

40:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !14
  %50 = call ptr @create_float_array_buffer(ptr noundef %43, i32 noundef %46, i32 noundef %49)
  store ptr %50, ptr %15, align 8, !tbaa !5
  %51 = load ptr, ptr %15, align 8, !tbaa !5
  %52 = icmp eq ptr %51, null
  br i1 %52, label %53, label %56

53:                                               ; preds = %40
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free_buf(ptr noundef %54)
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free_buf(ptr noundef %55)
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %87

56:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = call ptr @create_double_array_buffer(ptr noundef %57, i32 noundef %58, i32 noundef %59)
  store ptr %60, ptr %16, align 8, !tbaa !5
  %61 = load ptr, ptr %16, align 8, !tbaa !5
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %67

63:                                               ; preds = %56
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free_buf(ptr noundef %64)
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free_buf(ptr noundef %65)
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free_buf(ptr noundef %66)
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %86

67:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 8, !tbaa !13
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.prepared_ncc_template_t, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !14
  %79 = load ptr, ptr %16, align 8, !tbaa !5
  %80 = call i32 @prepared_match_template_ncc(ptr noundef %68, i32 noundef %69, i32 noundef %70, ptr noundef %71, ptr noundef %72, i32 noundef %75, i32 noundef %78, ptr noundef %79)
  store i32 %80, ptr %17, align 4, !tbaa !9
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free_buf(ptr noundef %81)
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free_buf(ptr noundef %82)
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free_buf(ptr noundef %83)
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free_buf(ptr noundef %84)
  %85 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %85, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %86

86:                                               ; preds = %67, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %87

87:                                               ; preds = %86, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %88

88:                                               ; preds = %87, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %89

89:                                               ; preds = %88, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %90 = load i32, ptr %6, align 4
  ret i32 %90
}

declare i32 @prepared_match_template_ncc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"prepared_ncc_template_t", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 0}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !6, i64 16}


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

declare ptr @create_rgba_buffer(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @free_buf(ptr noundef) local_unnamed_addr #0

declare ptr @create_double_array_buffer(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare ptr @create_float_array_buffer(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @libprepared_mtncc(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = tail call ptr @create_rgba_buffer(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2
  %7 = icmp eq ptr %6, null
  br i1 %7, label %30, label %8

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = load i32, ptr %3, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %3, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %14 = tail call ptr @create_float_array_buffer(ptr noundef %10, i32 noundef %11, i32 noundef %13) #2
  %15 = icmp eq ptr %14, null
  br i1 %15, label %.sink.split, label %16

16:                                               ; preds = %8
  %17 = getelementptr inbounds i8, ptr %3, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %3, align 8, !tbaa !11
  %20 = load i32, ptr %12, align 4, !tbaa !12
  %21 = tail call ptr @create_float_array_buffer(ptr noundef %18, i32 noundef %19, i32 noundef %20) #2
  %22 = icmp eq ptr %21, null
  br i1 %22, label %.sink.split.sink.split, label %23

23:                                               ; preds = %16
  %24 = tail call ptr @create_double_array_buffer(ptr noundef %4, i32 noundef %1, i32 noundef %2) #2
  %25 = icmp eq ptr %24, null
  br i1 %25, label %.sink.split.sink.split.sink.split, label %26

26:                                               ; preds = %23
  %27 = load i32, ptr %3, align 8, !tbaa !11
  %28 = load i32, ptr %12, align 4, !tbaa !12
  %29 = tail call i32 @prepared_match_template_ncc(ptr noundef nonnull %6, i32 noundef %1, i32 noundef %2, ptr noundef nonnull %14, ptr noundef nonnull %21, i32 noundef %27, i32 noundef %28, ptr noundef nonnull %24) #2
  tail call void @free_buf(ptr noundef nonnull %6) #2
  br label %.sink.split.sink.split.sink.split

.sink.split.sink.split.sink.split:                ; preds = %23, %26
  %.sink40 = phi ptr [ %14, %26 ], [ %6, %23 ]
  %.sink39.ph = phi ptr [ %21, %26 ], [ %14, %23 ]
  %.sink.ph.ph = phi ptr [ %24, %26 ], [ %21, %23 ]
  %.3.ph.ph.ph = phi i32 [ %29, %26 ], [ 1, %23 ]
  tail call void @free_buf(ptr noundef nonnull %.sink40) #2
  br label %.sink.split.sink.split

.sink.split.sink.split:                           ; preds = %.sink.split.sink.split.sink.split, %16
  %.sink39 = phi ptr [ %6, %16 ], [ %.sink39.ph, %.sink.split.sink.split.sink.split ]
  %.sink.ph = phi ptr [ %14, %16 ], [ %.sink.ph.ph, %.sink.split.sink.split.sink.split ]
  %.3.ph.ph = phi i32 [ 1, %16 ], [ %.3.ph.ph.ph, %.sink.split.sink.split.sink.split ]
  tail call void @free_buf(ptr noundef nonnull %.sink39) #2
  br label %.sink.split

.sink.split:                                      ; preds = %.sink.split.sink.split, %8
  %.sink = phi ptr [ %6, %8 ], [ %.sink.ph, %.sink.split.sink.split ]
  %.3.ph = phi i32 [ 1, %8 ], [ %.3.ph.ph, %.sink.split.sink.split ]
  tail call void @free_buf(ptr noundef nonnull %.sink) #2
  br label %30

30:                                               ; preds = %.sink.split, %5
  %.3 = phi i32 [ 1, %5 ], [ %.3.ph, %.sink.split ]
  ret i32 %.3
}

declare i32 @prepared_match_template_ncc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 }

!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 8}
!6 = !{!"prepared_ncc_template_t", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 16}


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