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

; 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_i_list_region_calculator_t = type { ptr, ptr, i32 }
%struct.number_list_t = type { %union.anon, %struct.anon.27 }
%union.anon = type { %struct.__simple_list_t }
%struct.__simple_list_t = type { %union.anon.0, %struct.anon.24, [192 x i8] }
%union.anon.0 = type { %struct.__arm_2d_list_core_t }
%struct.__arm_2d_list_core_t = type { %struct.anon, %struct.anon.2, %struct.anon.21 }
%struct.anon = type { %struct.__arm_2d_list_core_cfg_t }
%struct.__arm_2d_list_core_cfg_t = type { %struct.arm_2d_size_t, ptr, %union.anon.1, ptr, ptr, ptr, i32, ptr, i16, i16, i16, i16, ptr }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.1 = type { ptr }
%struct.anon.2 = type { %struct.anon.3, [112 x i8] }
%struct.anon.3 = type { %struct.arm_2d_tile_t, %struct.arm_2d_tile_t, %struct.__arm_2d_list_work_area_t, i8, %union.anon.19 }
%struct.arm_2d_tile_t = type { %union.anon.4, %union.anon.15, %union.anon.18 }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { i8, %union.arm_2d_color_info_t, %union.anon.8 }
%union.arm_2d_color_info_t = type { %struct.anon.6 }
%struct.anon.6 = type { i8 }
%union.anon.8 = type { i16 }
%union.anon.15 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.16, %union.anon.17 }
%union.anon.16 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.17 = type { %struct.arm_2d_size_t }
%union.anon.18 = type { ptr }
%struct.__arm_2d_list_work_area_t = type { ptr, %struct.arm_2d_region_t, %struct.arm_2d_list_item_param_t, i32 }
%struct.arm_2d_list_item_param_t = type { i8, i8, i16 }
%union.anon.19 = type { %struct.anon.20 }
%struct.anon.20 = type { i16 }
%struct.anon.21 = type { i8, i8, i16, i32, %union.anon.22 }
%union.anon.22 = type { %struct.anon.23 }
%struct.anon.23 = type { i16, i16, i16, i16 }
%struct.anon.24 = type { %struct.__simple_list_cfg_t }
%struct.__simple_list_cfg_t = type { i16, i8, i8, i8, %union.anon.25, %union.anon.26, %union.COLOUR_TYPE_T, %struct.arm_2d_size_t, %struct.arm_2d_size_t, i8, i8, i16, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr }
%union.anon.25 = type { %union.COLOUR_TYPE_T }
%union.anon.26 = type { %union.COLOUR_TYPE_T }
%union.COLOUR_TYPE_T = type { i32 }
%struct.anon.27 = type { ptr, i32, i16 }
%struct.number_list_cfg_t = type { %union.anon.28, ptr, i32, i16 }
%union.anon.28 = type { %struct.__simple_list_cfg_t }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.number_list_init = external hidden unnamed_addr constant [68 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@ARM_2D_LIST_CALCULATOR_MIDDLE_ALIGNED_FIXED_SIZED_ITEM_NO_STATUS_CHECK_VERTICAL = external constant %struct.arm_2d_i_list_region_calculator_t, align 8
@number_list_init.c_chDefaultFormatString = external hidden constant [3 x i8], align 1

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

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 125, ptr noundef @__PRETTY_FUNCTION__.number_list_init) #4
  unreachable

12:                                               ; preds = %10
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr null, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  br label %17

16:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 126, ptr noundef @__PRETTY_FUNCTION__.number_list_init) #4
  unreachable

17:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.number_list_t, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.number_list_cfg_t, ptr %20, i32 0, i32 0
  %22 = call i32 @__simple_list_init(ptr noundef %19, ptr noundef %21, ptr noundef @ARM_2D_LIST_CALCULATOR_MIDDLE_ALIGNED_FIXED_SIZED_ITEM_NO_STATUS_CHECK_VERTICAL)
  store i32 %22, ptr %6, align 4, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = icmp ne i32 0, %23
  br i1 %24, label %25, label %27

25:                                               ; preds = %17
  %26 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %26, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %66

27:                                               ; preds = %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.number_list_cfg_t, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.__simple_list_cfg_t, ptr %29, i32 0, i32 12
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = icmp eq ptr null, %31
  br i1 %32, label %33, label %36

33:                                               ; preds = %27
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.number_list_t, ptr %34, i32 0, i32 0
  call void @__simple_list_set_draw_list_item_handler(ptr noundef %35, ptr noundef @__arm_2d_number_list_draw_list_core_item)
  br label %36

36:                                               ; preds = %33, %27
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.number_list_cfg_t, ptr %37, i32 0, i32 3
  %39 = load i16, ptr %38, align 4, !tbaa !12
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.number_list_t, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds %struct.anon.27, ptr %41, i32 0, i32 2
  store i16 %39, ptr %42, align 4, !tbaa !15
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.number_list_cfg_t, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %44, align 8, !tbaa !18
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.number_list_t, ptr %46, i32 0, i32 1
  %48 = getelementptr inbounds %struct.anon.27, ptr %47, i32 0, i32 1
  store i32 %45, ptr %48, align 8, !tbaa !19
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.number_list_cfg_t, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.number_list_t, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.anon.27, ptr %53, i32 0, i32 0
  store ptr %51, ptr %54, align 8, !tbaa !21
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.number_list_t, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.anon.27, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !21
  %59 = icmp eq ptr null, %58
  br i1 %59, label %60, label %64

60:                                               ; preds = %36
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.number_list_t, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct.anon.27, ptr %62, i32 0, i32 0
  store ptr @number_list_init.c_chDefaultFormatString, ptr %63, align 8, !tbaa !21
  br label %64

64:                                               ; preds = %60, %36
  %65 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %65, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %66

66:                                               ; preds = %64, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %67 = load i32, ptr %3, align 4
  ret i32 %67
}

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

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

declare i32 @__simple_list_init(ptr noundef, ptr noundef, ptr noundef) #3

declare void @__simple_list_set_draw_list_item_handler(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_number_list_draw_list_core_item(ptr noundef, ptr noundef, i1 noundef zeroext, ptr noundef) #0

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

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 108}
!13 = !{!"number_list_cfg_t", !7, i64 0, !6, i64 96, !10, i64 104, !14, i64 108}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !14, i64 588}
!16 = !{!"number_list_t", !7, i64 0, !17, i64 576}
!17 = !{!"", !6, i64 0, !10, i64 8, !14, i64 12}
!18 = !{!13, !10, i64 104}
!19 = !{!16, !10, i64 584}
!20 = !{!13, !6, i64 96}
!21 = !{!16, !6, i64 576}


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

%struct.arm_2d_i_list_region_calculator_t = type { ptr, ptr, i32 }

@ARM_2D_LIST_CALCULATOR_MIDDLE_ALIGNED_FIXED_SIZED_ITEM_NO_STATUS_CHECK_VERTICAL = external constant %struct.arm_2d_i_list_region_calculator_t, align 8
@number_list_init.c_chDefaultFormatString = external hidden constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @number_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1) local_unnamed_addr #0 {
  %3 = tail call i32 @__simple_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull @ARM_2D_LIST_CALCULATOR_MIDDLE_ALIGNED_FIXED_SIZED_ITEM_NO_STATUS_CHECK_VERTICAL) #2
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %20

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %4
  tail call void @__simple_list_set_draw_list_item_handler(ptr noundef nonnull %0, ptr noundef nonnull @__arm_2d_number_list_draw_list_core_item) #2
  br label %9

9:                                                ; preds = %8, %4
  %10 = getelementptr inbounds i8, ptr %1, i64 108
  %11 = load i16, ptr %10, align 4, !tbaa !8
  %12 = getelementptr inbounds i8, ptr %0, i64 576
  %13 = getelementptr inbounds i8, ptr %0, i64 588
  store i16 %11, ptr %13, align 4, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %1, i64 104
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 584
  store i32 %15, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %1, i64 96
  %18 = load ptr, ptr %17, align 8, !tbaa !18
  %19 = icmp eq ptr %18, null
  %spec.select = select i1 %19, ptr @number_list_init.c_chDefaultFormatString, ptr %18
  store ptr %spec.select, ptr %12, align 8, !tbaa !19
  br label %20

20:                                               ; preds = %2, %9
  ret i32 %3
}

declare i32 @__simple_list_init(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @__simple_list_set_draw_list_item_handler(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_number_list_draw_list_core_item(ptr noundef, ptr noundef, i1 noundef zeroext, ptr noundef) #0

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 = { "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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !12, i64 108}
!9 = !{!"number_list_cfg_t", !6, i64 0, !10, i64 96, !11, i64 104, !12, i64 108}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"short", !6, i64 0}
!13 = !{!14, !12, i64 588}
!14 = !{!"number_list_t", !6, i64 0, !15, i64 576}
!15 = !{!"", !10, i64 0, !11, i64 8, !12, i64 12}
!16 = !{!9, !11, i64 104}
!17 = !{!14, !11, i64 584}
!18 = !{!9, !10, i64 96}
!19 = !{!14, !10, i64 576}


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