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

declare i32 @w2c_hermes_internal_memalign(ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_dlposix_memalign(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %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
  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
  store i32 0, ptr %10, align 4, !tbaa !9
  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
  %15 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %15, ptr %11, align 4, !tbaa !9
  store i32 8, ptr %12, align 4, !tbaa !9
  %16 = load i32, ptr %11, align 4, !tbaa !9
  %17 = load i32, ptr %12, align 4, !tbaa !9
  %18 = icmp eq i32 %16, %17
  %19 = zext i1 %18 to i32
  store i32 %19, ptr %11, align 4, !tbaa !9
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %27

22:                                               ; preds = %4
  %23 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %23, ptr %11, align 4, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = call i32 @w2c_hermes_dlmalloc(ptr noundef %24, i32 noundef %25)
  store i32 %26, ptr %11, align 4, !tbaa !9
  br label %96

27:                                               ; preds = %4
  store i32 28, ptr %11, align 4, !tbaa !9
  %28 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %28, ptr %9, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %29, ptr %11, align 4, !tbaa !9
  store i32 4, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = icmp ult i32 %30, %31
  %33 = zext i1 %32 to i32
  store i32 %33, ptr %11, align 4, !tbaa !9
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %27
  br label %114

37:                                               ; preds = %27
  %38 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %38, ptr %11, align 4, !tbaa !9
  store i32 3, ptr %12, align 4, !tbaa !9
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = and i32 %40, %39
  store i32 %41, ptr %11, align 4, !tbaa !9
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %37
  br label %114

45:                                               ; preds = %37
  %46 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %46, ptr %11, align 4, !tbaa !9
  store i32 2, ptr %12, align 4, !tbaa !9
  %47 = load i32, ptr %12, align 4, !tbaa !9
  %48 = and i32 %47, 31
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = lshr i32 %49, %48
  store i32 %50, ptr %11, align 4, !tbaa !9
  %51 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %51, ptr %10, align 4, !tbaa !9
  %52 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %52, ptr %12, align 4, !tbaa !9
  store i32 1, ptr %13, align 4, !tbaa !9
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = sub i32 %54, %53
  store i32 %55, ptr %12, align 4, !tbaa !9
  %56 = load i32, ptr %12, align 4, !tbaa !9
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = and i32 %57, %56
  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 %62

61:                                               ; preds = %45
  br label %114

62:                                               ; preds = %45
  store i32 48, ptr %11, align 4, !tbaa !9
  %63 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %63, ptr %9, align 4, !tbaa !9
  store i32 -64, ptr %11, align 4, !tbaa !9
  %64 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %64, ptr %12, align 4, !tbaa !9
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = sub i32 %66, %65
  store i32 %67, ptr %11, align 4, !tbaa !9
  %68 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %68, ptr %12, align 4, !tbaa !9
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = load i32, ptr %12, align 4, !tbaa !9
  %71 = icmp ult i32 %69, %70
  %72 = zext i1 %71 to i32
  store i32 %72, ptr %11, align 4, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %62
  br label %114

76:                                               ; preds = %62
  store i32 16, ptr %11, align 4, !tbaa !9
  %77 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %77, ptr %12, align 4, !tbaa !9
  %78 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %78, ptr %13, align 4, !tbaa !9
  store i32 16, ptr %14, align 4, !tbaa !9
  %79 = load i32, ptr %13, align 4, !tbaa !9
  %80 = load i32, ptr %14, align 4, !tbaa !9
  %81 = icmp ule i32 %79, %80
  %82 = zext i1 %81 to i32
  store i32 %82, ptr %13, align 4, !tbaa !9
  %83 = load i32, ptr %13, align 4, !tbaa !9
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %87

85:                                               ; preds = %76
  %86 = load i32, ptr %11, align 4, !tbaa !9
  br label %89

87:                                               ; preds = %76
  %88 = load i32, ptr %12, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %87, %85
  %90 = phi i32 [ %86, %85 ], [ %88, %87 ]
  store i32 %90, ptr %11, align 4, !tbaa !9
  %91 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %91, ptr %12, align 4, !tbaa !9
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = call i32 @w2c_hermes_internal_memalign(ptr noundef %92, i32 noundef %93, i32 noundef %94)
  store i32 %95, ptr %11, align 4, !tbaa !9
  br label %96

96:                                               ; preds = %89, %22
  %97 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %97, ptr %7, align 4, !tbaa !9
  %98 = load i32, ptr %11, align 4, !tbaa !9
  %99 = icmp ne i32 %98, 0
  %100 = xor i1 %99, true
  %101 = zext i1 %100 to i32
  store i32 %101, ptr %11, align 4, !tbaa !9
  %102 = load i32, ptr %11, align 4, !tbaa !9
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %96
  store i32 48, ptr %11, align 4, !tbaa !9
  br label %116

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

114:                                              ; preds = %105, %75, %61, %44, %36
  %115 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %115, ptr %11, align 4, !tbaa !9
  br label %116

116:                                              ; preds = %114, %104
  %117 = load i32, ptr %11, align 4, !tbaa !9
  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 i32 %117
}

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


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

declare i32 @w2c_hermes_internal_memalign(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 49) i32 @w2c_hermes_dlposix_memalign(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq i32 %2, 8
  br i1 %5, label %6, label %8

6:                                                ; preds = %4
  %7 = tail call i32 @w2c_hermes_dlmalloc(ptr noundef %0, i32 noundef %3)
  br label %20

8:                                                ; preds = %4
  %9 = icmp ugt i32 %2, 3
  %10 = and i32 %2, 3
  %.not = icmp eq i32 %10, 0
  %or.cond = and i1 %9, %.not
  br i1 %or.cond, label %11, label %24

11:                                               ; preds = %8
  %12 = lshr exact i32 %2, 2
  %13 = tail call range(i32 0, 31) i32 @llvm.ctpop.i32(i32 %12)
  %.not58 = icmp ult i32 %13, 2
  br i1 %.not58, label %14, label %24

14:                                               ; preds = %11
  %15 = sub i32 -64, %2
  %16 = icmp ult i32 %15, %3
  br i1 %16, label %24, label %17

17:                                               ; preds = %14
  %18 = tail call i32 @llvm.umax.i32(i32 %2, i32 16)
  %19 = tail call i32 @w2c_hermes_internal_memalign(ptr noundef %0, i32 noundef %18, i32 noundef %3) #4
  br label %20

20:                                               ; preds = %17, %6
  %.0 = phi i32 [ %7, %6 ], [ %19, %17 ]
  %.not59 = icmp eq i32 %.0, 0
  br i1 %.not59, label %24, label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  %23 = zext i32 %1 to i64
  tail call void @i32_store(ptr noundef nonnull %22, i64 noundef %23, i32 noundef %.0)
  br label %24

24:                                               ; preds = %21, %8, %11, %14, %20
  %.1 = phi i32 [ 48, %20 ], [ 0, %21 ], [ 28, %8 ], [ 28, %11 ], [ 48, %14 ]
  ret i32 %.1
}

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

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

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 = { "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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass