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

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

23:                                               ; preds = %3
  %24 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %24, ptr %8, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.w2c_hermes, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = add i64 %28, 8
  %30 = call i64 @i64_load(ptr noundef %26, i64 noundef %29)
  store i64 %30, ptr %12, align 8, !tbaa !11
  %31 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %31, ptr %7, align 8, !tbaa !11
  store i64 -844424930131969, ptr %13, align 8, !tbaa !11
  %32 = load i64, ptr %12, align 8, !tbaa !11
  %33 = load i64, ptr %13, align 8, !tbaa !11
  %34 = icmp ule i64 %32, %33
  %35 = zext i1 %34 to i32
  store i32 %35, ptr %8, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %23
  br label %114

39:                                               ; preds = %23
  %40 = load i64, ptr %7, align 8, !tbaa !11
  store i64 %40, ptr %12, align 8, !tbaa !11
  %41 = load i64, ptr %12, align 8, !tbaa !11
  %42 = trunc i64 %41 to i32
  store i32 %42, ptr %8, align 4, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %43, ptr %6, align 4, !tbaa !9
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 0
  %46 = xor i1 %45, true
  %47 = zext i1 %46 to i32
  store i32 %47, ptr %8, align 4, !tbaa !9
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %39
  br label %120

51:                                               ; preds = %39
  %52 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %52, ptr %8, align 4, !tbaa !9
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.w2c_hermes, ptr %53, i32 0, i32 6
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = add i64 %56, 3
  %58 = call i32 @i32_load8_u(ptr noundef %54, i64 noundef %57)
  store i32 %58, ptr %8, align 4, !tbaa !9
  store i32 24, ptr %9, align 4, !tbaa !9
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = and i32 %59, 31
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = shl i32 %61, %60
  store i32 %62, ptr %8, align 4, !tbaa !9
  store i32 1291845632, ptr %9, align 4, !tbaa !9
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = icmp ne i32 %63, %64
  %66 = zext i1 %65 to i32
  store i32 %66, ptr %8, align 4, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %51
  br label %126

70:                                               ; preds = %51
  %71 = load i64, ptr %7, align 8, !tbaa !11
  store i64 %71, ptr %12, align 8, !tbaa !11
  store i64 48, ptr %13, align 8, !tbaa !11
  %72 = load i64, ptr %12, align 8, !tbaa !11
  %73 = load i64, ptr %13, align 8, !tbaa !11
  %74 = and i64 %73, 63
  %75 = ashr i64 %72, %74
  store i64 %75, ptr %12, align 8, !tbaa !11
  %76 = load i64, ptr %12, align 8, !tbaa !11
  %77 = trunc i64 %76 to i32
  store i32 %77, ptr %8, align 4, !tbaa !9
  store i32 -2, ptr %9, align 4, !tbaa !9
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = icmp ne i32 %78, %79
  %81 = zext i1 %80 to i32
  store i32 %81, ptr %8, align 4, !tbaa !9
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %70
  br label %132

85:                                               ; preds = %70
  %86 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %86, ptr %8, align 4, !tbaa !9
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.w2c_hermes, ptr %87, i32 0, i32 6
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = zext i32 %89 to i64
  %91 = add i64 %90, 12
  %92 = call i32 @i32_load(ptr noundef %88, i64 noundef %91)
  store i32 %92, ptr %8, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 0
  %95 = xor i1 %94, true
  %96 = zext i1 %95 to i32
  store i32 %96, ptr %8, align 4, !tbaa !9
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %85
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %138

100:                                              ; preds = %85
  %101 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %101, ptr %8, align 4, !tbaa !9
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.w2c_hermes, ptr %102, i32 0, i32 6
  %104 = load i32, ptr %8, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = add i64 %105, 16
  %107 = call i64 @i64_load(ptr noundef %103, i64 noundef %106)
  store i64 %107, ptr %12, align 8, !tbaa !11
  br label %138

