; LLVM IR from ARM-software/Arm-2D :: examples/common/controls/text_list.ll_ (text_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.text_list_cfg_t = type { %union.anon, ptr, ptr }
%union.anon = type { %struct.__simple_list_cfg_t }
%struct.__simple_list_cfg_t = type { i16, i8, i8, i8, %union.anon.0, %union.anon.1, %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.0 = type { %union.COLOUR_TYPE_T }
%union.anon.1 = type { %union.COLOUR_TYPE_T }
%union.COLOUR_TYPE_T = type { i32 }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.text_list_t = type { %union.anon.2, %struct.anon.28 }
%union.anon.2 = type { %struct.__simple_list_t }
%struct.__simple_list_t = type { %union.anon.3, %struct.anon.27, [192 x i8] }
%union.anon.3 = type { %struct.__arm_2d_list_core_t }
%struct.__arm_2d_list_core_t = type { %struct.anon, %struct.anon.5, %struct.anon.24 }
%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.4, ptr, ptr, ptr, i32, ptr, i16, i16, i16, i16, ptr }
%union.anon.4 = type { ptr }
%struct.anon.5 = type { %struct.anon.6, [112 x i8] }
%struct.anon.6 = type { %struct.arm_2d_tile_t, %struct.arm_2d_tile_t, %struct.__arm_2d_list_work_area_t, i8, %union.anon.22 }
%struct.arm_2d_tile_t = type { %union.anon.7, %union.anon.18, %union.anon.21 }
%union.anon.7 = type { %struct.anon.8 }
%struct.anon.8 = type { i8, %union.arm_2d_color_info_t, %union.anon.11 }
%union.arm_2d_color_info_t = type { %struct.anon.9 }
%struct.anon.9 = type { i8 }
%union.anon.11 = type { i16 }
%union.anon.18 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.19, %union.anon.20 }
%union.anon.19 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.20 = type { %struct.arm_2d_size_t }
%union.anon.21 = 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.22 = type { %struct.anon.23 }
%struct.anon.23 = type { i16 }
%struct.anon.24 = type { i8, i8, i16, i32, %union.anon.25 }
%union.anon.25 = type { %struct.anon.26 }
%struct.anon.26 = type { i16, i16, i16, i16 }
%struct.anon.27 = type { %struct.__simple_list_cfg_t }
%struct.anon.28 = type { %struct.anon.29 }
%struct.anon.29 = type { ptr, ptr }

@.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__.__text_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 [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1
@__text_list_init.c_chDefaultFormatString = external hidden constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @__text_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 127, ptr noundef @__PRETTY_FUNCTION__.__text_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 128, ptr noundef @__PRETTY_FUNCTION__.__text_list_init) #4
  unreachable

19:                                               ; preds = %17
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.text_list_cfg_t, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = icmp ne ptr null, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  br label %26

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

26:                                               ; preds = %24
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = icmp ne ptr null, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %31

30:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 130, ptr noundef @__PRETTY_FUNCTION__.__text_list_init) #4
  unreachable

31:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.text_list_t, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.text_list_cfg_t, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i32 @__simple_list_init(ptr noundef %33, ptr noundef %35, ptr noundef %36)
  store i32 %37, ptr %8, align 4, !tbaa !11
  %38 = load i32, ptr %8, align 4, !tbaa !11
  %39 = icmp ne i32 0, %38
  br i1 %39, label %40, label %42

40:                                               ; preds = %31
  %41 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %41, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %87

42:                                               ; preds = %31
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.text_list_cfg_t, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.__simple_list_cfg_t, ptr %44, i32 0, i32 12
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = icmp eq ptr null, %46
  br i1 %47, label %48, label %51

48:                                               ; preds = %42
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.text_list_t, ptr %49, i32 0, i32 0
  call void @__simple_list_set_draw_list_item_handler(ptr noundef %50, ptr noundef @__arm_2d_text_list_draw_list_core_item)
  br label %51

51:                                               ; preds = %48, %42
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.text_list_cfg_t, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.text_list_t, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.anon.28, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds %struct.anon.29, ptr %57, i32 0, i32 1
  store ptr %54, ptr %58, align 8, !tbaa !14
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.text_list_t, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.anon.28, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.anon.29, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  %64 = icmp eq ptr null, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %51
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %87

66:                                               ; preds = %51
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.text_list_cfg_t, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !18
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.text_list_t, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds %struct.anon.28, ptr %71, i32 0, i32 0
  %73 = getelementptr inbounds %struct.anon.29, ptr %72, i32 0, i32 0
  store ptr %69, ptr %73, align 8, !tbaa !19
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.text_list_t, ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %struct.anon.28, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct.anon.29, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  %79 = icmp eq ptr null, %78
  br i1 %79, label %80, label %85

80:                                               ; preds = %66
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.text_list_t, ptr %81, i32 0, i32 1
  %83 = getelementptr inbounds %struct.anon.28, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.anon.29, ptr %83, i32 0, i32 0
  store ptr @__text_list_init.c_chDefaultFormatString, ptr %84, align 8, !tbaa !19
  br label %85

85:                                               ; preds = %80, %66
  %86 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %86, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %87

87:                                               ; preds = %85, %65, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %88 = load i32, ptr %4, align 4
  ret i32 %88
}

; 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_text_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, !6, i64 104}
!10 = !{!"text_list_cfg_t", !7, i64 0, !6, i64 96, !6, i64 104}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 584}
!15 = !{!"text_list_t", !7, i64 0, !16, i64 576}
!16 = !{!"", !17, i64 0}
!17 = !{!"", !6, i64 0, !6, i64 8}
!18 = !{!10, !6, i64 96}
!19 = !{!15, !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"

@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__.__text_list_init = external hidden unnamed_addr constant [101 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@__text_list_init.c_chDefaultFormatString = external hidden constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @__text_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 104
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 129, ptr noundef nonnull @__PRETTY_FUNCTION__.__text_list_init) #3
  unreachable

7:                                                ; preds = %3
  %8 = tail call i32 @__simple_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #4
  %.not20 = icmp eq i32 %8, 0
  br i1 %.not20, label %9, label %23

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = load ptr, ptr %10, align 8, !tbaa !10
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %9
  tail call void @__simple_list_set_draw_list_item_handler(ptr noundef nonnull %0, ptr noundef nonnull @__arm_2d_text_list_draw_list_core_item) #4
  br label %14

14:                                               ; preds = %13, %9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 584
  store ptr %15, ptr %16, align 8, !tbaa !11
  %17 = icmp eq ptr %15, null
  br i1 %17, label %23, label %18

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %0, i64 576
  %20 = getelementptr inbounds i8, ptr %1, i64 96
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = icmp eq ptr %21, null
  %spec.select = select i1 %22, ptr @__text_list_init.c_chDefaultFormatString, ptr %21
  store ptr %spec.select, ptr %19, align 8, !tbaa !16
  br label %23

23:                                               ; preds = %14, %7, %18
  %.0 = phi i32 [ 0, %18 ], [ %8, %7 ], [ -2, %14 ]
  ret i32 %.0
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_text_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 = { 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 = { "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 = { noreturn nounwind }
attributes #4 = { 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, !9, i64 104}
!6 = !{!"text_list_cfg_t", !7, i64 0, !9, i64 96, !9, i64 104}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !9, i64 584}
!12 = !{!"text_list_t", !7, i64 0, !13, i64 576}
!13 = !{!"", !14, i64 0}
!14 = !{!"", !9, i64 0, !9, i64 8}
!15 = !{!6, !9, i64 96}
!16 = !{!12, !9, i64 576}


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