; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_opt_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 i32 @w2c_hermes_0x28anonymous0x20namespace0x290x3A0x3Aget_host_function0x28HermesABIRuntime0x2A0x2C0x20HermesABIFunction0x29(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
  %14 = 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) #3
  store i64 0, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i32 67200, ptr %8, align 4, !tbaa !9
  %15 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %15, ptr %5, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %16, ptr %8, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.w2c_hermes, ptr %17, i32 0, i32 6
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = add i64 %20, 8
  %22 = call i64 @i64_load(ptr noundef %18, i64 noundef %21)
  store i64 %22, ptr %12, align 8, !tbaa !11
  %23 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %23, ptr %7, align 8, !tbaa !11
  store i64 -844424930131968, ptr %13, align 8, !tbaa !11
  %24 = load i64, ptr %12, align 8, !tbaa !11
  %25 = load i64, ptr %13, align 8, !tbaa !11
  %26 = icmp uge i64 %24, %25
  %27 = zext i1 %26 to i32
  store i32 %27, ptr %8, align 4, !tbaa !9
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %61

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

54:                                               ; preds = %30
  %55 = load i32, ptr %8, align 4, !tbaa !9
  br label %58

56:                                               ; preds = %30
  %57 = load i32, ptr %9, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %56, %54
  %59 = phi i32 [ %55, %54 ], [ %57, %56 ]
  store i32 %59, ptr %8, align 4, !tbaa !9
  %60 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %60, ptr %5, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %58, %3
  store i32 0, ptr %8, align 4, !tbaa !9
  %62 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %62, ptr %6, align 4, !tbaa !9
  %63 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %63, ptr %8, align 4, !tbaa !9
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.w2c_hermes, ptr %64, i32 0, i32 6
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = call i64 @i64_load(ptr noundef %65, i64 noundef %67)
  store i64 %68, ptr %12, align 8, !tbaa !11
  %69 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %69, ptr %7, align 8, !tbaa !11
  store i64 -844424930131968, ptr %13, align 8, !tbaa !11
  %70 = load i64, ptr %12, align 8, !tbaa !11
  %71 = load i64, ptr %13, align 8, !tbaa !11
  %72 = icmp ult i64 %70, %71
  %73 = zext i1 %72 to i32
  store i32 %73, ptr %8, align 4, !tbaa !9
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %61
  br label %106

77:                                               ; preds = %61
  %78 = load i64, ptr %7, align 8, !tbaa !11
  store i64 %78, ptr %12, align 8, !tbaa !11
  store i64 4294967295, ptr %13, align 8, !tbaa !11
  %79 = load i64, ptr %13, align 8, !tbaa !11
  %80 = load i64, ptr %12, align 8, !tbaa !11
  %81 = and i64 %80, %79
  store i64 %81, ptr %12, align 8, !tbaa !11
  %82 = load i64, ptr %12, align 8, !tbaa !11
  %83 = icmp ne i64 %82, 0
  %84 = xor i1 %83, true
  %85 = zext i1 %84 to i32
  store i32 %85, ptr %8, align 4, !tbaa !9
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %77
  br label %106

89:                                               ; preds = %77
  %90 = load i64, ptr %7, align 8, !tbaa !11
  store i64 %90, ptr %12, align 8, !tbaa !11
  %91 = load i64, ptr %12, align 8, !tbaa !11
  %92 = trunc i64 %91 to i32
  store i32 %92, ptr %8, align 4, !tbaa !9
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.w2c_hermes, ptr %93, i32 0, i32 6
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = zext i32 %95 to i64
  %97 = add i64 %96, 24
  %98 = call i32 @i32_load(ptr noundef %94, i64 noundef %97)
  store i32 %98, ptr %8, align 4, !tbaa !9
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.w2c_hermes, ptr %99, i32 0, i32 6
  %101 = load i32, ptr %8, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  %103 = add i64 %102, 4
  %104 = call i32 @i32_load(ptr noundef %100, i64 noundef %103)
  store i32 %104, ptr %8, align 4, !tbaa !9
  %105 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %105, ptr %6, align 4, !tbaa !9
  br label %106

106:                                              ; preds = %89, %88, %76
  %107 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %107, ptr %8, align 4, !tbaa !9
  %108 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 %108
}

; 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: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) #2

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

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

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 = { 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 }

!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 i32 @w2c_hermes_0x28anonymous0x20namespace0x290x3A0x3Aget_host_function0x28HermesABIRuntime0x2A0x2C0x20HermesABIFunction0x29(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, 8
  %7 = tail call i64 @i64_load(ptr noundef nonnull %4, i64 noundef %6)
  %8 = icmp ugt i64 %7, -844424930131969
  br i1 %8, label %9, label %16

9:                                                ; preds = %3
  %10 = add i32 %2, 8
  %11 = and i64 %7, 4294967295
  %12 = add nuw nsw i64 %11, 3
  %13 = tail call i32 @i32_load8_u(ptr noundef nonnull %4, i64 noundef %12)
  %.mask = and i32 %13, 255
  %.not = icmp eq i32 %.mask, 72
  %14 = select i1 %.not, i32 %10, i32 67200
  %15 = zext i32 %14 to i64
  br label %16

16:                                               ; preds = %9, %3
  %.0 = phi i64 [ %15, %9 ], [ 67200, %3 ]
  %17 = tail call i64 @i64_load(ptr noundef nonnull %4, i64 noundef %.0)
  %18 = icmp ult i64 %17, -844424930131968
  %19 = and i64 %17, 4294967295
  %.not47 = icmp eq i64 %19, 0
  %or.cond = or i1 %18, %.not47
  br i1 %or.cond, label %26, label %20

20:                                               ; preds = %16
  %21 = add nuw nsw i64 %19, 24
  %22 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %21)
  %23 = zext i32 %22 to i64
  %24 = add nuw nsw i64 %23, 4
  %25 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %24)
  br label %26

26:                                               ; preds = %16, %20
  %.044 = phi i32 [ 0, %16 ], [ %25, %20 ]
  ret i32 %.044
}

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

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

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

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

!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