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

; 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.expdesc = type { i32, %union.anon, i32, i32 }
%union.anon = type { double }
%struct.FuncState = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i16, i8, [60 x %struct.upvaldesc], [200 x i16] }
%struct.upvaldesc = type { i8, i8 }
%struct.Proto = type { ptr, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i8, i8, i8, i8 }
%struct.anon = type { i32, i32 }

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

; Function Attrs: nounwind uwtable
define hidden void @luaK_setreturns(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.expdesc, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp eq i32 %9, 13
  br i1 %10, label %11, label %41

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.FuncState, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.Proto, ptr %14, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.expdesc, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !18
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %16, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = and i32 %23, -8372225
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = add nsw i32 %25, 1
  %27 = shl i32 %26, 14
  %28 = and i32 %27, 8372224
  %29 = or i32 %24, %28
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.FuncState, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = getelementptr inbounds %struct.Proto, ptr %32, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.expdesc, ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %34, i64 %39
  store i32 %29, ptr %40, align 4, !tbaa !9
  br label %108

41:                                               ; preds = %3
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.expdesc, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !11
  %45 = icmp eq i32 %44, 14
  br i1 %45, label %46, label %107

46:                                               ; preds = %41
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.FuncState, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.Proto, ptr %49, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.expdesc, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.anon, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !18
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %51, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = and i32 %58, 8388607
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  %62 = shl i32 %61, 23
  %63 = and i32 %62, -8388608
  %64 = or i32 %59, %63
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.FuncState, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = getelementptr inbounds %struct.Proto, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.expdesc, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds %struct.anon, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 8, !tbaa !18
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i32, ptr %69, i64 %74
  store i32 %64, ptr %75, align 4, !tbaa !9
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.FuncState, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !13
  %79 = getelementptr inbounds %struct.Proto, ptr %78, i32 0, i32 4
  %80 = load ptr, ptr %79, align 8, !tbaa !16
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.expdesc, ptr %81, i32 0, i32 1
  %83 = getelementptr inbounds %struct.anon, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !18
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %80, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !9
  %88 = and i32 %87, -16321
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.FuncState, ptr %89, i32 0, i32 9
  %91 = load i32, ptr %90, align 4, !tbaa !19
  %92 = shl i32 %91, 6
  %93 = and i32 %92, 16320
  %94 = or i32 %88, %93
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.FuncState, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !13
  %98 = getelementptr inbounds %struct.Proto, ptr %97, i32 0, i32 4
  %99 = load ptr, ptr %98, align 8, !tbaa !16
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.expdesc, ptr %100, i32 0, i32 1
  %102 = getelementptr inbounds %struct.anon, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 8, !tbaa !18
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i32, ptr %99, i64 %104
  store i32 %94, ptr %105, align 4, !tbaa !9
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  call void @luaK_reserveregs(ptr noundef %106, i32 noundef 1)
  br label %107

107:                                              ; preds = %46, %41
  br label %108

108:                                              ; preds = %107, %11
  ret void
}

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

!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 = !{!12, !10, i64 0}
!12 = !{!"expdesc", !10, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!13 = !{!14, !6, i64 0}
!14 = !{!"FuncState", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !15, i64 72, !7, i64 74, !7, i64 75, !7, i64 196}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !6, i64 24}
!17 = !{!"Proto", !6, i64 0, !7, i64 8, !7, i64 9, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !6, i64 104, !7, i64 112, !7, i64 113, !7, i64 114, !7, i64 115}
!18 = !{!7, !7, i64 0}
!19 = !{!14, !10, i64 60}


; 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: nounwind uwtable
declare hidden void @luaK_reserveregs(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define hidden void @luaK_setreturns(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %1, align 8, !tbaa !5
  switch i32 %4, label %42 [
    i32 13, label %5
    i32 14, label %19
  ]

5:                                                ; preds = %3
  %6 = load ptr, ptr %0, align 8, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !16
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i32, ptr %8, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !17
  %14 = and i32 %13, -8372225
  %15 = shl i32 %2, 14
  %16 = add i32 %15, 16384
  %17 = and i32 %16, 8372224
  %18 = or disjoint i32 %14, %17
  store i32 %18, ptr %12, align 4, !tbaa !17
  br label %42

19:                                               ; preds = %3
  %20 = load ptr, ptr %0, align 8, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %1, i64 8
  %24 = load i32, ptr %23, align 8, !tbaa !16
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr %22, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = and i32 %27, 8388607
  %29 = shl i32 %2, 23
  %30 = add i32 %29, 8388608
  %31 = or disjoint i32 %28, %30
  store i32 %31, ptr %26, align 4, !tbaa !17
  %32 = load i32, ptr %23, align 8, !tbaa !16
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %22, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = and i32 %35, -16321
  %37 = getelementptr inbounds i8, ptr %0, i64 60
  %38 = load i32, ptr %37, align 4, !tbaa !18
  %39 = shl i32 %38, 6
  %40 = and i32 %39, 16320
  %41 = or disjoint i32 %40, %36
  store i32 %41, ptr %34, align 4, !tbaa !17
  tail call void @luaK_reserveregs(ptr noundef nonnull %0, i32 noundef 1)
  br label %42

42:                                               ; preds = %3, %19, %5
  ret void
}

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

!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, !7, i64 0}
!6 = !{!"expdesc", !7, i64 0, !8, i64 8, !7, i64 16, !7, i64 20}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"FuncState", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !13, i64 72, !8, i64 74, !8, i64 75, !8, i64 196}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!15, !12, i64 24}
!15 = !{!"Proto", !12, i64 0, !8, i64 8, !8, i64 9, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !12, i64 104, !8, i64 112, !8, i64 113, !8, i64 114, !8, i64 115}
!16 = !{!8, !8, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!11, !7, i64 60}


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