; LLVM IR from paintdream/DontStarveLuaJIT :: src/luajit/src (lj_debug)

; 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.anon.2 = type { %struct.GCRef, %union.FrameLink }
%struct.GCRef = type { i32 }
%union.FrameLink = type { i32 }
%struct.GCfuncC = type { %struct.GCRef, i8, i8, i8, i8, %struct.GCRef, %struct.GCRef, %struct.MRef, ptr, [1 x %union.TValue] }
%struct.MRef = type { i32 }
%union.TValue = type { i64 }
%struct.GCfuncL = type { %struct.GCRef, i8, i8, i8, i8, %struct.GCRef, %struct.GCRef, %struct.MRef, [1 x %struct.GCRef] }
%struct.GCproto = type { %struct.GCRef, i8, i8, i8, i8, i32, %struct.GCRef, %struct.MRef, %struct.MRef, i32, i32, i32, i8, i8, i16, %struct.GCRef, i32, i32, %struct.MRef, %struct.MRef, %struct.MRef }

@.str.12 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 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: nounwind uwtable
declare hidden void @lj_debug_shortname(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define hidden void @lj_debug_addloc(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca [60 x i8], align 16
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %66

16:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.anon.2, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.GCRef, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = inttoptr i64 %21 to ptr
  store ptr %22, ptr %9, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.GCfuncC, ptr %23, i32 0, i32 3
  %25 = load i8, ptr %24, align 2, !tbaa !9
  %26 = zext i8 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %62

28:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = call i32 @debug_frameline(ptr noundef %29, ptr noundef %30, ptr noundef %31)
  store i32 %32, ptr %10, align 4, !tbaa !10
  %33 = load i32, ptr %10, align 4, !tbaa !10
  %34 = icmp sge i32 %33, 0
  br i1 %34, label %35, label %58

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.GCfuncL, ptr %36, i32 0, i32 7
  %38 = getelementptr inbounds %struct.MRef, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = inttoptr i64 %40 to ptr
  %42 = getelementptr inbounds i8, ptr %41, i64 -64
  store ptr %42, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 60, ptr %12) #3
  %43 = getelementptr inbounds [60 x i8], ptr %12, i64 0, i64 0
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.GCproto, ptr %44, i32 0, i32 15
  %46 = getelementptr inbounds %struct.GCRef, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 4, !tbaa !12
  %48 = zext i32 %47 to i64
  %49 = inttoptr i64 %48 to ptr
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.GCproto, ptr %50, i32 0, i32 16
  %52 = load i32, ptr %51, align 4, !tbaa !17
  call void @lj_debug_shortname(ptr noundef %43, ptr noundef %49, i32 noundef %52)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds [60 x i8], ptr %12, i64 0, i64 0
  %55 = load i32, ptr %10, align 4, !tbaa !10
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = call ptr (ptr, ptr, ...) @lj_strfmt_pushf(ptr noundef %53, ptr noundef @.str.12, ptr noundef %54, i32 noundef %55, ptr noundef %56)
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 60, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %59

58:                                               ; preds = %28
  store i32 0, ptr %13, align 4
  br label %59

59:                                               ; preds = %58, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %60 = load i32, ptr %13, align 4
  switch i32 %60, label %63 [
    i32 0, label %61
  ]

61:                                               ; preds = %59
  br label %62

62:                                               ; preds = %61, %16
  store i32 0, ptr %13, align 4
  br label %63

63:                                               ; preds = %62, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %64 = load i32, ptr %13, align 4
  switch i32 %64, label %71 [
    i32 0, label %65
    i32 1, label %70
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65, %4
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call ptr (ptr, ptr, ...) @lj_strfmt_pushf(ptr noundef %67, ptr noundef @.str.13, ptr noundef %68)
  br label %70

70:                                               ; preds = %66, %63
  ret void

71:                                               ; preds = %63
  unreachable
}

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

declare hidden ptr @lj_strfmt_pushf(ptr noundef, ptr noundef, ...) #2

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 = { "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 }

!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, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 40}
!13 = !{!"GCproto", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !11, i64 8, !14, i64 12, !15, i64 16, !15, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !7, i64 36, !7, i64 37, !16, i64 38, !14, i64 40, !11, i64 44, !11, i64 48, !15, i64 52, !15, i64 56, !15, i64 60}
!14 = !{!"GCRef", !11, i64 0}
!15 = !{!"MRef", !11, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!13, !11, i64 44}


; 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.12 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define hidden void @lj_debug_addloc(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = alloca [60 x i8], align 16
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.critedge.thread, label %6

6:                                                ; preds = %4
  %7 = load i32, ptr %2, align 8, !tbaa !5
  %8 = zext i32 %7 to i64
  %9 = inttoptr i64 %8 to ptr
  %10 = getelementptr inbounds i8, ptr %9, i64 6
  %11 = load i8, ptr %10, align 2, !tbaa !5
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %13, label %.critedge.thread

13:                                               ; preds = %6
  %14 = tail call i32 @debug_frameline(ptr noundef %0, ptr noundef nonnull %9, ptr noundef %3)
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %.critedge.thread, label %.critedge

.critedge:                                        ; preds = %13
  %16 = getelementptr inbounds i8, ptr %9, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = inttoptr i64 %18 to ptr
  call void @llvm.lifetime.start.p0(i64 60, ptr nonnull %5) #3
  %20 = getelementptr inbounds i8, ptr %19, i64 -24
  %21 = load i32, ptr %20, align 4, !tbaa !8
  %22 = zext i32 %21 to i64
  %23 = inttoptr i64 %22 to ptr
  %24 = getelementptr inbounds i8, ptr %19, i64 -20
  %25 = load i32, ptr %24, align 4, !tbaa !14
  call void @lj_debug_shortname(ptr noundef nonnull %5, ptr noundef %23, i32 noundef %25)
  %26 = call ptr (ptr, ptr, ...) @lj_strfmt_pushf(ptr noundef %0, ptr noundef nonnull @.str.12, ptr noundef nonnull %5, i32 noundef %14, ptr noundef %1) #3
  call void @llvm.lifetime.end.p0(i64 60, ptr nonnull %5) #3
  br label %28

.critedge.thread:                                 ; preds = %6, %13, %4
  %27 = tail call ptr (ptr, ptr, ...) @lj_strfmt_pushf(ptr noundef %0, ptr noundef nonnull @.str.13, ptr noundef %1) #3
  br label %28

28:                                               ; preds = %.critedge, %.critedge.thread
  ret void
}

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

declare hidden ptr @lj_strfmt_pushf(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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 }

!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, !11, i64 40}
!9 = !{!"GCproto", !10, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !11, i64 8, !10, i64 12, !12, i64 16, !12, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 36, !6, i64 37, !13, i64 38, !10, i64 40, !11, i64 44, !11, i64 48, !12, i64 52, !12, i64 56, !12, i64 60}
!10 = !{!"GCRef", !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"MRef", !11, i64 0}
!13 = !{!"short", !6, i64 0}
!14 = !{!9, !11, i64 44}


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