; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_compiled_1)

; 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.w2c_hermes = type { ptr, ptr, ptr, i32, i32, i32, %struct.wasm_rt_memory_t, %struct.wasm_rt_funcref_table_t }
%struct.wasm_rt_memory_t = type { ptr, i64, i64, i64, i8 }
%struct.wasm_rt_funcref_table_t = type { 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: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store(ptr noundef, i64 noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @i64_load(ptr noundef, i64 noundef) #1

; 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 @w2c_hermes_hermes0x3A0x3Abigint0x3A0x3AasUintNResultSize0x28unsigned0x20long0x20long0x2C0x20hermes0x3A0x3Abigint0x3A0x3AImmutableBigIntRef0x2C0x20unsigned0x20int0x260x29(ptr noundef %0, i64 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %18 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %18, ptr %11, align 4, !tbaa !11
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.w2c_hermes, ptr %19, i32 0, i32 6
  %21 = load i32, ptr %11, align 4, !tbaa !11
  %22 = zext i32 %21 to i64
  %23 = add i64 %22, 4
  %24 = call i32 @i32_load(ptr noundef %20, i64 noundef %23)
  store i32 %24, ptr %11, align 4, !tbaa !11
  %25 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %25, ptr %9, align 4, !tbaa !11
  %26 = load i32, ptr %11, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %61

28:                                               ; preds = %4
  %29 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %29, ptr %11, align 4, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.w2c_hermes, ptr %30, i32 0, i32 6
  %32 = load i32, ptr %11, align 4, !tbaa !11
  %33 = zext i32 %32 to i64
  %34 = call i32 @i32_load(ptr noundef %31, i64 noundef %33)
  store i32 %34, ptr %11, align 4, !tbaa !11
  %35 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %35, ptr %12, align 4, !tbaa !11
  store i32 3, ptr %13, align 4, !tbaa !11
  %36 = load i32, ptr %13, align 4, !tbaa !11
  %37 = and i32 %36, 31
  %38 = load i32, ptr %12, align 4, !tbaa !11
  %39 = shl i32 %38, %37
  store i32 %39, ptr %12, align 4, !tbaa !11
  %40 = load i32, ptr %12, align 4, !tbaa !11
  %41 = load i32, ptr %11, align 4, !tbaa !11
  %42 = add i32 %41, %40
  store i32 %42, ptr %11, align 4, !tbaa !11
  store i32 8, ptr %12, align 4, !tbaa !11
  %43 = load i32, ptr %12, align 4, !tbaa !11
  %44 = load i32, ptr %11, align 4, !tbaa !11
  %45 = sub i32 %44, %43
  store i32 %45, ptr %11, align 4, !tbaa !11
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.w2c_hermes, ptr %46, i32 0, i32 6
  %48 = load i32, ptr %11, align 4, !tbaa !11
  %49 = zext i32 %48 to i64
  %50 = call i64 @i64_load(ptr noundef %47, i64 noundef %49)
  store i64 %50, ptr %14, align 8, !tbaa !9
  store i64 0, ptr %15, align 8, !tbaa !9
  %51 = load i64, ptr %14, align 8, !tbaa !9
  %52 = load i64, ptr %15, align 8, !tbaa !9
  %53 = icmp slt i64 %51, %52
  %54 = zext i1 %53 to i32
  %55 = sext i32 %54 to i64
  %56 = trunc i64 %55 to i32
  store i32 %56, ptr %11, align 4, !tbaa !11
  %57 = load i32, ptr %11, align 4, !tbaa !11
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %28
  br label %86

60:                                               ; preds = %28
  br label %61

61:                                               ; preds = %60, %4
  %62 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %62, ptr %11, align 4, !tbaa !11
  store i32 6, ptr %12, align 4, !tbaa !11
  %63 = load i32, ptr %12, align 4, !tbaa !11
  %64 = and i32 %63, 31
  %65 = load i32, ptr %11, align 4, !tbaa !11
  %66 = shl i32 %65, %64
  store i32 %66, ptr %11, align 4, !tbaa !11
  %67 = load i32, ptr %11, align 4, !tbaa !11
  %68 = zext i32 %67 to i64
  store i64 %68, ptr %14, align 8, !tbaa !9
  %69 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %69, ptr %10, align 8, !tbaa !9
  %70 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %70, ptr %15, align 8, !tbaa !9
  %71 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %71, ptr %16, align 8, !tbaa !9
  %72 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %72, ptr %17, align 8, !tbaa !9
  %73 = load i64, ptr %16, align 8, !tbaa !9
  %74 = load i64, ptr %17, align 8, !tbaa !9
  %75 = icmp ugt i64 %73, %74
  %76 = zext i1 %75 to i32
  store i32 %76, ptr %13, align 4, !tbaa !11
  %77 = load i32, ptr %13, align 4, !tbaa !11
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %61
  %80 = load i64, ptr %14, align 8, !tbaa !9
  br label %83

81:                                               ; preds = %61
  %82 = load i64, ptr %15, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %81, %79
  %84 = phi i64 [ %80, %79 ], [ %82, %81 ]
  store i64 %84, ptr %14, align 8, !tbaa !9
  %85 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %85, ptr %6, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %83, %59
  store i32 2, ptr %11, align 4, !tbaa !11
  %87 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %87, ptr %7, align 4, !tbaa !11
  %88 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %88, ptr %14, align 8, !tbaa !9
  store i64 1, ptr %15, align 8, !tbaa !9
  %89 = load i64, ptr %15, align 8, !tbaa !9
  %90 = load i64, ptr %14, align 8, !tbaa !9
  %91 = add i64 %90, %89
  store i64 %91, ptr %14, align 8, !tbaa !9
  %92 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %92, ptr %6, align 8, !tbaa !9
  store i64 65536, ptr %15, align 8, !tbaa !9
  %93 = load i64, ptr %14, align 8, !tbaa !9
  %94 = load i64, ptr %15, align 8, !tbaa !9
  %95 = icmp ule i64 %93, %94
  %96 = zext i1 %95 to i32
  store i32 %96, ptr %11, align 4, !tbaa !11
  %97 = load i32, ptr %11, align 4, !tbaa !11
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %117

99:                                               ; preds = %86
  %100 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %100, ptr %11, align 4, !tbaa !11
  %101 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %101, ptr %15, align 8, !tbaa !9
  %102 = load i64, ptr %15, align 8, !tbaa !9
  %103 = trunc i64 %102 to i32
  store i32 %103, ptr %12, align 4, !tbaa !11
  store i32 63, ptr %13, align 4, !tbaa !11
  %104 = load i32, ptr %13, align 4, !tbaa !11
  %105 = load i32, ptr %12, align 4, !tbaa !11
  %106 = add i32 %105, %104
  store i32 %106, ptr %12, align 4, !tbaa !11
  store i32 6, ptr %13, align 4, !tbaa !11
  %107 = load i32, ptr %13, align 4, !tbaa !11
  %108 = and i32 %107, 31
  %109 = load i32, ptr %12, align 4, !tbaa !11
  %110 = lshr i32 %109, %108
  store i32 %110, ptr %12, align 4, !tbaa !11
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.w2c_hermes, ptr %111, i32 0, i32 6
  %113 = load i32, ptr %11, align 4, !tbaa !11
  %114 = zext i32 %113 to i64
  %115 = load i32, ptr %12, align 4, !tbaa !11
  call void @i32_store(ptr noundef %112, i64 noundef %114, i32 noundef %115)
  store i32 0, ptr %11, align 4, !tbaa !11
  %116 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %116, ptr %7, align 4, !tbaa !11
  br label %117

117:                                              ; preds = %99, %86
  %118 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %118, ptr %11, align 4, !tbaa !11
  %119 = load i32, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %119
}

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @i64_load(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @w2c_hermes_hermes0x3A0x3Abigint0x3A0x3AasUintNResultSize0x28unsigned0x20long0x20long0x2C0x20hermes0x3A0x3Abigint0x3A0x3AImmutableBigIntRef0x2C0x20unsigned0x20int0x260x29(ptr noundef %0, i64 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = zext i32 %2 to i64
  %7 = add nuw nsw i64 %6, 4
  %8 = tail call i32 @i32_load(ptr noundef nonnull %5, i64 noundef %7)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %17, label %9

9:                                                ; preds = %4
  %10 = tail call i32 @i32_load(ptr noundef nonnull %5, i64 noundef %6)
  %11 = shl i32 %8, 3
  %12 = add i32 %11, -8
  %13 = add i32 %12, %10
  %14 = zext i32 %13 to i64
  %15 = tail call i64 @i64_load(ptr noundef nonnull %5, i64 noundef %14)
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %21, label %17

17:                                               ; preds = %9, %4
  %18 = shl i32 %8, 6
  %19 = zext i32 %18 to i64
  %20 = tail call i64 @llvm.umin.i64(i64 %19, i64 %1)
  br label %21

21:                                               ; preds = %9, %17
  %.0 = phi i64 [ %1, %9 ], [ %20, %17 ]
  %22 = add i64 %.0, 1
  %23 = icmp ult i64 %22, 65537
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  %25 = trunc nuw nsw i64 %22 to i32
  %26 = add nuw nsw i32 %25, 63
  %27 = lshr i32 %26, 6
  %28 = zext i32 %3 to i64
  tail call void @i32_store(ptr noundef nonnull %5, i64 noundef %28, i32 noundef %27)
  br label %29

29:                                               ; preds = %24, %21
  %.054 = phi i32 [ 0, %24 ], [ 2, %21 ]
  ret i32 %.054
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #2

attributes #0 = { inlinehint 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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