; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_opt_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 }

; 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_load8_u(ptr noundef, i64 noundef) #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store(ptr noundef, i64 noundef, i32 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 i64 @i64_load(ptr noundef, i64 noundef) #1

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

declare i32 @w2c_hermes_write(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

38:                                               ; preds = %147, %4
  %39 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %39, ptr %10, align 4, !tbaa !9
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.w2c_hermes, ptr %40, i32 0, i32 6
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = add i64 %43, 20
  %45 = call i32 @i32_load(ptr noundef %41, i64 noundef %44)
  store i32 %45, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %46, ptr %11, align 4, !tbaa !9
  store i32 2147483647, ptr %12, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %47, ptr %13, align 4, !tbaa !9
  %48 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %48, ptr %14, align 4, !tbaa !9
  store i32 2147483647, ptr %15, align 4, !tbaa !9
  %49 = load i32, ptr %14, align 4, !tbaa !9
  %50 = load i32, ptr %15, align 4, !tbaa !9
  %51 = icmp uge i32 %49, %50
  %52 = zext i1 %51 to i32
  store i32 %52, ptr %14, align 4, !tbaa !9
  %53 = load i32, ptr %14, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %38
  %56 = load i32, ptr %12, align 4, !tbaa !9
  br label %59

57:                                               ; preds = %38
  %58 = load i32, ptr %13, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %57, %55
  %60 = phi i32 [ %56, %55 ], [ %58, %57 ]
  store i32 %60, ptr %12, align 4, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = call i32 @w2c_hermes_write(ptr noundef %61, i32 noundef %62, i32 noundef %63, i32 noundef %64)
  store i32 %65, ptr %10, align 4, !tbaa !9
  %66 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %66, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = icmp slt i32 %67, %68
  %70 = zext i1 %69 to i32
  store i32 %70, ptr %10, align 4, !tbaa !9
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %130

73:                                               ; preds = %59
  store i32 120240, ptr %10, align 4, !tbaa !9
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.w2c_hermes, ptr %74, i32 0, i32 6
  %76 = load i32, ptr %10, align 4, !tbaa !9
  %77 = zext i32 %76 to i64
  %78 = call i32 @i32_load(ptr noundef %75, i64 noundef %77)
  store i32 %78, ptr %10, align 4, !tbaa !9
  %79 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %79, ptr %9, align 4, !tbaa !9
  store i32 6, ptr %11, align 4, !tbaa !9
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = icmp eq i32 %80, %81
  %83 = zext i1 %82 to i32
  store i32 %83, ptr %10, align 4, !tbaa !9
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %87

86:                                               ; preds = %73
  br label %143

87:                                               ; preds = %73
  %88 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %88, ptr %10, align 4, !tbaa !9
  store i32 27, ptr %11, align 4, !tbaa !9
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = load i32, ptr %11, align 4, !tbaa !9
  %91 = icmp eq i32 %89, %90
  %92 = zext i1 %91 to i32
  store i32 %92, ptr %10, align 4, !tbaa !9
  %93 = load i32, ptr %10, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %87
  br label %143

96:                                               ; preds = %87
  store i32 121600, ptr %10, align 4, !tbaa !9
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.w2c_hermes, ptr %97, i32 0, i32 6
  %99 = load i32, ptr %10, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = call i32 @i32_load8_u(ptr noundef %98, i64 noundef %100)
  store i32 %101, ptr %10, align 4, !tbaa !9
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = icmp ne i32 %102, 0
  %104 = xor i1 %103, true
  %105 = zext i1 %104 to i32
  store i32 %105, ptr %10, align 4, !tbaa !9
  %106 = load i32, ptr %10, align 4, !tbaa !9
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %114

108:                                              ; preds = %96
  store i32 121600, ptr %10, align 4, !tbaa !9
  store i32 1, ptr %11, align 4, !tbaa !9
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.w2c_hermes, ptr %109, i32 0, i32 6
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = zext i32 %111 to i64
  %113 = load i32, ptr %11, align 4, !tbaa !9
  call void @i32_store8(ptr noundef %110, i64 noundef %112, i32 noundef %113)
  br label %114

114:                                              ; preds = %108, %96
  %115 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %115, ptr %10, align 4, !tbaa !9
  %116 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %116, ptr %11, align 4, !tbaa !9
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.w2c_hermes, ptr %117, i32 0, i32 6
  %119 = load i32, ptr %10, align 4, !tbaa !9
  %120 = zext i32 %119 to i64
  %121 = add i64 %120, 28
  %122 = load i32, ptr %11, align 4, !tbaa !9
  call void @i32_store(ptr noundef %118, i64 noundef %121, i32 noundef %122)
  %123 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %123, ptr %10, align 4, !tbaa !9
  store i32 109932, ptr %11, align 4, !tbaa !9
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.w2c_hermes, ptr %124, i32 0, i32 6
  %126 = load i32, ptr %10, align 4, !tbaa !9
  %127 = zext i32 %126 to i64
  %128 = add i64 %127, 32
  %129 = load i32, ptr %11, align 4, !tbaa !9
  call void @i32_store(ptr noundef %125, i64 noundef %128, i32 noundef %129)
  br label %149

130:                                              ; preds = %59
  %131 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %131, ptr %10, align 4, !tbaa !9
  %132 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %132, ptr %11, align 4, !tbaa !9
  %133 = load i32, ptr %11, align 4, !tbaa !9
  %134 = load i32, ptr %10, align 4, !tbaa !9
  %135 = sub i32 %134, %133
  store i32 %135, ptr %10, align 4, !tbaa !9
  %136 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %136, ptr %8, align 4, !tbaa !9
  %137 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %137, ptr %10, align 4, !tbaa !9
  %138 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %138, ptr %11, align 4, !tbaa !9
  %139 = load i32, ptr %11, align 4, !tbaa !9
  %140 = load i32, ptr %10, align 4, !tbaa !9
  %141 = add i32 %140, %139
  store i32 %141, ptr %10, align 4, !tbaa !9
  %142 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %142, ptr %7, align 4, !tbaa !9
  br label %143

143:                                              ; preds = %130, %95, %86
  %144 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %144, ptr %10, align 4, !tbaa !9
  %145 = load i32, ptr %10, align 4, !tbaa !9
  %146 = icmp ne i32 %145, 0
  br i1 %146, label %147, label %148

147:                                              ; preds = %143
  br label %38

148:                                              ; preds = %143
  br label %149

149:                                              ; preds = %148, %114
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

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

!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: inlinehint nounwind uwtable
declare hidden i32 @i32_load8_u(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store8(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i64_store(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

declare i32 @w2c_hermes_write(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @w2c_hermes_llvh0x3A0x3Araw_fd_ostream0x3A0x3Awrite_impl0x28char0x20const0x2A0x2C0x20unsigned0x20long0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = zext i32 %1 to i64
  %7 = add nuw nsw i64 %6, 40
  %8 = tail call i64 @i64_load(ptr noundef nonnull %5, i64 noundef %7)
  %9 = zext i32 %3 to i64
  %10 = add i64 %8, %9
  tail call void @i64_store(ptr noundef nonnull %5, i64 noundef %7, i64 noundef %10)
  %11 = add nuw nsw i64 %6, 20
  br label %12

12:                                               ; preds = %28, %4
  %.067 = phi i32 [ %3, %4 ], [ %.168, %28 ]
  %.0 = phi i32 [ %2, %4 ], [ %.1, %28 ]
  %13 = tail call i32 @i32_load(ptr noundef nonnull %5, i64 noundef %11)
  %14 = tail call i32 @llvm.umin.i32(i32 %.067, i32 2147483647)
  %15 = tail call i32 @w2c_hermes_write(ptr noundef %0, i32 noundef %13, i32 noundef %.0, i32 noundef %14) #4
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %25

17:                                               ; preds = %12
  %18 = tail call i32 @i32_load(ptr noundef nonnull %5, i64 noundef 120240)
  switch i32 %18, label %19 [
    i32 6, label %28
    i32 27, label %28
  ]

19:                                               ; preds = %17
  %20 = tail call i32 @i32_load8_u(ptr noundef nonnull %5, i64 noundef 121600)
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %22

21:                                               ; preds = %19
  tail call void @i32_store8(ptr noundef nonnull %5, i64 noundef 121600, i32 noundef 1)
  br label %22

22:                                               ; preds = %21, %19
  %23 = add nuw nsw i64 %6, 28
  tail call void @i32_store(ptr noundef nonnull %5, i64 noundef %23, i32 noundef %18)
  %24 = add nuw nsw i64 %6, 32
  tail call void @i32_store(ptr noundef nonnull %5, i64 noundef %24, i32 noundef 109932)
  br label %.loopexit

25:                                               ; preds = %12
  %26 = sub i32 %.067, %15
  %27 = add i32 %15, %.0
  br label %28

28:                                               ; preds = %17, %17, %25
  %.168 = phi i32 [ %.067, %17 ], [ %26, %25 ], [ %.067, %17 ]
  %.1 = phi i32 [ %.0, %17 ], [ %27, %25 ], [ %.0, %17 ]
  %.not71 = icmp eq i32 %.168, 0
  br i1 %.not71, label %.loopexit, label %12

.loopexit:                                        ; preds = %28, %22
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass