; 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 }
%struct.wasm_rt_funcref_t = type { ptr, ptr, ptr }

@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_dlfree(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3AHermesLLVMMemoryBuffer0x3A0x3A0x7EHermesLLVMMemoryBuffer0x280x29(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %8 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %8, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.w2c_hermes, ptr %9, i32 0, i32 6
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = add i64 %12, 24
  %14 = call i32 @i32_load(ptr noundef %10, i64 noundef %13)
  store i32 %14, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %15, ptr %5, align 4, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %16, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.w2c_hermes, ptr %17, i32 0, i32 6
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = add i64 %20, 24
  %22 = load i32, ptr %7, align 4, !tbaa !9
  call void @i32_store(ptr noundef %18, i64 noundef %21, i32 noundef %22)
  %23 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %23, ptr %6, align 4, !tbaa !9
  store i32 113856, ptr %7, align 4, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.w2c_hermes, ptr %24, i32 0, i32 6
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = load i32, ptr %7, align 4, !tbaa !9
  call void @i32_store(ptr noundef %25, i64 noundef %27, i32 noundef %28)
  %29 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %29, ptr %6, align 4, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %106

32:                                               ; preds = %2
  %33 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %33, ptr %6, align 4, !tbaa !9
  %34 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %34, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.w2c_hermes, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = call i32 @i32_load(ptr noundef %36, i64 noundef %38)
  store i32 %39, ptr %7, align 4, !tbaa !9
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.w2c_hermes, ptr %40, i32 0, i32 6
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = add i64 %43, 4
  %45 = call i32 @i32_load(ptr noundef %41, i64 noundef %44)
  store i32 %45, ptr %7, align 4, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.w2c_hermes, ptr %47, i32 0, i32 7
  %49 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = icmp ult i32 %46, %50
  br i1 %51, label %52, label %74

52:                                               ; preds = %32
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.w2c_hermes, ptr %53, i32 0, i32 7
  %55 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %74

63:                                               ; preds = %52
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.w2c_hermes, ptr %64, i32 0, i32 7
  %66 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !17
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %67, i64 %69
  %71 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !20
  %73 = call zeroext i1 @func_types_eq(ptr noundef @.str.3, ptr noundef %72)
  br label %74

74:                                               ; preds = %63, %52, %32
  %75 = phi i1 [ false, %52 ], [ false, %32 ], [ %73, %63 ]
  %76 = xor i1 %75, true
  %77 = xor i1 %76, true
  %78 = zext i1 %77 to i32
  %79 = sext i32 %78 to i64
  %80 = call i64 @llvm.expect.i64(i64 %79, i64 1)
  %81 = icmp ne i64 %80, 0
  br i1 %81, label %84, label %82

82:                                               ; preds = %74
  call void @wasm_rt_trap(i32 noundef 6) #6
  unreachable

83:                                               ; No predecessors!
  br label %84

84:                                               ; preds = %83, %74
  %85 = phi i1 [ true, %74 ], [ false, %83 ]
  %86 = zext i1 %85 to i32
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.w2c_hermes, ptr %87, i32 0, i32 7
  %89 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !17
  %91 = load i32, ptr %7, align 4, !tbaa !9
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %90, i64 %92
  %94 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %93, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !18
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.w2c_hermes, ptr %96, i32 0, i32 7
  %98 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !17
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %99, i64 %101
  %103 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %102, i32 0, i32 2
  %104 = load ptr, ptr %103, align 8, !tbaa !21
  %105 = load i32, ptr %6, align 4, !tbaa !9
  call void %95(ptr noundef %104, i32 noundef %105)
  br label %106

106:                                              ; preds = %84, %2
  %107 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %107, ptr %6, align 4, !tbaa !9
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.w2c_hermes, ptr %108, i32 0, i32 6
  %110 = load i32, ptr %6, align 4, !tbaa !9
  %111 = zext i32 %110 to i64
  %112 = add i64 %111, 23
  %113 = call i32 @i32_load8_s(ptr noundef %109, i64 noundef %112)
  store i32 %113, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  %114 = load i32, ptr %6, align 4, !tbaa !9
  %115 = load i32, ptr %7, align 4, !tbaa !9
  %116 = icmp slt i32 %114, %115
  %117 = zext i1 %116 to i32
  store i32 %117, ptr %6, align 4, !tbaa !9
  %118 = load i32, ptr %6, align 4, !tbaa !9
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %130

120:                                              ; preds = %106
  %121 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %121, ptr %6, align 4, !tbaa !9
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.w2c_hermes, ptr %122, i32 0, i32 6
  %124 = load i32, ptr %6, align 4, !tbaa !9
  %125 = zext i32 %124 to i64
  %126 = add i64 %125, 12
  %127 = call i32 @i32_load(ptr noundef %123, i64 noundef %126)
  store i32 %127, ptr %6, align 4, !tbaa !9
  %128 = load ptr, ptr %3, align 8, !tbaa !5
  %129 = load i32, ptr %6, align 4, !tbaa !9
  call void @w2c_hermes_dlfree(ptr noundef %128, i32 noundef %129)
  br label %130

130:                                              ; preds = %120, %106
  %131 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %131, ptr %6, align 4, !tbaa !9
  %132 = load i32, ptr %6, align 4, !tbaa !9
  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 %132
}

; 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 void @i32_store(ptr noundef, i64 noundef, i32 noundef) #2

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @func_types_eq(ptr noundef, ptr 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 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 92}
!12 = !{!"w2c_hermes", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !13, i64 40, !16, i64 80}
!13 = !{!"", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !15, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!12, !6, i64 80}
!18 = !{!19, !6, i64 8}
!19 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!19, !6, i64 0}
!21 = !{!19, !6, i64 16}


; 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"

%struct.wasm_rt_funcref_t = type { ptr, ptr, ptr }

@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_dlfree(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @w2c_hermes_hermes0x3A0x3AHermesLLVMMemoryBuffer0x3A0x3A0x7EHermesLLVMMemoryBuffer0x280x29(ptr noundef %0, i32 noundef returned %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = zext i32 %1 to i64
  %5 = add nuw nsw i64 %4, 24
  %6 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %5)
  tail call void @i32_store(ptr noundef nonnull %3, i64 noundef %5, i32 noundef 0)
  tail call void @i32_store(ptr noundef nonnull %3, i64 noundef %4, i32 noundef 113856)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %33, label %7

7:                                                ; preds = %2
  %8 = zext i32 %6 to i64
  %9 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %8)
  %10 = zext i32 %9 to i64
  %11 = add nuw nsw i64 %10, 4
  %12 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = getelementptr inbounds i8, ptr %0, i64 92
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %17, label %.critedge, !prof !15

17:                                               ; preds = %7
  %18 = load ptr, ptr %13, align 8, !tbaa !16
  %19 = zext i32 %12 to i64
  %20 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %18, i64 %19
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %.not44 = icmp eq ptr %22, null
  br i1 %.not44, label %.critedge, label %23, !prof !19

23:                                               ; preds = %17
  %24 = load ptr, ptr %20, align 8, !tbaa !20
  %25 = tail call zeroext i1 @func_types_eq(ptr noundef nonnull @.str.3, ptr noundef %24)
  br i1 %25, label %26, label %.critedge, !prof !15

.critedge:                                        ; preds = %17, %7, %23
  tail call void @wasm_rt_trap(i32 noundef 6) #3
  unreachable

26:                                               ; preds = %23
  %27 = load ptr, ptr %13, align 8, !tbaa !16
  %28 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %27, i64 %19
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %28, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  tail call void %30(ptr noundef %32, i32 noundef %6) #4
  br label %33

33:                                               ; preds = %26, %2
  %34 = add nuw nsw i64 %4, 23
  %35 = tail call i32 @i32_load8_s(ptr noundef nonnull %3, i64 noundef %34)
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %33
  %38 = add nuw nsw i64 %4, 12
  %39 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %38)
  tail call void @w2c_hermes_dlfree(ptr noundef %0, i32 noundef %39)
  br label %40

40:                                               ; preds = %37, %33
  ret i32 %1
}

; 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 void @i32_store(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @func_types_eq(ptr noundef, ptr 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" }
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 = { noreturn nounwind }
attributes #4 = { 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, !10, i64 92}
!6 = !{!"w2c_hermes", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 40, !14, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !13, i64 32}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!16 = !{!6, !7, i64 80}
!17 = !{!18, !7, i64 8}
!18 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!19 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!20 = !{!18, !7, i64 0}
!21 = !{!18, !7, i64 16}


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