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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

declare void @w2c_hermes_0x5F_assert_fail(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

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

21:                                               ; preds = %2
  br label %66

22:                                               ; preds = %2
  %23 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %23, ptr %12, align 8, !tbaa !9
  %24 = load i64, ptr %12, align 8, !tbaa !9
  %25 = trunc i64 %24 to i32
  store i32 %25, ptr %7, align 4, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %26, ptr %6, align 4, !tbaa !11
  %27 = load i32, ptr %7, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  %29 = xor i1 %28, true
  %30 = zext i1 %29 to i32
  store i32 %30, ptr %7, align 4, !tbaa !11
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %22
  br label %68

34:                                               ; preds = %22
  %35 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %35, ptr %7, align 4, !tbaa !11
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.w2c_hermes, ptr %36, i32 0, i32 6
  %38 = load i32, ptr %7, align 4, !tbaa !11
  %39 = zext i32 %38 to i64
  %40 = add i64 %39, 3
  %41 = call i32 @i32_load8_u(ptr noundef %37, i64 noundef %40)
  store i32 %41, ptr %7, align 4, !tbaa !11
  store i32 24, ptr %8, align 4, !tbaa !11
  %42 = load i32, ptr %8, align 4, !tbaa !11
  %43 = and i32 %42, 31
  %44 = load i32, ptr %7, align 4, !tbaa !11
  %45 = shl i32 %44, %43
  store i32 %45, ptr %7, align 4, !tbaa !11
  store i32 486539264, ptr %8, align 4, !tbaa !11
  %46 = load i32, ptr %7, align 4, !tbaa !11
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = icmp ne i32 %46, %47
  %49 = zext i1 %48 to i32
  store i32 %49, ptr %7, align 4, !tbaa !11
  %50 = load i32, ptr %7, align 4, !tbaa !11
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %34
  br label %66

53:                                               ; preds = %34
  %54 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %54, ptr %7, align 4, !tbaa !11
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.w2c_hermes, ptr %55, i32 0, i32 6
  %57 = load i32, ptr %7, align 4, !tbaa !11
  %58 = zext i32 %57 to i64
  %59 = add i64 %58, 44
  %60 = call i32 @i32_load8_u(ptr noundef %56, i64 noundef %59)
  store i32 %60, ptr %7, align 4, !tbaa !11
  %61 = load i32, ptr %7, align 4, !tbaa !11
  %62 = icmp ne i32 %61, 0
  %63 = xor i1 %62, true
  %64 = zext i1 %63 to i32
  store i32 %64, ptr %7, align 4, !tbaa !11
  %65 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %65, ptr %5, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %53, %52, %21
  %67 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %67, ptr %7, align 4, !tbaa !11
  br label %85

68:                                               ; preds = %33
  store i32 0, ptr %7, align 4, !tbaa !11
  store i32 147142, ptr %8, align 4, !tbaa !11
  %69 = load i32, ptr %8, align 4, !tbaa !11
  %70 = load i32, ptr %7, align 4, !tbaa !11
  %71 = add i32 %70, %69
  store i32 %71, ptr %7, align 4, !tbaa !11
  %72 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %72, ptr %8, align 4, !tbaa !11
  store i32 82611, ptr %9, align 4, !tbaa !11
  %73 = load i32, ptr %9, align 4, !tbaa !11
  %74 = load i32, ptr %8, align 4, !tbaa !11
  %75 = add i32 %74, %73
  store i32 %75, ptr %8, align 4, !tbaa !11
  store i32 106, ptr %9, align 4, !tbaa !11
  %76 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %76, ptr %10, align 4, !tbaa !11
  store i32 28119, ptr %11, align 4, !tbaa !11
  %77 = load i32, ptr %11, align 4, !tbaa !11
  %78 = load i32, ptr %10, align 4, !tbaa !11
  %79 = add i32 %78, %77
  store i32 %79, ptr %10, align 4, !tbaa !11
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = load i32, ptr %7, align 4, !tbaa !11
  %82 = load i32, ptr %8, align 4, !tbaa !11
  %83 = load i32, ptr %9, align 4, !tbaa !11
  %84 = load i32, ptr %10, align 4, !tbaa !11
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %80, i32 noundef %81, i32 noundef %82, i32 noundef %83, i32 noundef %84)
  call void @wasm_rt_trap(i32 noundef 5) #6
  unreachable

85:                                               ; preds = %66
  %86 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret i32 %86
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"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: noreturn
declare void @wasm_rt_trap(i32 noundef) local_unnamed_addr #0

declare void @w2c_hermes_0x5F_assert_fail(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AisUncatchableError0x28hermes0x3A0x3Avm0x3A0x3AHermesValue0x29(ptr noundef %0, i64 noundef %1) local_unnamed_addr #3 {
  %3 = icmp ult i64 %1, -844424930131968
  br i1 %3, label %14, label %4

4:                                                ; preds = %2
  %5 = and i64 %1, 4294967295
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %15, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = add nuw nsw i64 %5, 3
  %9 = tail call i32 @i32_load8_u(ptr noundef nonnull %7, i64 noundef %8)
  %.mask = and i32 %9, 255
  %.not37 = icmp eq i32 %.mask, 29
  br i1 %.not37, label %10, label %14

10:                                               ; preds = %6
  %11 = add nuw nsw i64 %5, 44
  %12 = tail call i32 @i32_load8_u(ptr noundef nonnull %7, i64 noundef %11)
  %.not38 = icmp eq i32 %12, 0
  %13 = zext i1 %.not38 to i32
  br label %14

14:                                               ; preds = %6, %2, %10
  %.0 = phi i32 [ 0, %2 ], [ 0, %6 ], [ %13, %10 ]
  ret i32 %.0

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

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