; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_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
declare dso_local i32 @w2c_hermes_dlmalloc(ptr noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_dlcalloc(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 i32, align 4
  %8 = alloca i64, align 8
  %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
  %15 = 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 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !11
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  %16 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %16, ptr %10, align 4, !tbaa !9
  %17 = load i32, ptr %10, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  %19 = xor i1 %18, true
  %20 = zext i1 %19 to i32
  store i32 %20, ptr %10, align 4, !tbaa !9
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %3
  br label %67

24:                                               ; preds = %3
  %25 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %25, ptr %9, align 4, !tbaa !9
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  store i64 %27, ptr %12, align 8, !tbaa !11
  %28 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %28, ptr %10, align 4, !tbaa !9
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  store i64 %30, ptr %13, align 8, !tbaa !11
  %31 = load i64, ptr %13, align 8, !tbaa !11
  %32 = load i64, ptr %12, align 8, !tbaa !11
  %33 = mul i64 %32, %31
  store i64 %33, ptr %12, align 8, !tbaa !11
  %34 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %34, ptr %8, align 8, !tbaa !11
  %35 = load i64, ptr %12, align 8, !tbaa !11
  %36 = trunc i64 %35 to i32
  store i32 %36, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %37, ptr %7, align 4, !tbaa !9
  %38 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %38, ptr %10, align 4, !tbaa !9
  %39 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %39, ptr %11, align 4, !tbaa !9
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = or i32 %41, %40
  store i32 %42, ptr %10, align 4, !tbaa !9
  store i32 65536, ptr %11, align 4, !tbaa !9
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = icmp ult i32 %43, %44
  %46 = zext i1 %45 to i32
  store i32 %46, ptr %10, align 4, !tbaa !9
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %24
  br label %67

50:                                               ; preds = %24
  store i32 -1, ptr %9, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %51, ptr %10, align 4, !tbaa !9
  %52 = load i64, ptr %8, align 8, !tbaa !11
  store i64 %52, ptr %14, align 8, !tbaa !11
  store i64 32, ptr %15, align 8, !tbaa !11
  %53 = load i64, ptr %15, align 8, !tbaa !11
  %54 = and i64 %53, 63
  %55 = load i64, ptr %14, align 8, !tbaa !11
  %56 = lshr i64 %55, %54
  store i64 %56, ptr %14, align 8, !tbaa !11
  %57 = load i64, ptr %14, align 8, !tbaa !11
  %58 = trunc i64 %57 to i32
  store i32 %58, ptr %11, align 4, !tbaa !9
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %63

61:                                               ; preds = %50
  %62 = load i32, ptr %9, align 4, !tbaa !9
  br label %65

63:                                               ; preds = %50
  %64 = load i32, ptr %10, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %63, %61
  %66 = phi i32 [ %62, %61 ], [ %64, %63 ]
  store i32 %66, ptr %9, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %65, %49, %23
  %68 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %68, ptr %7, align 4, !tbaa !9
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = call i32 @w2c_hermes_dlmalloc(ptr noundef %69, i32 noundef %70)
  store i32 %71, ptr %9, align 4, !tbaa !9
  %72 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %72, ptr %5, align 4, !tbaa !9
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = icmp ne i32 %73, 0
  %75 = xor i1 %74, true
  %76 = zext i1 %75 to i32
  store i32 %76, ptr %9, align 4, !tbaa !9
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %80

79:                                               ; preds = %67
  br label %108

80:                                               ; preds = %67
  %81 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %81, ptr %9, align 4, !tbaa !9
  store i32 4, ptr %10, align 4, !tbaa !9
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = load i32, ptr %9, align 4, !tbaa !9
  %84 = sub i32 %83, %82
  store i32 %84, ptr %9, align 4, !tbaa !9
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.w2c_hermes, ptr %85, i32 0, i32 6
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = call i32 @i32_load8_u(ptr noundef %86, i64 noundef %88)
  store i32 %89, ptr %9, align 4, !tbaa !9
  store i32 3, ptr %10, align 4, !tbaa !9
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = load i32, ptr %9, align 4, !tbaa !9
  %92 = and i32 %91, %90
  store i32 %92, ptr %9, align 4, !tbaa !9
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 0
  %95 = xor i1 %94, true
  %96 = zext i1 %95 to i32
  store i32 %96, ptr %9, align 4, !tbaa !9
  %97 = load i32, ptr %9, align 4, !tbaa !9
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %80
  br label %108

100:                                              ; preds = %80
  %101 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %101, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !9
  %102 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %102, ptr %11, align 4, !tbaa !9
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = load i32, ptr %9, align 4, !tbaa !9
  %105 = load i32, ptr %10, align 4, !tbaa !9
  %106 = load i32, ptr %11, align 4, !tbaa !9
  %107 = call i32 @w2c_hermes_0x5F_memset(ptr noundef %103, i32 noundef %104, i32 noundef %105, i32 noundef %106)
  store i32 %107, ptr %9, align 4, !tbaa !9
  br label %108

108:                                              ; preds = %100, %99, %79
  %109 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %109, ptr %9, align 4, !tbaa !9
  %110 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  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 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %110
}

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
declare dso_local i32 @w2c_hermes_dlmalloc(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_dlcalloc(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %10, label %4

4:                                                ; preds = %3
  %umul = tail call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %1, i32 %2)
  %umul.value = extractvalue { i32, i1 } %umul, 0
  %5 = or i32 %2, %1
  %6 = icmp ult i32 %5, 65536
  br i1 %6, label %10, label %7

7:                                                ; preds = %4
  %8 = extractvalue { i32, i1 } %umul, 1
  %9 = select i1 %8, i32 -1, i32 %umul.value
  br label %10

10:                                               ; preds = %4, %3, %7
  %.0 = phi i32 [ 0, %3 ], [ %umul.value, %4 ], [ %9, %7 ]
  %11 = tail call i32 @w2c_hermes_dlmalloc(ptr noundef %0, i32 noundef %.0)
  %.not50 = icmp eq i32 %11, 0
  br i1 %.not50, label %20, label %12

12:                                               ; preds = %10
  %13 = add i32 %11, -4
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = zext i32 %13 to i64
  %16 = tail call i32 @i32_load8_u(ptr noundef nonnull %14, i64 noundef %15)
  %17 = and i32 %16, 3
  %.not51 = icmp eq i32 %17, 0
  br i1 %.not51, label %20, label %18

18:                                               ; preds = %12
  %19 = tail call i32 @w2c_hermes_0x5F_memset(ptr noundef %0, i32 noundef %11, i32 noundef 0, i32 noundef %.0)
  br label %20

20:                                               ; preds = %12, %10, %18
  ret i32 %11
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32) #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 = { 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 speculatable willreturn memory(none) }

!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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass