; LLVM IR from ARM-software/Arm-2D :: examples/common/controls/icon_list.ll_ (icon_list_init)

; 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.icon_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, i16 }
%struct.icon_list_cfg_t = type { %union.anon.28, %struct.anon.29 }
%union.anon.28 = type { %struct.__simple_list_cfg_t }
%struct.anon.29 = type { ptr, i16 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__.__icon_list_init = external hidden unnamed_addr constant [101 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

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

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 130, ptr noundef @__PRETTY_FUNCTION__.__icon_list_init) #4
  unreachable

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

17:                                               ; preds = %14
  br label %19

18:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 131, ptr noundef @__PRETTY_FUNCTION__.__icon_list_init) #4
  unreachable

19:                                               ; preds = %17
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr null, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 132, ptr noundef @__PRETTY_FUNCTION__.__icon_list_init) #4
  unreachable

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.icon_list_t, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.icon_list_cfg_t, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call i32 @__simple_list_init(ptr noundef %26, ptr noundef %28, ptr noundef %29)
  store i32 %30, ptr %8, align 4, !tbaa !9
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp ne i32 0, %31
  br i1 %32, label %33, label %35

33:                                               ; preds = %24
  %34 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %34, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %74

35:                                               ; preds = %24
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.icon_list_cfg_t, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.__simple_list_cfg_t, ptr %37, i32 0, i32 12
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = icmp eq ptr null, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %35
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.icon_list_t, ptr %42, i32 0, i32 0
  call void @__simple_list_set_draw_list_item_handler(ptr noundef %43, ptr noundef @__arm_2d_icon_list_draw_list_core_item)
  br label %44

44:                                               ; preds = %41, %35
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.icon_list_cfg_t, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.anon.29, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !12
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.icon_list_t, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.anon.27, ptr %50, i32 0, i32 0
  store ptr %48, ptr %51, align 8, !tbaa !16
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.icon_list_cfg_t, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.anon.29, ptr %53, i32 0, i32 1
  %55 = load i16, ptr %54, align 8, !tbaa !18
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.icon_list_t, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %struct.anon.27, ptr %57, i32 0, i32 1
  store i16 %55, ptr %58, align 8, !tbaa !19
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.icon_list_t, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.anon.27, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = icmp eq ptr null, %62
  br i1 %63, label %71, label %64

64:                                               ; preds = %44
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.icon_list_t, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.anon.27, ptr %66, i32 0, i32 1
  %68 = load i16, ptr %67, align 8, !tbaa !19
  %69 = zext i16 %68 to i32
  %70 = icmp eq i32 0, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %64, %44
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %74

72:                                               ; preds = %64
  %73 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %73, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %74

74:                                               ; preds = %72, %71, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %75 = load i32, ptr %4, align 4
  ret i32 %75
}

; 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_icon_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, !6, i64 96}
!13 = !{!"icon_list_cfg_t", !7, i64 0, !14, i64 96}
!14 = !{!"", !6, i64 0, !15, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !6, i64 576}
!17 = !{!"icon_list_t", !7, i64 0, !14, i64 576}
!18 = !{!13, !15, i64 104}
!19 = !{!17, !15, i64 584}


; 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: nounwind uwtable
define dso_local i32 @__icon_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) local_unnamed_addr #0 {
  %4 = tail call i32 @__simple_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #2
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %19

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

9:                                                ; preds = %5
  tail call void @__simple_list_set_draw_list_item_handler(ptr noundef nonnull %0, ptr noundef nonnull @__arm_2d_icon_list_draw_list_core_item) #2
  br label %10

10:                                               ; preds = %9, %5
  %11 = getelementptr inbounds i8, ptr %1, i64 96
  %12 = load ptr, ptr %11, align 8, !tbaa !8
  %13 = getelementptr inbounds i8, ptr %0, i64 576
  store ptr %12, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %1, i64 104
  %15 = load i16, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %0, i64 584
  store i16 %15, ptr %16, align 8, !tbaa !16
  %17 = icmp eq ptr %12, null
  %18 = icmp eq i16 %15, 0
  %or.cond = select i1 %17, i1 true, i1 %18
  %spec.select = select i1 %or.cond, i32 -2, i32 0
  br label %19

19:                                               ; preds = %10, %3
  %.0 = phi i32 [ %4, %3 ], [ %spec.select, %10 ]
  ret i32 %.0
}

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_icon_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, !11, i64 96}
!9 = !{!"icon_list_cfg_t", !6, i64 0, !10, i64 96}
!10 = !{!"", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!"short", !6, i64 0}
!13 = !{!14, !11, i64 576}
!14 = !{!"icon_list_t", !6, i64 0, !10, i64 576}
!15 = !{!9, !12, i64 104}
!16 = !{!14, !12, i64 584}


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