; 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_identifier_expr_t = type { %struct.gnode_t, ptr, ptr, ptr, %struct.gnode_location_t, ptr }
%struct.gnode_t = type { i32, i32, i32, %struct.gtoken_s, i8, ptr }
%struct.gnode_location_t = type { i32, i16, i16 }

; 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_identifier_expr_create(ptr noundef byval(%struct.gtoken_s) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  br label %32

13:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %14 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 112)
  store ptr %14, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.gnode_identifier_expr_t, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.gnode_t, ptr %16, i32 0, i32 0
  store i32 18, ptr %17, align 8, !tbaa !9
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.gnode_identifier_expr_t, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct.gnode_t, ptr %19, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %20, ptr align 8 %0, i64 40, i1 false), !tbaa.struct !17
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.gnode_identifier_expr_t, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.gnode_t, ptr %23, i32 0, i32 5
  store ptr %21, ptr %24, align 8, !tbaa !19
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.gnode_identifier_expr_t, ptr %26, i32 0, i32 1
  store ptr %25, ptr %27, align 8, !tbaa !20
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.gnode_identifier_expr_t, ptr %29, i32 0, i32 2
  store ptr %28, ptr %30, align 8, !tbaa !21
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %31, ptr %5, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %32

32:                                               ; preds = %13, %12
  %33 = load ptr, ptr %5, align 8
  ret ptr %33
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 0}
!10 = !{!"", !11, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !15, i64 96, !6, i64 104}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !13, i64 16, !14, i64 56, !6, i64 64}
!12 = !{!"int", !7, i64 0}
!13 = !{!"gtoken_s", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !6, i64 32}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!"", !12, i64 0, !16, i64 4, !16, i64 6}
!16 = !{!"short", !7, i64 0}
!17 = !{i64 0, i64 4, !18, i64 4, i64 4, !18, i64 8, i64 4, !18, i64 12, i64 4, !18, i64 16, i64 4, !18, i64 20, i64 4, !18, i64 24, i64 4, !18, i64 28, i64 4, !18, i64 32, i64 8, !5}
!18 = !{!12, !12, i64 0}
!19 = !{!10, !6, i64 64}
!20 = !{!10, !6, i64 72}
!21 = !{!10, !6, i64 80}


; 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_identifier_expr_create(ptr nocapture noundef readonly byval(%struct.gtoken_s) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %11, label %5

5:                                                ; preds = %4
  %6 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 112) #3
  store i32 18, 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 !16
  %8 = getelementptr inbounds i8, ptr %6, i64 64
  store ptr %3, ptr %8, align 8, !tbaa !19
  %9 = getelementptr inbounds i8, ptr %6, i64 72
  store ptr %1, ptr %9, align 8, !tbaa !20
  %10 = getelementptr inbounds i8, ptr %6, i64 80
  store ptr %2, ptr %10, align 8, !tbaa !21
  br label %11

11:                                               ; preds = %4, %5
  %.0 = phi ptr [ %6, %5 ], [ null, %4 ]
  ret ptr %.0
}

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, !12, i64 72, !12, i64 80, !12, i64 88, !14, i64 96, !12, i64 104}
!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 = !{!"", !8, i64 0, !15, i64 4, !15, i64 6}
!15 = !{!"short", !9, i64 0}
!16 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17, i64 20, i64 4, !17, i64 24, i64 4, !17, i64 28, i64 4, !17, i64 32, i64 8, !18}
!17 = !{!8, !8, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{!6, !12, i64 64}
!20 = !{!6, !12, i64 72}
!21 = !{!6, !12, i64 80}


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