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

; 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 }
%struct.nk_draw_command = type { i32, %struct.nk_rect, %union.nk_handle }

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

13:                                               ; preds = %2
  br label %15

14:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 9285, ptr noundef @__PRETTY_FUNCTION__.nk__draw_list_end) #4
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.2, i32 noundef 9286, ptr noundef @__PRETTY_FUNCTION__.nk__draw_list_end) #4
  unreachable

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

23:                                               ; preds = %20
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %23, %20
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %53

27:                                               ; preds = %23
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.nk_buffer, ptr %28, i32 0, i32 3
  %30 = getelementptr inbounds %struct.nk_memory, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  store ptr %31, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.nk_buffer, ptr %32, i32 0, i32 3
  %34 = getelementptr inbounds %struct.nk_memory, ptr %33, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !16
  store i64 %35, ptr %6, align 8, !tbaa !17
  %36 = load i64, ptr %6, align 8, !tbaa !17
  %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 !18
  %40 = sub i64 %36, %39
  store i64 %40, ptr %7, align 8, !tbaa !17
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i64, ptr %7, align 8, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  store ptr %43, ptr %9, align 8, !tbaa !5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.nk_draw_list, ptr %44, i32 0, i32 8
  %46 = load i32, ptr %45, align 8, !tbaa !24
  %47 = sub i32 %46, 1
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = zext i32 %47 to i64
  %50 = sub i64 0, %49
  %51 = getelementptr inbounds %struct.nk_draw_command, ptr %48, i64 %50
  store ptr %51, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %52, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %53

53:                                               ; preds = %27, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  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
  %54 = load ptr, ptr %3, align 8
  ret ptr %54
}

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, !6, i64 64}
!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 = !{!10, !14, i64 72}
!17 = !{!14, !14, i64 0}
!18 = !{!19, !14, i64 216}
!19 = !{!"nk_draw_list", !20, i64 0, !7, i64 16, !21, 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}
!20 = !{!"nk_rect", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!21 = !{!"nk_convert_config", !15, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !22, i64 24, !6, i64 40, !14, i64 48, !14, i64 56}
!22 = !{!"nk_draw_null_texture", !7, i64 0, !23, i64 8}
!23 = !{!"nk_vec2", !15, i64 0, !15, i64 4}
!24 = !{!19, !12, i64 208}


; 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"

%struct.nk_draw_command = type { i32, %struct.nk_rect, %union.nk_handle }
%struct.nk_rect = type { float, float, float, float }
%union.nk_handle = type { ptr }

@.str.2 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.nk__draw_list_end = external hidden unnamed_addr constant [103 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_end(ptr 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 9285, ptr noundef nonnull @__PRETTY_FUNCTION__.nk__draw_list_end) #2
  unreachable

4:                                                ; preds = %2
  %.not16 = icmp eq ptr %0, null
  br i1 %.not16, label %5, label %6

5:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.2, i32 noundef 9286, ptr noundef nonnull @__PRETTY_FUNCTION__.nk__draw_list_end) #2
  unreachable

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %1, i64 64
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 72
  %10 = load i64, ptr %9, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 216
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = sub i64 %10, %12
  %14 = getelementptr inbounds i8, ptr %8, i64 %13
  %15 = getelementptr inbounds i8, ptr %0, i64 208
  %16 = load i32, ptr %15, align 8, !tbaa !22
  %17 = add i32 %16, -1
  %18 = zext i32 %17 to i64
  %19 = sub nsw i64 0, %18
  %20 = getelementptr inbounds %struct.nk_draw_command, ptr %14, i64 %19
  ret ptr %20
}

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, !10, i64 64}
!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 = !{!6, !13, i64 72}
!16 = !{!17, !13, i64 216}
!17 = !{!"nk_draw_list", !18, i64 0, !7, i64 16, !19, 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}
!18 = !{!"nk_rect", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!19 = !{!"nk_convert_config", !14, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !20, i64 24, !10, i64 40, !13, i64 48, !13, i64 56}
!20 = !{!"nk_draw_null_texture", !7, i64 0, !21, i64 8}
!21 = !{!"nk_vec2", !14, i64 0, !14, i64 4}
!22 = !{!17, !11, i64 208}


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