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

; 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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AStringPrimitive0x3A0x3AcastToUTF16PointerForWrite0x280x29(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 i32, align 4
  %10 = alloca i32, align 4
  %11 = 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
  store i32 0, ptr %6, align 4, !tbaa !9
  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
  %12 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %12, ptr %7, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.w2c_hermes, ptr %13, i32 0, i32 6
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = call i32 @i32_load(ptr noundef %14, i64 noundef %16)
  store i32 %17, ptr %7, align 4, !tbaa !9
  %18 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %18, ptr %6, align 4, !tbaa !9
  store i32 -16777216, ptr %8, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = and i32 %20, %19
  store i32 %21, ptr %7, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %22, ptr %5, align 4, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %23, ptr %7, align 4, !tbaa !9
  store i32 150994944, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp uge i32 %24, %25
  %27 = zext i1 %26 to i32
  store i32 %27, ptr %7, align 4, !tbaa !9
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %70

30:                                               ; preds = %2
  %31 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %31, ptr %7, align 4, !tbaa !9
  store i32 150994944, ptr %8, align 4, !tbaa !9
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = icmp ne i32 %32, %33
  %35 = zext i1 %34 to i32
  store i32 %35, ptr %7, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %30
  br label %114

39:                                               ; preds = %30
  %40 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %40, ptr %7, align 4, !tbaa !9
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.w2c_hermes, ptr %41, i32 0, i32 6
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = add i64 %44, 20
  %46 = call i32 @i32_load(ptr noundef %42, i64 noundef %45)
  store i32 %46, ptr %7, align 4, !tbaa !9
  %47 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %47, ptr %8, align 4, !tbaa !9
  store i32 20, ptr %9, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = add i32 %49, %48
  store i32 %50, ptr %8, align 4, !tbaa !9
  %51 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %51, ptr %9, align 4, !tbaa !9
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.w2c_hermes, ptr %52, i32 0, i32 6
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = add i64 %55, 31
  %57 = call i32 @i32_load8_s(ptr noundef %53, i64 noundef %56)
  store i32 %57, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  %61 = zext i1 %60 to i32
  store i32 %61, ptr %9, align 4, !tbaa !9
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %39
  %65 = load i32, ptr %7, align 4, !tbaa !9
  br label %68

66:                                               ; preds = %39
  %67 = load i32, ptr %8, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %66, %64
  %69 = phi i32 [ %65, %64 ], [ %67, %66 ]
  store i32 %69, ptr %7, align 4, !tbaa !9
  br label %132

70:                                               ; preds = %2
  %71 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %71, ptr %7, align 4, !tbaa !9
  store i32 50331648, ptr %8, align 4, !tbaa !9
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = icmp ne i32 %72, %73
  %75 = zext i1 %74 to i32
  store i32 %75, ptr %7, align 4, !tbaa !9
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %109

78:                                               ; preds = %70
  %79 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %79, ptr %7, align 4, !tbaa !9
  store i32 117440512, ptr %8, align 4, !tbaa !9
  %80 = load i32, ptr %7, align 4, !tbaa !9
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = icmp eq i32 %80, %81
  %83 = zext i1 %82 to i32
  store i32 %83, ptr %7, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %91

86:                                               ; preds = %78
  %87 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %87, ptr %7, align 4, !tbaa !9
  store i32 20, ptr %8, align 4, !tbaa !9
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = add i32 %89, %88
  store i32 %90, ptr %7, align 4, !tbaa !9
  br label %132

91:                                               ; preds = %78
  store i32 0, ptr %7, align 4, !tbaa !9
  %92 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %92, ptr %4, align 4, !tbaa !9
  store i32 205012, ptr %8, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = add i32 %94, %93
  store i32 %95, ptr %7, align 4, !tbaa !9
  %96 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %96, ptr %8, align 4, !tbaa !9
  store i32 82611, ptr %9, align 4, !tbaa !9
  %97 = load i32, ptr %9, align 4, !tbaa !9
  %98 = load i32, ptr %8, align 4, !tbaa !9
  %99 = add i32 %98, %97
  store i32 %99, ptr %8, align 4, !tbaa !9
  store i32 255, ptr %9, align 4, !tbaa !9
  %100 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %100, ptr %10, align 4, !tbaa !9
  store i32 24720, ptr %11, align 4, !tbaa !9
  %101 = load i32, ptr %11, align 4, !tbaa !9
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = add i32 %102, %101
  store i32 %103, ptr %10, align 4, !tbaa !9
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = load i32, ptr %7, align 4, !tbaa !9
  %106 = load i32, ptr %8, align 4, !tbaa !9
  %107 = load i32, ptr %9, align 4, !tbaa !9
  %108 = load i32, ptr %10, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_assert_fail(ptr noundef %104, i32 noundef %105, i32 noundef %106, i32 noundef %107, i32 noundef %108)
  call void @wasm_rt_trap(i32 noundef 5) #6
  unreachable

109:                                              ; preds = %70
  %110 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %110, ptr %7, align 4, !tbaa !9
  store i32 16, ptr %8, align 4, !tbaa !9
  %111 = load i32, ptr %8, align 4, !tbaa !9
  %112 = load i32, ptr %7, align 4, !tbaa !9
  %113 = add i32 %112, %111
  store i32 %113, ptr %7, align 4, !tbaa !9
  br label %132

114:                                              ; preds = %38
  store i32 0, ptr %7, align 4, !tbaa !9
  %115 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %115, ptr %4, align 4, !tbaa !9
  store i32 205012, ptr %8, align 4, !tbaa !9
  %116 = load i32, ptr %8, align 4, !tbaa !9
  %117 = load i32, ptr %7, align 4, !tbaa !9
  %118 = add i32 %117, %116
  store i32 %118, ptr %7, align 4, !tbaa !9
  %119 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %119, ptr %8, align 4, !tbaa !9
  store i32 82611, ptr %9, align 4, !tbaa !9
  %120 = load i32, ptr %9, align 4, !tbaa !9
  %121 = load i32, ptr %8, align 4, !tbaa !9
  %122 = add i32 %121, %120
  store i32 %122, ptr %8, align 4, !tbaa !9
  store i32 255, ptr %9, align 4, !tbaa !9
  %123 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %123, ptr %10, align 4, !tbaa !9
  store i32 24720, ptr %11, align 4, !tbaa !9
  %124 = load i32, ptr %11, align 4, !tbaa !9
  %125 = load i32, ptr %10, align 4, !tbaa !9
  %126 = add i32 %125, %124
  store i32 %126, ptr %10, align 4, !tbaa !9
  %127 = load ptr, ptr %3, align 8, !tbaa !5
  %128 = load i32, ptr %7, align 4, !tbaa !9
  %129 = load i32, ptr %8, align 4, !tbaa !9
  %130 = load i32, ptr %9, align 4, !tbaa !9
  %131 = load i32, ptr %10, 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) #6
  unreachable