108:                                              ; preds = %3
  store i32 131111, ptr %8, align 4, !tbaa !9
  store i32 61000, ptr %9, align 4, !tbaa !9
  store i32 95, ptr %10, align 4, !tbaa !9
  store i32 90287, ptr %11, align 4, !tbaa !9
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = load i32, ptr %8, align 4, !tbaa !9
  %111 = load i32, ptr %9, align 4, !tbaa !9
  %112 = load i32, ptr %10, align 4, !tbaa !9
  %113 = load i32, ptr %11, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %109, i32 noundef %110, i32 noundef %111, i32 noundef %112, i32 noundef %113)
  call void @wasm_rt_trap(i32 noundef 5) #5
  unreachable

114:                                              ; preds = %38
  store i32 146777, ptr %8, align 4, !tbaa !9
  store i32 82692, ptr %9, align 4, !tbaa !9
  store i32 43, ptr %10, align 4, !tbaa !9
  store i32 24718, ptr %11, align 4, !tbaa !9
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = load i32, ptr %8, align 4, !tbaa !9
  %117 = load i32, ptr %9, align 4, !tbaa !9
  %118 = load i32, ptr %10, align 4, !tbaa !9
  %119 = load i32, ptr %11, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %115, i32 noundef %116, i32 noundef %117, i32 noundef %118, i32 noundef %119)
  call void @wasm_rt_trap(i32 noundef 5) #5
  unreachable

120:                                              ; preds = %50
  store i32 147142, ptr %8, align 4, !tbaa !9
  store i32 82611, ptr %9, align 4, !tbaa !9
  store i32 106, ptr %10, align 4, !tbaa !9
  store i32 28119, ptr %11, align 4, !tbaa !9
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = load i32, ptr %8, align 4, !tbaa !9
  %123 = load i32, ptr %9, align 4, !tbaa !9
  %124 = load i32, ptr %10, align 4, !tbaa !9
  %125 = load i32, ptr %11, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %121, i32 noundef %122, i32 noundef %123, i32 noundef %124, i32 noundef %125)
  call void @wasm_rt_trap(i32 noundef 5) #5
  unreachable

126:                                              ; preds = %69
  store i32 205012, ptr %8, align 4, !tbaa !9
  store i32 82611, ptr %9, align 4, !tbaa !9
  store i32 255, ptr %10, align 4, !tbaa !9
  store i32 24720, ptr %11, align 4, !tbaa !9
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = load i32, ptr %8, align 4, !tbaa !9
  %129 = load i32, ptr %9, align 4, !tbaa !9
  %130 = load i32, ptr %10, align 4, !tbaa !9
  %131 = load i32, ptr %11, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %127, i32 noundef %128, i32 noundef %129, i32 noundef %130, i32 noundef %131)
  call void @wasm_rt_trap(i32 noundef 5) #5
  unreachable

132:                                              ; preds = %84
  store i32 117977, ptr %8, align 4, !tbaa !9
  store i32 83341, ptr %9, align 4, !tbaa !9
  store i32 475, ptr %10, align 4, !tbaa !9
  store i32 27558, ptr %11, align 4, !tbaa !9
  %133 = load ptr, ptr %4, align 8, !tbaa !5
  %134 = load i32, ptr %8, align 4, !tbaa !9
  %135 = load i32, ptr %9, align 4, !tbaa !9
  %136 = load i32, ptr %10, align 4, !tbaa !9
  %137 = load i32, ptr %11, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %133, i32 noundef %134, i32 noundef %135, i32 noundef %136, i32 noundef %137)
  call void @wasm_rt_trap(i32 noundef 5) #5
  unreachable

138:                                              ; preds = %100, %99
  %139 = load i64, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i64 %139
}

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

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

