; LLVM IR from ARM-software/Arm-2D :: Helper/Source (arm_2d_helper)

; 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.arm_2d_helper_film_t = type { %union.anon.16, i16, i16, i16, i16 }
%union.anon.16 = type { %struct.arm_2d_tile_t }
%struct.arm_2d_tile_t = type { %union.anon.2, %union.anon.13, %union.anon.14 }
%union.anon.2 = type { %struct.anon.3 }
%struct.anon.3 = type { i8, %union.arm_2d_color_info_t, %union.anon.6 }
%union.arm_2d_color_info_t = type { %struct.anon.4 }
%struct.anon.4 = type { i8 }
%union.anon.6 = type { i16 }
%union.anon.13 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.1 }
%union.anon = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.1 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.14 = type { ptr }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_helper_film_next_frame = external hidden unnamed_addr constant [60 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_2d_helper_film_next_frame(ptr noundef nonnull %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  store i8 0, ptr %3, align 1, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr null, %5
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  br label %9

8:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 657, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_film_next_frame) #4
  unreachable

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.arm_2d_helper_film_t, ptr %10, i32 0, i32 0
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %12, i32 0, i32 1
  %14 = getelementptr inbounds %struct.arm_2d_region_t, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %struct.arm_2d_size_t, ptr %14, i32 0, i32 0
  %16 = load i16, ptr %15, align 4, !tbaa !11
  %17 = sext i16 %16 to i32
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds %struct.arm_2d_region_t, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.arm_2d_location_t, ptr %20, i32 0, i32 0
  %22 = load i16, ptr %21, align 4, !tbaa !11
  %23 = sext i16 %22 to i32
  %24 = add nsw i32 %23, %17
  %25 = trunc i32 %24 to i16
  store i16 %25, ptr %21, align 4, !tbaa !11
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.arm_2d_region_t, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.arm_2d_location_t, ptr %28, i32 0, i32 0
  %30 = load i16, ptr %29, align 4, !tbaa !11
  %31 = sext i16 %30 to i32
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.arm_2d_region_t, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %struct.arm_2d_size_t, ptr %34, i32 0, i32 0
  %36 = load i16, ptr %35, align 4, !tbaa !11
  %37 = sext i16 %36 to i32
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.arm_2d_helper_film_t, ptr %38, i32 0, i32 1
  %40 = load i16, ptr %39, align 8, !tbaa !12
  %41 = zext i16 %40 to i32
  %42 = mul nsw i32 %37, %41
  %43 = icmp sge i32 %31, %42
  br i1 %43, label %44, label %63

44:                                               ; preds = %9
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.arm_2d_region_t, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.arm_2d_location_t, ptr %47, i32 0, i32 0
  store i16 0, ptr %48, align 4, !tbaa !11
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.arm_2d_region_t, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.arm_2d_size_t, ptr %51, i32 0, i32 1
  %53 = load i16, ptr %52, align 2, !tbaa !11
  %54 = sext i16 %53 to i32
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.arm_2d_region_t, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds %struct.arm_2d_location_t, ptr %57, i32 0, i32 1
  %59 = load i16, ptr %58, align 2, !tbaa !11
  %60 = sext i16 %59 to i32
  %61 = add nsw i32 %60, %54
  %62 = trunc i32 %61 to i16
  store i16 %62, ptr %58, align 2, !tbaa !11
  br label %63

63:                                               ; preds = %44, %9
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.arm_2d_helper_film_t, ptr %64, i32 0, i32 4
  %66 = load i16, ptr %65, align 2, !tbaa !15
  %67 = add i16 %66, 1
  store i16 %67, ptr %65, align 2, !tbaa !15
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.arm_2d_helper_film_t, ptr %68, i32 0, i32 4
  %70 = load i16, ptr %69, align 2, !tbaa !15
  %71 = zext i16 %70 to i32
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.arm_2d_helper_film_t, ptr %72, i32 0, i32 2
  %74 = load i16, ptr %73, align 2, !tbaa !16
  %75 = zext i16 %74 to i32
  %76 = icmp sge i32 %71, %75
  br i1 %76, label %77, label %88

77:                                               ; preds = %63
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.arm_2d_helper_film_t, ptr %78, i32 0, i32 4
  store i16 0, ptr %79, align 2, !tbaa !15
  store i8 1, ptr %3, align 1, !tbaa !9
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %80, i32 0, i32 1
  %82 = getelementptr inbounds %struct.arm_2d_region_t, ptr %81, i32 0, i32 0
  %83 = getelementptr inbounds %struct.arm_2d_location_t, ptr %82, i32 0, i32 0
  store i16 0, ptr %83, align 4, !tbaa !11
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %84, i32 0, i32 1
  %86 = getelementptr inbounds %struct.arm_2d_region_t, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.arm_2d_location_t, ptr %86, i32 0, i32 1
  store i16 0, ptr %87, align 2, !tbaa !11
  br label %88

88:                                               ; preds = %77, %63
  %89 = load i8, ptr %3, align 1, !tbaa !9, !range !17, !noundef !18
  %90 = trunc i8 %89 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret i1 %90
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }
attributes #4 = { noreturn 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 = !{!"_Bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 24}
!13 = !{!"arm_2d_helper_film_t", !7, i64 0, !14, i64 24, !14, i64 26, !14, i64 28, !14, i64 30}
!14 = !{!"short", !7, i64 0}
!15 = !{!13, !14, i64 30}
!16 = !{!13, !14, i64 26}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef zeroext i1 @arm_2d_helper_film_next_frame(ptr nocapture noundef nonnull %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i16, ptr %3, align 4, !tbaa !5
  %5 = load i16, ptr %2, align 4, !tbaa !5
  %6 = add i16 %5, %4
  store i16 %6, ptr %2, align 4, !tbaa !5
  %7 = sext i16 %6 to i32
  %8 = sext i16 %4 to i32
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load i16, ptr %9, align 8, !tbaa !8
  %11 = zext i16 %10 to i32
  %12 = mul nsw i32 %11, %8
  %.not = icmp sgt i32 %12, %7
  br i1 %.not, label %19, label %13

13:                                               ; preds = %1
  store i16 0, ptr %2, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 10
  %15 = load i16, ptr %14, align 2, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 6
  %17 = load i16, ptr %16, align 2, !tbaa !5
  %18 = add i16 %17, %15
  store i16 %18, ptr %16, align 2, !tbaa !5
  br label %19

19:                                               ; preds = %13, %1
  %20 = getelementptr inbounds i8, ptr %0, i64 30
  %21 = load i16, ptr %20, align 2, !tbaa !11
  %22 = add i16 %21, 1
  store i16 %22, ptr %20, align 2, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %0, i64 26
  %24 = load i16, ptr %23, align 2, !tbaa !12
  %.not16 = icmp uge i16 %22, %24
  br i1 %.not16, label %25, label %27

25:                                               ; preds = %19
  store i16 0, ptr %20, align 2, !tbaa !11
  store i16 0, ptr %2, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 6
  store i16 0, ptr %26, align 2, !tbaa !5
  br label %27

27:                                               ; preds = %25, %19
  ret i1 %.not16
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 = !{!9, !10, i64 24}
!9 = !{!"arm_2d_helper_film_t", !6, i64 0, !10, i64 24, !10, i64 26, !10, i64 28, !10, i64 30}
!10 = !{!"short", !6, i64 0}
!11 = !{!9, !10, i64 30}
!12 = !{!9, !10, i64 26}


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