; LLVM IR from marcobambini/gravity :: src/compiler (gravity_ast)

; 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.gtoken_s = type { i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%struct.gnode_postfix_subexpr_t = type { %struct.gnode_t, %union.anon.0 }
%struct.gnode_t = type { i32, i32, i32, %struct.gtoken_s, i8, ptr }
%union.anon.0 = type { ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @gnode_postfix_subexpr_create(ptr noundef byval(%struct.gtoken_s) align 8 %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store i32 %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  store ptr %4, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 80)
  store ptr %11, ptr %10, align 8, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = load ptr, ptr %10, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.gnode_postfix_subexpr_t, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.gnode_t, ptr %14, i32 0, i32 0
  store i32 %12, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %10, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.gnode_postfix_subexpr_t, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.gnode_t, ptr %17, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %0, i64 40, i1 false), !tbaa.struct !16
  %19 = load ptr, ptr %9, align 8, !tbaa !9
  %20 = load ptr, ptr %10, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.gnode_postfix_subexpr_t, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.gnode_t, ptr %21, i32 0, i32 5
  store ptr %19, ptr %22, align 8, !tbaa !17
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 21
  br i1 %24, label %25, label %29

25:                                               ; preds = %5
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = load ptr, ptr %10, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.gnode_postfix_subexpr_t, ptr %27, i32 0, i32 1
  store ptr %26, ptr %28, align 8, !tbaa !18
  br label %33

29:                                               ; preds = %5
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = load ptr, ptr %10, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.gnode_postfix_subexpr_t, ptr %31, i32 0, i32 1
  store ptr %30, ptr %32, align 8, !tbaa !18
  br label %33

33:                                               ; preds = %29, %25
  %34 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  ret ptr %34
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = !{!"", !13, i64 0, !7, i64 72}
!13 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !14, i64 16, !15, i64 56, !10, i64 64}
!14 = !{!"gtoken_s", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !10, i64 32}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5, i64 16, i64 4, !5, i64 20, i64 4, !5, i64 24, i64 4, !5, i64 28, i64 4, !5, i64 32, i64 8, !9}
!17 = !{!12, !10, i64 64}
!18 = !{!7, !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"

%struct.gtoken_s = type { i32, i32, i32, i32, i32, i32, i32, i32, ptr }

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @gnode_postfix_subexpr_create(ptr nocapture noundef readonly byval(%struct.gtoken_s) align 8 %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 80) #3
  store i32 %1, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %7, ptr noundef nonnull align 8 dereferenceable(40) %0, i64 40, i1 false), !tbaa.struct !14
  %8 = getelementptr inbounds i8, ptr %6, i64 64
  store ptr %4, ptr %8, align 8, !tbaa !17
  %9 = icmp eq i32 %1, 21
  %spec.select = select i1 %9, ptr %3, ptr %2
  %10 = getelementptr inbounds i8, ptr %6, i64 72
  store ptr %spec.select, ptr %10, align 8
  ret ptr %6
}

attributes #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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !8, i64 0}
!6 = !{!"", !7, i64 0, !9, i64 72}
!7 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !11, i64 16, !13, i64 56, !12, i64 64}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"gtoken_s", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !12, i64 32}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_Bool", !9, i64 0}
!14 = !{i64 0, i64 4, !15, i64 4, i64 4, !15, i64 8, i64 4, !15, i64 12, i64 4, !15, i64 16, i64 4, !15, i64 20, i64 4, !15, i64 24, i64 4, !15, i64 28, i64 4, !15, i64 32, i64 8, !16}
!15 = !{!8, !8, i64 0}
!16 = !{!12, !12, i64 0}
!17 = !{!6, !12, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass