; LLVM IR from Water-Melon/Melon :: src (mln_expr)

; 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.mln_expr_val_t = type { i32, %union.anon, ptr }
%union.anon = type { i64 }
%struct.mln_string_t = type { ptr, i64, 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: nounwind uwtable
define dso_local ptr @mln_expr_val_new(i32 noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %12 = call noalias ptr @malloc(i64 noundef 24) #4
  store ptr %12, ptr %8, align 8, !tbaa !9
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %75

15:                                               ; preds = %3
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.mln_expr_val_t, ptr %17, i32 0, i32 0
  store i32 %16, ptr %18, align 8, !tbaa !11
  %19 = load i32, ptr %5, align 4, !tbaa !5
  switch i32 %19, label %66 [
    i32 0, label %20
    i32 1, label %23
    i32 2, label %30
    i32 3, label %37
    i32 4, label %44
  ]

20:                                               ; preds = %15
  %21 = load ptr, ptr %8, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.mln_expr_val_t, ptr %21, i32 0, i32 2
  store ptr null, ptr %22, align 8, !tbaa !13
  br label %73

23:                                               ; preds = %15
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = load i8, ptr %24, align 1, !tbaa !14
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.mln_expr_val_t, ptr %26, i32 0, i32 1
  store i8 %25, ptr %27, align 8, !tbaa !14
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.mln_expr_val_t, ptr %28, i32 0, i32 2
  store ptr null, ptr %29, align 8, !tbaa !13
  br label %73

30:                                               ; preds = %15
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = load i64, ptr %31, align 8, !tbaa !15
  %33 = load ptr, ptr %8, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.mln_expr_val_t, ptr %33, i32 0, i32 1
  store i64 %32, ptr %34, align 8, !tbaa !14
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.mln_expr_val_t, ptr %35, i32 0, i32 2
  store ptr null, ptr %36, align 8, !tbaa !13
  br label %73

37:                                               ; preds = %15
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  %39 = load double, ptr %38, align 8, !tbaa !17
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.mln_expr_val_t, ptr %40, i32 0, i32 1
  store double %39, ptr %41, align 8, !tbaa !14
  %42 = load ptr, ptr %8, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.mln_expr_val_t, ptr %42, i32 0, i32 2
  store ptr null, ptr %43, align 8, !tbaa !13
  br label %73

44:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %45, ptr %10, align 8, !tbaa !9
  %46 = load ptr, ptr %10, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.mln_string_t, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8
  %49 = lshr i32 %48, 2
  %50 = zext i32 %49 to i64
  %51 = add i64 %50, 1
  %52 = trunc i64 %51 to i32
  %53 = load i32, ptr %47, align 8
  %54 = and i32 %52, 1073741823
  %55 = shl i32 %54, 2
  %56 = and i32 %53, 3
  %57 = or i32 %56, %55
  store i32 %57, ptr %47, align 8
  %58 = zext i32 %54 to i64
  %59 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %59, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.mln_expr_val_t, ptr %61, i32 0, i32 1
  store ptr %60, ptr %62, align 8, !tbaa !14
  %63 = load ptr, ptr %7, align 8, !tbaa !9
  %64 = load ptr, ptr %8, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.mln_expr_val_t, ptr %64, i32 0, i32 2
  store ptr %63, ptr %65, align 8, !tbaa !13
  br label %73

66:                                               ; preds = %15
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = load ptr, ptr %8, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.mln_expr_val_t, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !14
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.mln_expr_val_t, ptr %71, i32 0, i32 2
  store ptr %70, ptr %72, align 8, !tbaa !13
  br label %73

73:                                               ; preds = %66, %44, %37, %30, %23, %20
  %74 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %74, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %75

75:                                               ; preds = %73, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %76 = load ptr, ptr %4, align 8
  ret ptr %76
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nounwind allocsize(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 }
attributes #4 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !7, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 16}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !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: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @mln_expr_val_new(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #2
  %5 = icmp eq ptr %4, null
  br i1 %5, label %27, label %6

6:                                                ; preds = %3
  store i32 %0, ptr %4, align 8, !tbaa !5
  switch i32 %0, label %24 [
    i32 0, label %.sink.split
    i32 1, label %7
    i32 2, label %10
    i32 3, label %13
    i32 4, label %16
  ]

7:                                                ; preds = %6
  %8 = load i8, ptr %1, align 1, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  store i8 %8, ptr %9, align 8, !tbaa !11
  br label %.sink.split

10:                                               ; preds = %6
  %11 = load i64, ptr %1, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %11, ptr %12, align 8, !tbaa !11
  br label %.sink.split

13:                                               ; preds = %6
  %14 = load double, ptr %1, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  store double %14, ptr %15, align 8, !tbaa !11
  br label %.sink.split

16:                                               ; preds = %6
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load i32, ptr %17, align 8
  %19 = and i32 %18, -4
  %20 = add i32 %19, 4
  %21 = and i32 %18, 3
  %22 = or disjoint i32 %20, %21
  store i32 %22, ptr %17, align 8
  %23 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %1, ptr %23, align 8, !tbaa !11
  br label %.sink.split

24:                                               ; preds = %6
  %25 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %1, ptr %25, align 8, !tbaa !11
  br label %.sink.split

.sink.split:                                      ; preds = %6, %24, %16, %13, %10, %7
  %.sink = phi ptr [ null, %7 ], [ null, %10 ], [ null, %13 ], [ %2, %16 ], [ %2, %24 ], [ null, %6 ]
  %26 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %.sink, ptr %26, align 8, !tbaa !16
  br label %27

27:                                               ; preds = %.sink.split, %3
  ret ptr %4
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !8, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!8, !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!6, !10, i64 16}


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