; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/tests/gamma.ll_nk (draw_list_begin)

; 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.nk_buffer = type { [2 x %struct.nk_buffer_marker], %struct.nk_allocator, i32, %struct.nk_memory, float, i64, i64, i64, i64 }
%struct.nk_buffer_marker = type { i32, i64 }
%struct.nk_allocator = type { %union.nk_handle, ptr, ptr }
%union.nk_handle = type { ptr }
%struct.nk_memory = type { ptr, i64 }
%struct.nk_draw_list = type { %struct.nk_rect, [12 x %struct.nk_vec2], %struct.nk_convert_config, ptr, ptr, ptr, i32, i32, i32, i64, i32, i32, i32, i32 }
%struct.nk_rect = type { float, float, float, float }
%struct.nk_vec2 = type { float, float }
%struct.nk_convert_config = type { float, i32, i32, i32, i32, i32, %struct.nk_draw_null_texture, ptr, i64, i64 }
%struct.nk_draw_null_texture = type { %union.nk_handle, %struct.nk_vec2 }

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.nk__draw_list_begin = external hidden unnamed_addr constant [105 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 ptr @nk__draw_list_begin(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %14

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 9268, ptr noundef @__PRETTY_FUNCTION__.nk__draw_list_begin) #4
  unreachable

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

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.nk_buffer, ptr %18, i32 0, i32 8
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %27

22:                                               ; preds = %17
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.nk_draw_list, ptr %23, i32 0, i32 8
  %25 = load i32, ptr %24, align 8, !tbaa !16
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %22, %17, %14
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %45

28:                                               ; preds = %22
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.nk_buffer, ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds %struct.nk_memory, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !22
  store ptr %32, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.nk_buffer, ptr %33, i32 0, i32 3
  %35 = getelementptr inbounds %struct.nk_memory, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !23
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.nk_draw_list, ptr %37, i32 0, i32 9
  %39 = load i64, ptr %38, align 8, !tbaa !24
  %40 = sub i64 %36, %39
  store i64 %40, ptr %7, align 8, !tbaa !25
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i64, ptr %7, align 8, !tbaa !25
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  store ptr %43, ptr %8, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %44, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %45

45:                                               ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %46 = load ptr, ptr %3, align 8
  ret ptr %46
}

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 = { nounwind }
attributes #4 = { noreturn 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, !14, i64 112}
!10 = !{!"nk_buffer", !7, i64 0, !11, i64 32, !12, i64 56, !13, i64 64, !15, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112}
!11 = !{!"nk_allocator", !7, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"nk_memory", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!17, !12, i64 208}
!17 = !{!"nk_draw_list", !18, i64 0, !7, i64 16, !19, i64 112, !6, i64 176, !6, i64 184, !6, i64 192, !12, i64 200, !12, i64 204, !12, i64 208, !14, i64 216, !12, i64 224, !12, i64 228, !12, i64 232, !12, i64 236}
!18 = !{!"nk_rect", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!19 = !{!"nk_convert_config", !15, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !20, i64 24, !6, i64 40, !14, i64 48, !14, i64 56}
!20 = !{!"nk_draw_null_texture", !7, i64 0, !21, i64 8}
!21 = !{!"nk_vec2", !15, i64 0, !15, i64 4}
!22 = !{!10, !6, i64 64}
!23 = !{!10, !14, i64 72}
!24 = !{!17, !14, i64 216}
!25 = !{!14, !14, 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"

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.nk__draw_list_begin = external hidden unnamed_addr constant [105 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @nk__draw_list_begin(ptr nocapture noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 9268, ptr noundef nonnull @__PRETTY_FUNCTION__.nk__draw_list_begin) #2
  unreachable

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 112
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not11 = icmp eq i64 %6, 0
  br i1 %.not11, label %19, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 208
  %9 = load i32, ptr %8, align 8, !tbaa !15
  %.not12 = icmp eq i32 %9, 0
  br i1 %.not12, label %19, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 64
  %12 = load ptr, ptr %11, align 8, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %1, i64 72
  %14 = load i64, ptr %13, align 8, !tbaa !22
  %15 = getelementptr inbounds i8, ptr %0, i64 216
  %16 = load i64, ptr %15, align 8, !tbaa !23
  %17 = sub i64 %14, %16
  %18 = getelementptr inbounds i8, ptr %12, i64 %17
  br label %19

19:                                               ; preds = %4, %7, %10
  %.0 = phi ptr [ %18, %10 ], [ null, %7 ], [ null, %4 ]
  ret ptr %.0
}

attributes #0 = { 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 #1 = { 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 #2 = { noreturn 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, !13, i64 112}
!6 = !{!"nk_buffer", !7, i64 0, !9, i64 32, !11, i64 56, !12, i64 64, !14, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"nk_allocator", !7, i64 0, !10, i64 8, !10, i64 16}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!"nk_memory", !10, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !11, i64 208}
!16 = !{!"nk_draw_list", !17, i64 0, !7, i64 16, !18, i64 112, !10, i64 176, !10, i64 184, !10, i64 192, !11, i64 200, !11, i64 204, !11, i64 208, !13, i64 216, !11, i64 224, !11, i64 228, !11, i64 232, !11, i64 236}
!17 = !{!"nk_rect", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!18 = !{!"nk_convert_config", !14, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !19, i64 24, !10, i64 40, !13, i64 48, !13, i64 56}
!19 = !{!"nk_draw_null_texture", !7, i64 0, !20, i64 8}
!20 = !{!"nk_vec2", !14, i64 0, !14, i64 4}
!21 = !{!6, !10, i64 64}
!22 = !{!6, !13, i64 72}
!23 = !{!16, !13, i64 216}


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