; LLVM IR from ARM-software/Arm-2D :: examples/common/controls (cloudy_glass)

; 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.cloudy_glass_t = type { %struct.anon }
%struct.anon = type { %struct.cloudy_glass_cfg_t, [1 x i64], %struct.arm_2d_helper_dirty_region_item_t, %struct.arm_2d_filter_iir_blur_descriptor_t, %struct.dynamic_nebula_t }
%struct.cloudy_glass_cfg_t = type { ptr, %struct.arm_2d_size_t, i16, float, ptr, i16, i16, i8 }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.arm_2d_helper_dirty_region_item_t = type { [48 x i8], %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_filter_iir_blur_descriptor_t = type { [72 x i8], %struct.arm_2d_scratch_mem_t }
%struct.arm_2d_scratch_mem_t = type { %union.anon.1, i64 }
%union.anon.1 = type { %union.anon.2 }
%union.anon.2 = type { %struct.anon.3 }
%struct.anon.3 = type { i32 }
%struct.dynamic_nebula_t = type { [56 x i8], ptr }

@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.cloudy_glass_set_colour = external hidden unnamed_addr constant [57 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @cloudy_glass_set_colour(ptr noundef nonnull %0, i16 noundef zeroext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i16 %1, ptr %4, align 2, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = icmp ne ptr null, %5
  br i1 %6, label %7, label %8

7:                                                ; preds = %2
  br label %9

8:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 203, ptr noundef @__PRETTY_FUNCTION__.cloudy_glass_set_colour) #2
  unreachable

9:                                                ; preds = %7
  %10 = load i16, ptr %4, align 2, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.cloudy_glass_t, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.anon, ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %struct.cloudy_glass_cfg_t, ptr %13, i32 0, i32 6
  store i16 %10, ptr %14, align 2, !tbaa !11
  ret void
}

attributes #0 = { 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 #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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 34}
!12 = !{!"cloudy_glass_t", !13, i64 0}
!13 = !{!"", !14, i64 0, !7, i64 40, !18, i64 48, !20, i64 104, !23, i64 192}
!14 = !{!"cloudy_glass_cfg_t", !6, i64 0, !15, i64 8, !10, i64 12, !16, i64 16, !6, i64 24, !10, i64 32, !10, i64 34, !17, i64 36}
!15 = !{!"arm_2d_size_t", !10, i64 0, !10, i64 2}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!"arm_2d_helper_dirty_region_item_t", !7, i64 0, !19, i64 48}
!19 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!20 = !{!"arm_2d_filter_iir_blur_descriptor_t", !7, i64 0, !21, i64 72}
!21 = !{!"arm_2d_scratch_mem_t", !7, i64 0, !22, i64 8}
!22 = !{!"long", !7, i64 0}
!23 = !{!"dynamic_nebula_t", !7, i64 0, !6, i64 56}


; 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: write) uwtable
define dso_local void @cloudy_glass_set_colour(ptr nocapture noundef nonnull writeonly %0, i16 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 34
  store i16 %1, ptr %3, align 2, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !13, i64 34}
!6 = !{!"cloudy_glass_t", !7, i64 0}
!7 = !{!"", !8, i64 0, !10, i64 40, !16, i64 48, !18, i64 104, !21, i64 192}
!8 = !{!"cloudy_glass_cfg_t", !9, i64 0, !12, i64 8, !13, i64 12, !14, i64 16, !9, i64 24, !13, i64 32, !13, i64 34, !15, i64 36}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"arm_2d_size_t", !13, i64 0, !13, i64 2}
!13 = !{!"short", !10, i64 0}
!14 = !{!"float", !10, i64 0}
!15 = !{!"_Bool", !10, i64 0}
!16 = !{!"arm_2d_helper_dirty_region_item_t", !10, i64 0, !17, i64 48}
!17 = !{!"arm_2d_region_t", !10, i64 0, !10, i64 4}
!18 = !{!"arm_2d_filter_iir_blur_descriptor_t", !10, i64 0, !19, i64 72}
!19 = !{!"arm_2d_scratch_mem_t", !10, i64 0, !20, i64 8}
!20 = !{!"long", !10, i64 0}
!21 = !{!"dynamic_nebula_t", !10, i64 0, !9, i64 56}


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