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

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

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

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

; Function Attrs: nounwind uwtable
define hidden i32 @luaK_exp2RK(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  call void @luaK_exp2val(ptr noundef %6, ptr noundef %7)
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.expdesc, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 8, !tbaa !9
  switch i32 %10, label %71 [
    i32 5, label %11
    i32 2, label %11
    i32 3, label %11
    i32 1, label %11
    i32 4, label %58
  ]

11:                                               ; preds = %2, %2, %2, %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.FuncState, ptr %12, i32 0, i32 10
  %14 = load i32, ptr %13, align 8, !tbaa !12
  %15 = icmp sle i32 %14, 255
  br i1 %15, label %16, label %57

16:                                               ; preds = %11
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.expdesc, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %24

21:                                               ; preds = %16
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call i32 @nilK(ptr noundef %22)
  br label %45

24:                                               ; preds = %16
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.expdesc, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = icmp eq i32 %27, 5
  br i1 %28, label %29, label %35

29:                                               ; preds = %24
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.expdesc, ptr %31, i32 0, i32 1
  %33 = load double, ptr %32, align 8, !tbaa !15
  %34 = call i32 @luaK_numberK(ptr noundef %30, double noundef %33)
  br label %43

35:                                               ; preds = %24
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.expdesc, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = icmp eq i32 %39, 2
  %41 = zext i1 %40 to i32
  %42 = call i32 @boolK(ptr noundef %36, i32 noundef %41)
  br label %43

43:                                               ; preds = %35, %29
  %44 = phi i32 [ %34, %29 ], [ %42, %35 ]
  br label %45

45:                                               ; preds = %43, %21
  %46 = phi i32 [ %23, %21 ], [ %44, %43 ]
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.expdesc, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds %struct.anon, ptr %48, i32 0, i32 0
  store i32 %46, ptr %49, align 8, !tbaa !15
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.expdesc, ptr %50, i32 0, i32 0
  store i32 4, ptr %51, align 8, !tbaa !9
  %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 !15
  %56 = or i32 %55, 256
  store i32 %56, ptr %3, align 4
  br label %76

57:                                               ; preds = %11
  br label %72

58:                                               ; preds = %2
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.expdesc, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.anon, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !15
  %63 = icmp sle i32 %62, 255
  br i1 %63, label %64, label %70

64:                                               ; preds = %58
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.expdesc, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.anon, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !15
  %69 = or i32 %68, 256
  store i32 %69, ptr %3, align 4
  br label %76

70:                                               ; preds = %58
  br label %72

71:                                               ; preds = %2
  br label %72

72:                                               ; preds = %71, %70, %57
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = call i32 @luaK_exp2anyreg(ptr noundef %73, ptr noundef %74)
  store i32 %75, ptr %3, align 4
  br label %76

76:                                               ; preds = %72, %64, %45
  %77 = load i32, ptr %3, align 4
  ret i32 %77
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @boolK(ptr noundef, i32 noundef) #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" }

!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, !11, i64 0}
!10 = !{!"expdesc", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 64}
!13 = !{!"FuncState", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !14, i64 72, !7, i64 74, !7, i64 75, !7, i64 196}
!14 = !{!"short", !7, i64 0}
!15 = !{!7, !7, 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"

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

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

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

; Function Attrs: nounwind uwtable
define hidden i32 @luaK_exp2RK(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @luaK_exp2val(ptr noundef %0, ptr noundef %1)
  %3 = load i32, ptr %1, align 8, !tbaa !5
  switch i32 %3, label %29 [
    i32 5, label %4
    i32 2, label %4
    i32 3, label %4
    i32 1, label %4
    i32 4, label %23
  ]

4:                                                ; preds = %2, %2, %2, %2
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = load i32, ptr %5, align 8, !tbaa !10
  %7 = icmp slt i32 %6, 256
  br i1 %7, label %8, label %29

8:                                                ; preds = %4
  switch i32 %3, label %15 [
    i32 1, label %9
    i32 5, label %11
  ]

9:                                                ; preds = %8
  %10 = tail call i32 @nilK(ptr noundef nonnull %0)
  br label %19

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = tail call i32 @luaK_numberK(ptr noundef nonnull %0, double noundef %13)
  br label %19

15:                                               ; preds = %8
  %16 = icmp eq i32 %3, 2
  %17 = zext i1 %16 to i32
  %18 = tail call i32 @boolK(ptr noundef nonnull %0, i32 noundef %17)
  br label %19

19:                                               ; preds = %11, %15, %9
  %20 = phi i32 [ %10, %9 ], [ %14, %11 ], [ %18, %15 ]
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %20, ptr %21, align 8, !tbaa !14
  store i32 4, ptr %1, align 8, !tbaa !5
  %22 = or i32 %20, 256
  br label %31

23:                                               ; preds = %2
  %24 = getelementptr inbounds i8, ptr %1, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp slt i32 %25, 256
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = or i32 %25, 256
  br label %31

29:                                               ; preds = %2, %23, %4
  %30 = tail call i32 @luaK_exp2anyreg(ptr noundef %0, ptr noundef nonnull %1)
  br label %31

31:                                               ; preds = %29, %27, %19
  %.0 = phi i32 [ %30, %29 ], [ %28, %27 ], [ %22, %19 ]
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @boolK(ptr noundef, i32 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" }

!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, !7, i64 64}
!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 = !{!8, !8, i64 0}


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