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

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

@w2c_hermes_t22 = external constant ptr, align 8

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @func_types_eq(ptr noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @w2c_hermes_llvh0x3A0x3Acircular_raw_ostream0x3A0x3Acurrent_pos0x280x290x20const(ptr noundef %0, i32 noundef %1) #4 {
  %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
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %11 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %11, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.w2c_hermes, ptr %12, i32 0, i32 6
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = add i64 %15, 20
  %17 = call i32 @i32_load(ptr noundef %13, i64 noundef %16)
  store i32 %17, ptr %6, align 4, !tbaa !9
  %18 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %18, ptr %5, align 4, !tbaa !9
  %19 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %19, ptr %7, align 4, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.w2c_hermes, ptr %20, i32 0, i32 6
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = call i32 @i32_load(ptr noundef %21, i64 noundef %23)
  store i32 %24, ptr %7, align 4, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.w2c_hermes, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = add i64 %28, 32
  %30 = call i32 @i32_load(ptr noundef %26, i64 noundef %29)
  store i32 %30, ptr %7, align 4, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.w2c_hermes, ptr %32, i32 0, i32 7
  %34 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = icmp ult i32 %31, %35
  br i1 %36, label %37, label %60

37:                                               ; preds = %2
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.w2c_hermes, ptr %38, i32 0, i32 7
  %40 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %41, i64 %43
  %45 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %60

48:                                               ; preds = %37
  %49 = load ptr, ptr @w2c_hermes_t22, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.w2c_hermes, ptr %50, i32 0, i32 7
  %52 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !17
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %53, i64 %55
  %57 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !20
  %59 = call zeroext i1 @func_types_eq(ptr noundef %49, ptr noundef %58)
  br label %60

60:                                               ; preds = %48, %37, %2
  %61 = phi i1 [ false, %37 ], [ false, %2 ], [ %59, %48 ]
  %62 = xor i1 %61, true
  %63 = xor i1 %62, true
  %64 = zext i1 %63 to i32
  %65 = sext i32 %64 to i64
  %66 = call i64 @llvm.expect.i64(i64 %65, i64 1)
  %67 = icmp ne i64 %66, 0
  br i1 %67, label %70, label %68

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

69:                                               ; No predecessors!
  br label %70

70:                                               ; preds = %69, %60
  %71 = phi i1 [ true, %60 ], [ false, %69 ]
  %72 = zext i1 %71 to i32
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.w2c_hermes, ptr %73, i32 0, i32 7
  %75 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !17
  %77 = load i32, ptr %7, align 4, !tbaa !9
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %76, i64 %78
  %80 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %79, i32 0, i32 1
  %81 = load ptr, ptr %80, align 8, !tbaa !18
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.w2c_hermes, ptr %82, i32 0, i32 7
  %84 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !17
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %85, i64 %87
  %89 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %88, i32 0, i32 2
  %90 = load ptr, ptr %89, align 8, !tbaa !21
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = call i64 %81(ptr noundef %90, i32 noundef %91)
  store i64 %92, ptr %9, align 8, !tbaa !22
  %93 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %93, ptr %7, align 4, !tbaa !9
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.w2c_hermes, ptr %94, i32 0, i32 6
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = add i64 %97, 12
  %99 = call i32 @i32_load(ptr noundef %95, i64 noundef %98)
  store i32 %99, ptr %7, align 4, !tbaa !9
  %100 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %100, ptr %8, align 4, !tbaa !9
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.w2c_hermes, ptr %101, i32 0, i32 6
  %103 = load i32, ptr %8, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = add i64 %104, 4
  %106 = call i32 @i32_load(ptr noundef %102, i64 noundef %105)
  store i32 %106, ptr %8, align 4, !tbaa !9
  %107 = load i32, ptr %8, align 4, !tbaa !9
  %108 = load i32, ptr %7, align 4, !tbaa !9
  %109 = sub i32 %108, %107
  store i32 %109, ptr %7, align 4, !tbaa !9
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = zext i32 %110 to i64
  store i64 %111, ptr %10, align 8, !tbaa !22
  %112 = load i64, ptr %10, align 8, !tbaa !22
  %113 = load i64, ptr %9, align 8, !tbaa !22
  %114 = add i64 %113, %112
  store i64 %114, ptr %9, align 8, !tbaa !22
  %115 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %115, ptr %7, align 4, !tbaa !9
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.w2c_hermes, ptr %116, i32 0, i32 6
  %118 = load i32, ptr %7, align 4, !tbaa !9
  %119 = zext i32 %118 to i64
  %120 = add i64 %119, 20
  %121 = call i32 @i32_load(ptr noundef %117, i64 noundef %120)
  store i32 %121, ptr %7, align 4, !tbaa !9
  %122 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %122, ptr %5, align 4, !tbaa !9
  %123 = load ptr, ptr %3, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.w2c_hermes, ptr %123, i32 0, i32 6
  %125 = load i32, ptr %7, align 4, !tbaa !9
  %126 = zext i32 %125 to i64
  %127 = add i64 %126, 12
  %128 = call i32 @i32_load(ptr noundef %124, i64 noundef %127)
  store i32 %128, ptr %7, align 4, !tbaa !9
  %129 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %129, ptr %8, align 4, !tbaa !9
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.w2c_hermes, ptr %130, i32 0, i32 6
  %132 = load i32, ptr %8, align 4, !tbaa !9
  %133 = zext i32 %132 to i64
  %134 = add i64 %133, 4
  %135 = call i32 @i32_load(ptr noundef %131, i64 noundef %134)
  store i32 %135, ptr %8, align 4, !tbaa !9
  %136 = load i32, ptr %8, align 4, !tbaa !9
  %137 = load i32, ptr %7, align 4, !tbaa !9
  %138 = sub i32 %137, %136
  store i32 %138, ptr %7, align 4, !tbaa !9
  %139 = load i32, ptr %7, align 4, !tbaa !9
  %140 = zext i32 %139 to i64
  store i64 %140, ptr %10, align 8, !tbaa !22
  %141 = load i64, ptr %10, align 8, !tbaa !22
  %142 = load i64, ptr %9, align 8, !tbaa !22
  %143 = sub i64 %142, %141
  store i64 %143, ptr %9, align 8, !tbaa !22
  %144 = load i64, ptr %9, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, 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 i64 %144
}

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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { 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 = !{!"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}
!22 = !{!14, !14, 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"

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

@w2c_hermes_t22 = external local_unnamed_addr constant ptr, align 8

; 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 zeroext i1 @func_types_eq(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local i64 @w2c_hermes_llvh0x3A0x3Acircular_raw_ostream0x3A0x3Acurrent_pos0x280x290x20const(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = zext i32 %1 to i64
  %5 = add nuw nsw i64 %4, 20
  %6 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %5)
  %7 = zext i32 %6 to i64
  %8 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %7)
  %9 = zext i32 %8 to i64
  %10 = add nuw nsw i64 %9, 32
  %11 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 80
  %13 = getelementptr inbounds i8, ptr %0, i64 92
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp ult i32 %11, %14
  br i1 %15, label %16, label %.critedge, !prof !15

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

22:                                               ; preds = %16
  %23 = load ptr, ptr @w2c_hermes_t22, align 8, !tbaa !20
  %24 = load ptr, ptr %19, align 8, !tbaa !21
  %25 = tail call zeroext i1 @func_types_eq(ptr noundef %23, ptr noundef %24)
  br i1 %25, label %26, label %.critedge, !prof !15

.critedge:                                        ; preds = %16, %2, %22
  tail call void @wasm_rt_trap(i32 noundef 6) #3
  unreachable

26:                                               ; preds = %22
  %27 = load ptr, ptr %12, align 8, !tbaa !16
  %28 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %27, i64 %18
  %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 !22
  %33 = tail call i64 %30(ptr noundef %32, i32 noundef %6) #4
  %34 = add nuw nsw i64 %7, 12
  %35 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %34)
  %36 = add nuw nsw i64 %7, 4
  %37 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %36)
  %38 = sub i32 %35, %37
  %39 = zext i32 %38 to i64
  %40 = add i64 %33, %39
  %41 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %5)
  %42 = zext i32 %41 to i64
  %43 = add nuw nsw i64 %42, 12
  %44 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %43)
  %45 = add nuw nsw i64 %42, 4
  %46 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %45)
  %47 = sub i32 %44, %46
  %48 = zext i32 %47 to i64
  %49 = sub i64 %40, %48
  ret i64 %49
}

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 = { 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 = { 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 }
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 = !{!7, !7, i64 0}
!21 = !{!18, !7, i64 0}
!22 = !{!18, !7, i64 16}


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