; Function Attrs: noreturn
declare void @wasm_rt_trap(i32 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @i32_load8_u(ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_0x5F_assert_fail(ptr noundef, i32 noundef, i32 noundef, i32 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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn "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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn }

!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, !12, i64 0}
!12 = !{!"long", !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
define dso_local i64 @w2c_hermes_0x28anonymous0x20namespace0x290x3A0x3Abigint_truncate_to_uint640x28HermesABIRuntime0x2A0x2C0x20HermesABIBigInt0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = zext i32 %2 to i64
  %6 = add nuw nsw i64 %5, 4
  %7 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %6)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %24, label %8

8:                                                ; preds = %3
  %9 = add nuw nsw i64 %5, 8
  %10 = tail call i64 @i64_load(ptr noundef nonnull %4, i64 noundef %9)
  %11 = icmp ult i64 %10, -844424930131968
  br i1 %11, label %25, label %12

12:                                               ; preds = %8
  %13 = and i64 %10, 4294967295
  %.not65 = icmp eq i64 %13, 0
  br i1 %.not65, label %26, label %14

14:                                               ; preds = %12
  %15 = add nuw nsw i64 %13, 3
  %16 = tail call i32 @i32_load8_u(ptr noundef nonnull %4, i64 noundef %15)
  %.mask = and i32 %16, 255
  %.not66 = icmp eq i32 %.mask, 77
  br i1 %.not66, label %17, label %27

17:                                               ; preds = %14
  %.mask68 = and i64 %10, -281474976710656
  %.not67 = icmp eq i64 %.mask68, -562949953421312
  br i1 %.not67, label %18, label %28

18:                                               ; preds = %17
  %19 = add nuw nsw i64 %13, 12
  %20 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %19)
  %.not69 = icmp eq i32 %20, 0
  br i1 %.not69, label %29, label %21

21:                                               ; preds = %18
  %22 = add nuw nsw i64 %13, 16
  %23 = tail call i64 @i64_load(ptr noundef nonnull %4, i64 noundef %22)
  br label %29

24:                                               ; preds = %3
  tail call void @w2c_hermes_0x5F_assert_fail(ptr noundef %0, i32 noundef 131111, i32 noundef 61000, i32 noundef 95, i32 noundef 90287)
  tail call void @wasm_rt_trap(i32 noundef 5) #3
  unreachable

25:                                               ; preds = %8
  tail call void @w2c_hermes_0x5F_assert_fail(ptr noundef %0, i32 noundef 146777, i32 noundef 82692, i32 noundef 43, i32 noundef 24718)
  tail call void @wasm_rt_trap(i32 noundef 5) #3
  unreachable

26:                                               ; preds = %12
  tail call void @w2c_hermes_0x5F_assert_fail(ptr noundef %0, i32 noundef 147142, i32 noundef 82611, i32 noundef 106, i32 noundef 28119)
  tail call void @wasm_rt_trap(i32 noundef 5) #3
  unreachable

27:                                               ; preds = %14
  tail call void @w2c_hermes_0x5F_assert_fail(ptr noundef %0, i32 noundef 205012, i32 noundef 82611, i32 noundef 255, i32 noundef 24720)
  tail call void @wasm_rt_trap(i32 noundef 5) #3
  unreachable

28:                                               ; preds = %17
  tail call void @w2c_hermes_0x5F_assert_fail(ptr noundef %0, i32 noundef 117977, i32 noundef 83341, i32 noundef 475, i32 noundef 27558)
  tail call void @wasm_rt_trap(i32 noundef 5) #3
  unreachable

29:                                               ; preds = %18, %21
  %.0 = phi i64 [ %23, %21 ], [ 0, %18 ]
  ret i64 %.0
}

; Function Attrs: noreturn
declare void @wasm_rt_trap(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @i32_load8_u(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_0x5F_assert_fail(ptr noundef, i32 noundef, i32 noundef, i32 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" }
attributes #1 = { noreturn "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 = { 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 #3 = { noreturn 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)"}


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