; LLVM IR from ARM-software/Arm-2D :: examples/common/controls//simple_list.ll_ (simple_list_request_redraw_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.__simple_list_t = type { %union.anon.13, %struct.anon.23, %struct.anon.26 }
%union.anon.13 = type { %struct.__arm_2d_list_core_t }
%struct.__arm_2d_list_core_t = type { %struct.anon.14, %struct.anon.16, %struct.anon.20 }
%struct.anon.14 = type { %struct.__arm_2d_list_core_cfg_t }
%struct.__arm_2d_list_core_cfg_t = type { %struct.arm_2d_size_t, ptr, %union.anon.15, ptr, ptr, ptr, i32, ptr, i16, i16, i16, i16, ptr }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.15 = type { ptr }
%struct.anon.16 = type { %struct.anon.17, [112 x i8] }
%struct.anon.17 = type { %struct.arm_2d_tile_t, %struct.arm_2d_tile_t, %struct.__arm_2d_list_work_area_t, i8, %union.anon.18 }
%struct.arm_2d_tile_t = type { %union.anon.1, %union.anon.11, %union.anon.12 }
%union.anon.1 = type { %struct.anon }
%struct.anon = type { i8, %union.arm_2d_color_info_t, %union.anon.4 }
%union.arm_2d_color_info_t = type { %struct.anon.2 }
%struct.anon.2 = type { i8 }
%union.anon.4 = type { i16 }
%union.anon.11 = type { %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 }
%union.anon.12 = 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.18 = type { %struct.anon.19 }
%struct.anon.19 = type { i16 }
%struct.anon.20 = type { i8, i8, i16, i32, %union.anon.21 }
%union.anon.21 = type { %struct.anon.22 }
%struct.anon.22 = type { i16, i16, i16, i16 }
%struct.anon.23 = type { %struct.__simple_list_cfg_t }
%struct.__simple_list_cfg_t = type { i16, i8, i8, i8, %union.anon.24, %union.anon.25, %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.24 = type { %union.COLOUR_TYPE_T }
%union.anon.25 = type { %union.COLOUR_TYPE_T }
%union.COLOUR_TYPE_T = type { i32 }
%struct.anon.26 = type { %struct.arm_2d_list_item_t, i16, i8, i8, %struct.arm_2d_region_t, i64, [2 x %struct.arm_2d_helper_dirty_region_item_t] }
%struct.arm_2d_list_item_t = type { %struct.anon.27, i16, %union.anon.28, ptr, ptr, %struct.anon.30, %struct.arm_2d_margin_t, %struct.arm_2d_size_t, i64 }
%struct.anon.27 = type { ptr }
%union.anon.28 = type { i16 }
%struct.anon.30 = type { i8, i8 }
%struct.arm_2d_margin_t = type { i8, i8, i8, i8 }
%struct.arm_2d_helper_dirty_region_item_t = type { [48 x i8], %struct.arm_2d_region_t }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__.__simple_list_request_redraw_list = external hidden unnamed_addr constant [58 x i8], align 1

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

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

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

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

7:                                                ; preds = %1
  br label %9

8:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 927, ptr noundef @__PRETTY_FUNCTION__.__simple_list_request_redraw_list) #3
  unreachable

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %15, %9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds i32, ptr %11, i32 1
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %11, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %22

15:                                               ; preds = %10
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.__simple_list_t, ptr %16, i32 0, i32 2
  %18 = getelementptr inbounds %struct.anon.26, ptr %17, i32 0, i32 2
  %19 = load i8, ptr %18, align 2
  %20 = and i8 %19, -3
  %21 = or i8 %20, 2
  store i8 %21, ptr %18, align 2
  br label %10, !llvm.loop !11

22:                                               ; preds = %14
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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: readwrite) uwtable
define dso_local void @__simple_list_request_redraw_list(ptr nocapture noundef nonnull %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 442
  %.promoted = load i8, ptr %2, align 2
  %3 = or i8 %.promoted, 2
  store i8 %3, ptr %2, align 2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass