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

34:                                               ; preds = %1
  br label %132

35:                                               ; preds = %1
  store i32 291704, ptr %5, align 4, !tbaa !9
  %36 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %36, ptr %6, align 4, !tbaa !9
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.w2c_hermes, ptr %37, i32 0, i32 6
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = add i64 %40, 12
  %42 = call i32 @i32_load(ptr noundef %38, i64 noundef %41)
  store i32 %42, ptr %6, align 4, !tbaa !9
  store i32 2, ptr %7, align 4, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = and i32 %43, 31
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = shl i32 %45, %44
  store i32 %46, ptr %6, align 4, !tbaa !9
  store i32 4, ptr %7, align 4, !tbaa !9
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = add i32 %48, %47
  store i32 %49, ptr %6, align 4, !tbaa !9
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = call i32 @w2c_hermes_dlmalloc(ptr noundef %50, i32 noundef %51)
  store i32 %52, ptr %6, align 4, !tbaa !9
  %53 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %53, ptr %4, align 4, !tbaa !9
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.w2c_hermes, ptr %54, i32 0, i32 6
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = load i32, ptr %6, align 4, !tbaa !9
  call void @i32_store(ptr noundef %55, i64 noundef %57, i32 noundef %58)
  %59 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %59, ptr %5, align 4, !tbaa !9
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  %62 = xor i1 %61, true
  %63 = zext i1 %62 to i32
  store i32 %63, ptr %5, align 4, !tbaa !9
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %35
  br label %132

67:                                               ; preds = %35
  %68 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %68, ptr %5, align 4, !tbaa !9
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.w2c_hermes, ptr %69, i32 0, i32 6
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = zext i32 %71 to i64
  %73 = add i64 %72, 8
  %74 = call i32 @i32_load(ptr noundef %70, i64 noundef %73)
  store i32 %74, ptr %5, align 4, !tbaa !9
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = call i32 @w2c_hermes_dlmalloc(ptr noundef %75, i32 noundef %76)
  store i32 %77, ptr %5, align 4, !tbaa !9
  %78 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %78, ptr %4, align 4, !tbaa !9
  %79 = load i32, ptr %5, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %126

81:                                               ; preds = %67
  store i32 291704, ptr %5, align 4, !tbaa !9
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.w2c_hermes, ptr %82, i32 0, i32 6
  %84 = load i32, ptr %5, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = call i32 @i32_load(ptr noundef %83, i64 noundef %85)
  store i32 %86, ptr %5, align 4, !tbaa !9
  %87 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %87, ptr %6, align 4, !tbaa !9
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.w2c_hermes, ptr %88, i32 0, i32 6
  %90 = load i32, ptr %6, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = add i64 %91, 12
  %93 = call i32 @i32_load(ptr noundef %89, i64 noundef %92)
  store i32 %93, ptr %6, align 4, !tbaa !9
  store i32 2, ptr %7, align 4, !tbaa !9
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = and i32 %94, 31
  %96 = load i32, ptr %6, align 4, !tbaa !9
  %97 = shl i32 %96, %95
  store i32 %97, ptr %6, align 4, !tbaa !9
  %98 = load i32, ptr %6, align 4, !tbaa !9
  %99 = load i32, ptr %5, align 4, !tbaa !9
  %100 = add i32 %99, %98
  store i32 %100, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.w2c_hermes, ptr %101, i32 0, i32 6
  %103 = load i32, ptr %5, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = load i32, ptr %6, align 4, !tbaa !9
  call void @i32_store(ptr noundef %102, i64 noundef %104, i32 noundef %105)
  store i32 291704, ptr %5, align 4, !tbaa !9
  %106 = load ptr, ptr %2, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.w2c_hermes, ptr %106, i32 0, i32 6
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = zext i32 %108 to i64
  %110 = call i32 @i32_load(ptr noundef %107, i64 noundef %109)
  store i32 %110, ptr %5, align 4, !tbaa !9
  %111 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %111, ptr %6, align 4, !tbaa !9
  %112 = load ptr, ptr %2, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.w2c_hermes, ptr %112, i32 0, i32 2
  %114 = load ptr, ptr %113, align 8, !tbaa !17
  %115 = load i32, ptr %5, align 4, !tbaa !9
  %116 = load i32, ptr %6, align 4, !tbaa !9
  %117 = call i32 @w2c_wasi__snapshot__preview1_environ_get(ptr noundef %114, i32 noundef %115, i32 noundef %116)
  store i32 %117, ptr %5, align 4, !tbaa !9
  %118 = load i32, ptr %5, align 4, !tbaa !9
  %119 = icmp ne i32 %118, 0
  %120 = xor i1 %119, true
  %121 = zext i1 %120 to i32
  store i32 %121, ptr %5, align 4, !tbaa !9
  %122 = load i32, ptr %5, align 4, !tbaa !9
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %125

124:                                              ; preds = %81
  br label %132

125:                                              ; preds = %81
  br label %126

126:                                              ; preds = %125, %67
  store i32 291704, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  %127 = load ptr, ptr %2, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.w2c_hermes, ptr %127, i32 0, i32 6
  %129 = load i32, ptr %5, align 4, !tbaa !9
  %130 = zext i32 %129 to i64
  %131 = load i32, ptr %6, align 4, !tbaa !9
  call void @i32_store(ptr noundef %128, i64 noundef %130, i32 noundef %131)
  br label %132

132:                                              ; preds = %126, %124, %66, %34
  %133 = load i32, ptr %3, align 4, !tbaa !9
  store i32 %133, ptr %5, align 4, !tbaa !9
  store i32 16, ptr %6, align 4, !tbaa !9
  %134 = load i32, ptr %6, align 4, !tbaa !9
  %135 = load i32, ptr %5, align 4, !tbaa !9
  %136 = add i32 %135, %134
  store i32 %136, ptr %5, align 4, !tbaa !9
  %137 = load i32, ptr %5, align 4, !tbaa !9
  %138 = load ptr, ptr %2, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.w2c_hermes, ptr %138, i32 0, i32 3
  store i32 %137, ptr %139, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

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

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

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

declare i32 @w2c_wasi__snapshot__preview1_environ_get(ptr noundef, i32 noundef, i32 noundef) #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 = { 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}
!11 = !{!12, !10, i64 24}
!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 16}


; 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: nounwind uwtable
define dso_local void @w2c_hermes_0x5F_emscripten_environ_constructor(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = add i32 %3, -16
  store i32 %4, ptr %2, align 8, !tbaa !5
  %5 = add i32 %3, -4
  %6 = add i32 %3, -8
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  %9 = tail call i32 @w2c_wasi__snapshot__preview1_environ_sizes_get(ptr noundef %8, i32 noundef %5, i32 noundef %6) #3
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %32

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = zext i32 %4 to i64
  %13 = add nuw nsw i64 %12, 12
  %14 = tail call i32 @i32_load(ptr noundef nonnull %11, i64 noundef %13)
  %15 = shl i32 %14, 2
  %16 = add i32 %15, 4
  %17 = tail call i32 @w2c_hermes_dlmalloc(ptr noundef nonnull %0, i32 noundef %16)
  tail call void @i32_store(ptr noundef nonnull %11, i64 noundef 291704, i32 noundef %17)
  %.not66 = icmp eq i32 %17, 0
  br i1 %.not66, label %32, label %18

18:                                               ; preds = %10
  %19 = add nuw nsw i64 %12, 8
  %20 = tail call i32 @i32_load(ptr noundef nonnull %11, i64 noundef %19)
  %21 = tail call i32 @w2c_hermes_dlmalloc(ptr noundef nonnull %0, i32 noundef %20)
  %.not67 = icmp eq i32 %21, 0
  br i1 %.not67, label %31, label %22

22:                                               ; preds = %18
  %23 = tail call i32 @i32_load(ptr noundef nonnull %11, i64 noundef 291704)
  %24 = tail call i32 @i32_load(ptr noundef nonnull %11, i64 noundef %13)
  %25 = shl i32 %24, 2
  %26 = add i32 %25, %23
  %27 = zext i32 %26 to i64
  tail call void @i32_store(ptr noundef nonnull %11, i64 noundef %27, i32 noundef 0)
  %28 = tail call i32 @i32_load(ptr noundef nonnull %11, i64 noundef 291704)
  %29 = load ptr, ptr %7, align 8, !tbaa !15
  %30 = tail call i32 @w2c_wasi__snapshot__preview1_environ_get(ptr noundef %29, i32 noundef %28, i32 noundef %21) #3
  %.not68 = icmp eq i32 %30, 0
  br i1 %.not68, label %32, label %31

31:                                               ; preds = %22, %18
  tail call void @i32_store(ptr noundef nonnull %11, i64 noundef 291704, i32 noundef 0)
  br label %32

32:                                               ; preds = %22, %10, %1, %31
  store i32 %3, ptr %2, align 8, !tbaa !5
  ret void
}

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

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

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

declare i32 @w2c_wasi__snapshot__preview1_environ_get(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { "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, !10, i64 24}
!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 = !{!6, !7, i64 16}


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