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

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__.__text_tracking_list_init = external hidden unnamed_addr constant [128 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 @__text_tracking_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, 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 = %3
  br label %12

11:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 96, ptr noundef @__PRETTY_FUNCTION__.__text_tracking_list_init) #5
  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 97, ptr noundef @__PRETTY_FUNCTION__.__text_tracking_list_init) #5
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr null, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %22

21:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 98, ptr noundef @__PRETTY_FUNCTION__.__text_tracking_list_init) #5
  unreachable

22:                                               ; preds = %20
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.text_tracking_list_t, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds %struct.anon.28, ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.text_tracking_list_cfg_t, ptr %26, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %27, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.text_tracking_list_t, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.text_tracking_list_cfg_t, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call i32 @__text_list_init(ptr noundef %29, ptr noundef %31, ptr noundef %32)
  store i32 %33, ptr %7, align 4, !tbaa !11
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.text_tracking_list_cfg_t, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.text_list_cfg_t, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.__simple_list_cfg_t, ptr %36, i32 0, i32 14
  %38 = load ptr, ptr %37, align 8, !tbaa !10
  %39 = icmp eq ptr null, %38
  br i1 %39, label %40, label %44

40:                                               ; preds = %22
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.text_tracking_list_t, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.text_list_t, ptr %42, i32 0, i32 0
  call void @__simple_list_set_draw_list_background_handler(ptr noundef %43, ptr noundef @__arm_2d_text_tracking_list_draw_background)
  br label %44

44:                                               ; preds = %40, %22
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.text_tracking_list_cfg_t, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.text_list_cfg_t, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.__simple_list_cfg_t, ptr %47, i32 0, i32 17
  %49 = load i32, ptr %48, align 8, !tbaa !10
  %50 = and i32 1, %49
  %51 = icmp eq i32 0, %50
  br i1 %51, label %52, label %59

52:                                               ; preds = %44
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.text_tracking_list_t, ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds %struct.anon.28, ptr %54, i32 0, i32 3
  %56 = load i8, ptr %55, align 8
  %57 = and i8 %56, -2
  %58 = or i8 %57, 0
  store i8 %58, ptr %55, align 8
  br label %59

59:                                               ; preds = %52, %44
  %60 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret i32 %60
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

declare i32 @__text_list_init(ptr noundef, ptr noundef, ptr noundef) #4

declare void @__simple_list_set_draw_list_background_handler(ptr noundef, ptr noundef) #4

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

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

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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { noreturn nounwind }
attributes #6 = { 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 = !{i64 0, i64 1, !10, i64 4, i64 4, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; 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 @__text_tracking_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 608
  %5 = getelementptr inbounds i8, ptr %1, i64 112
  %6 = load i64, ptr %5, align 8
  store i64 %6, ptr %4, align 8
  %7 = tail call i32 @__text_list_init(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #2
  %8 = getelementptr inbounds i8, ptr %1, i64 48
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  tail call void @__simple_list_set_draw_list_background_handler(ptr noundef nonnull %0, ptr noundef nonnull @__arm_2d_text_tracking_list_draw_background) #2
  br label %12

12:                                               ; preds = %11, %3
  %13 = getelementptr inbounds i8, ptr %1, i64 72
  %14 = load i32, ptr %13, align 8, !tbaa !5
  %15 = and i32 %14, 1
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %12
  %18 = load i8, ptr %4, align 8
  %19 = and i8 %18, -2
  store i8 %19, ptr %4, align 8
  br label %20

20:                                               ; preds = %17, %12
  ret i32 %7
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_text_tracking_list_draw_background(ptr noundef, ptr noundef, i1 noundef zeroext) #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"}


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