; LLVM IR from ramsdell/lineqpp :: lua (ldebug)

; 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.lua_State = type { ptr, i8, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i16, i16, i8, i8, i32, i32, ptr, %struct.lua_TValue, %struct.lua_TValue, ptr, ptr, ptr, i64 }
%struct.lua_TValue = type { %union.Value, i32 }
%union.Value = type { ptr }
%struct.lua_Debug = type { i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, [60 x i8], i32 }
%struct.CallInfo = type { ptr, ptr, ptr, ptr, i32, i32 }

; 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: nounwind uwtable
define dso_local i32 @lua_getinfo(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = sext i8 %13 to i32
  %15 = icmp eq i32 %14, 62
  br i1 %15, label %16, label %31

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.lua_State, ptr %17, i32 0, i32 4
  %19 = load ptr, ptr %18, align 8, !tbaa !10
  %20 = getelementptr inbounds %struct.lua_TValue, ptr %19, i64 -1
  store ptr %20, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i32 1
  store ptr %23, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.lua_TValue, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.lua_State, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !10
  %30 = getelementptr inbounds %struct.lua_TValue, ptr %29, i32 -1
  store ptr %30, ptr %28, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %51

31:                                               ; preds = %3
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.lua_Debug, ptr %32, i32 0, i32 10
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %50

36:                                               ; preds = %31
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.lua_State, ptr %37, i32 0, i32 12
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.lua_Debug, ptr %40, i32 0, i32 10
  %42 = load i32, ptr %41, align 4, !tbaa !16
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %struct.CallInfo, ptr %39, i64 %43
  store ptr %44, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.CallInfo, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %48 = getelementptr inbounds %struct.lua_TValue, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  store ptr %49, ptr %8, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %36, %31
  br label %51

51:                                               ; preds = %50, %16
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = call i32 @auxgetinfo(ptr noundef %52, ptr noundef %53, ptr noundef %54, ptr noundef %55, ptr noundef %56)
  store i32 %57, ptr %7, align 4, !tbaa !21
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = call ptr @strchr(ptr noundef %58, i32 noundef 102) #5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %97

61:                                               ; preds = %51
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %69

64:                                               ; preds = %61
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.lua_State, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !10
  %68 = getelementptr inbounds %struct.lua_TValue, ptr %67, i32 0, i32 1
  store i32 0, ptr %68, align 8, !tbaa !22
  br label %78

69:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.lua_State, ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %71, align 8, !tbaa !10
  store ptr %72, ptr %11, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.lua_TValue, ptr %74, i32 0, i32 0
  store ptr %73, ptr %75, align 8, !tbaa !9
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.lua_TValue, ptr %76, i32 0, i32 1
  store i32 6, ptr %77, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %78

78:                                               ; preds = %69, %64
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.lua_State, ptr %79, i32 0, i32 9
  %81 = load ptr, ptr %80, align 8, !tbaa !23
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.lua_State, ptr %82, i32 0, i32 4
  %84 = load ptr, ptr %83, align 8, !tbaa !10
  %85 = ptrtoint ptr %81 to i64
  %86 = ptrtoint ptr %84 to i64
  %87 = sub i64 %85, %86
  %88 = icmp sle i64 %87, 16
  br i1 %88, label %89, label %91

89:                                               ; preds = %78
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  call void @luaD_growstack(ptr noundef %90, i32 noundef 1)
  br label %92

91:                                               ; preds = %78
  br label %92

92:                                               ; preds = %91, %89
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.lua_State, ptr %93, i32 0, i32 4
  %95 = load ptr, ptr %94, align 8, !tbaa !10
  %96 = getelementptr inbounds %struct.lua_TValue, ptr %95, i32 1
  store ptr %96, ptr %94, align 8, !tbaa !10
  br label %97

97:                                               ; preds = %92, %51
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = call ptr @strchr(ptr noundef %98, i32 noundef 76) #5
  %100 = icmp ne ptr %99, null
  br i1 %100, label %101, label %104

101:                                              ; preds = %97
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = load ptr, ptr %8, align 8, !tbaa !5
  call void @collectvalidlines(ptr noundef %102, ptr noundef %103)
  br label %104

104:                                              ; preds = %101, %97
  %105 = load i32, ptr %7, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %105
}

; Function Attrs: nounwind uwtable
declare hidden i32 @auxgetinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #2

declare hidden void @luaD_growstack(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @collectvalidlines(ptr noundef, ptr noundef) #1

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

!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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 16}
!11 = !{!"lua_State", !6, i64 0, !7, i64 8, !7, i64 9, !7, i64 10, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !13, i64 96, !13, i64 98, !7, i64 100, !7, i64 101, !12, i64 104, !12, i64 108, !6, i64 112, !14, i64 120, !14, i64 136, !6, i64 152, !6, i64 160, !6, i64 168, !15, i64 176}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"lua_TValue", !7, i64 0, !12, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !12, i64 116}
!17 = !{!"lua_Debug", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !7, i64 56, !12, i64 116}
!18 = !{!11, !6, i64 80}
!19 = !{!20, !6, i64 8}
!20 = !{!"CallInfo", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 36}
!21 = !{!12, !12, i64 0}
!22 = !{!14, !12, i64 8}
!23 = !{!11, !6, i64 56}


; 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.CallInfo = type { ptr, ptr, ptr, ptr, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @lua_getinfo(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %5 = icmp eq i8 %4, 62
  br i1 %5, label %6, label %12

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %8, i64 -16
  %10 = getelementptr inbounds i8, ptr %1, i64 1
  %11 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !8
  br label %23

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %2, i64 116
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %23, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 80
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = sext i32 %14 to i64
  %19 = getelementptr inbounds %struct.CallInfo, ptr %17, i64 %18
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %12, %15, %6
  %.030 = phi ptr [ null, %6 ], [ %19, %15 ], [ null, %12 ]
  %.029 = phi ptr [ %11, %6 ], [ %22, %15 ], [ null, %12 ]
  %.0 = phi ptr [ %10, %6 ], [ %1, %15 ], [ %1, %12 ]
  %24 = tail call i32 @auxgetinfo(ptr noundef %0, ptr noundef nonnull %.0, ptr noundef %2, ptr noundef %.029, ptr noundef %.030)
  %25 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.0, i32 noundef 102) #3
  %.not32 = icmp eq ptr %25, null
  br i1 %.not32, label %47, label %26

26:                                               ; preds = %23
  %27 = icmp eq ptr %.029, null
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !8
  br i1 %27, label %30, label %32

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %29, i64 8
  store i32 0, ptr %31, align 8, !tbaa !20
  br label %34

32:                                               ; preds = %26
  store ptr %.029, ptr %29, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %29, i64 8
  store i32 6, ptr %33, align 8, !tbaa !20
  %.pre = load ptr, ptr %28, align 8, !tbaa !8
  br label %34

34:                                               ; preds = %32, %30
  %35 = phi ptr [ %.pre, %32 ], [ %29, %30 ]
  %36 = getelementptr inbounds i8, ptr %0, i64 56
  %37 = load ptr, ptr %36, align 8, !tbaa !21
  %38 = getelementptr inbounds i8, ptr %0, i64 16
  %39 = ptrtoint ptr %37 to i64
  %40 = ptrtoint ptr %35 to i64
  %41 = sub i64 %39, %40
  %42 = icmp slt i64 %41, 17
  br i1 %42, label %43, label %44

43:                                               ; preds = %34
  tail call void @luaD_growstack(ptr noundef nonnull %0, i32 noundef 1) #4
  br label %44

44:                                               ; preds = %34, %43
  %45 = load ptr, ptr %38, align 8, !tbaa !8
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  store ptr %46, ptr %38, align 8, !tbaa !8
  br label %47

47:                                               ; preds = %44, %23
  %48 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.0, i32 noundef 76) #3
  %.not33 = icmp eq ptr %48, null
  br i1 %.not33, label %50, label %49

49:                                               ; preds = %47
  tail call void @collectvalidlines(ptr noundef %0, ptr noundef %.029)
  br label %50

50:                                               ; preds = %49, %47
  ret i32 %24
}

; Function Attrs: nounwind uwtable
declare hidden i32 @auxgetinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #1

declare hidden void @luaD_growstack(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @collectvalidlines(ptr noundef, ptr noundef) local_unnamed_addr #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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nounwind willreturn memory(read) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 16}
!9 = !{!"lua_State", !10, i64 0, !6, i64 8, !6, i64 9, !6, i64 10, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !11, i64 88, !11, i64 92, !12, i64 96, !12, i64 98, !6, i64 100, !6, i64 101, !11, i64 104, !11, i64 108, !10, i64 112, !13, i64 120, !13, i64 136, !10, i64 152, !10, i64 160, !10, i64 168, !14, i64 176}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"short", !6, i64 0}
!13 = !{!"lua_TValue", !6, i64 0, !11, i64 8}
!14 = !{!"long", !6, i64 0}
!15 = !{!16, !11, i64 116}
!16 = !{!"lua_Debug", !11, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !6, i64 56, !11, i64 116}
!17 = !{!9, !10, i64 80}
!18 = !{!19, !10, i64 8}
!19 = !{!"CallInfo", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !11, i64 36}
!20 = !{!13, !11, i64 8}
!21 = !{!9, !10, i64 56}


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