132:                                              ; preds = %109, %86, %68
  %133 = load i32, ptr %7, align 4, !tbaa !9
  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 %133
}

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


; 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

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

declare void @w2c_hermes_0x5F_assert_fail(ptr noundef, i32 noundef, i32 noundef, i32 noundef, 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: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AStringPrimitive0x3A0x3AcastToUTF16PointerForWrite0x280x29(ptr noundef %0, i32 noundef %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = zext i32 %1 to i64
  %5 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %4)
  %6 = and i32 %5, -16777216
  %7 = icmp ugt i32 %5, 150994943
  br i1 %7, label %8, label %17

8:                                                ; preds = %2
  %.not72 = icmp eq i32 %6, 150994944
  br i1 %.not72, label %9, label %23

9:                                                ; preds = %8
  %10 = add nuw nsw i64 %4, 20
  %11 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %10)
  %12 = add i32 %1, 20
  %13 = add nuw nsw i64 %4, 31
  %14 = tail call i32 @i32_load8_s(ptr noundef nonnull %3, i64 noundef %13)
  %15 = icmp slt i32 %14, 0
  %16 = select i1 %15, i32 %11, i32 %12
  br label %24

17:                                               ; preds = %2
  switch i32 %6, label %20 [
    i32 50331648, label %21
    i32 117440512, label %18
  ]

18:                                               ; preds = %17
  %19 = add i32 %1, 20
  br label %24

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

21:                                               ; preds = %17
  %22 = add i32 %1, 16
  br label %24

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

24:                                               ; preds = %21, %18, %9
  %.0 = phi i32 [ %16, %9 ], [ %19, %18 ], [ %22, %21 ]
  ret i32 %.0
}

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