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

; 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.ircode_t = type { ptr, %struct.uint32_r, %struct.uint32_r, %struct.uint32_r, i32, i32, i32, i16, i8, [256 x i8], [256 x i8], %struct.uint32_r, %struct.context_r }
%struct.uint32_r = type { i64, i64, ptr }
%struct.context_r = type { i64, i64, ptr }

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @ircode_register_push(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ircode_t, ptr %5, i32 0, i32 11
  %7 = getelementptr inbounds %struct.uint32_r, ptr %6, i32 0, i32 0
  %8 = load i64, ptr %7, align 8, !tbaa !11
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.ircode_t, ptr %9, i32 0, i32 11
  %11 = getelementptr inbounds %struct.uint32_r, ptr %10, i32 0, i32 1
  %12 = load i64, ptr %11, align 8, !tbaa !17
  %13 = icmp eq i64 %8, %12
  br i1 %13, label %14, label %45

14:                                               ; preds = %2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ircode_t, ptr %15, i32 0, i32 11
  %17 = getelementptr inbounds %struct.uint32_r, ptr %16, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !17
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %26

20:                                               ; preds = %14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ircode_t, ptr %21, i32 0, i32 11
  %23 = getelementptr inbounds %struct.uint32_r, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !17
  %25 = shl i64 %24, 1
  br label %27

26:                                               ; preds = %14
  br label %27

27:                                               ; preds = %26, %20
  %28 = phi i64 [ %25, %20 ], [ 8, %26 ]
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ircode_t, ptr %29, i32 0, i32 11
  %31 = getelementptr inbounds %struct.uint32_r, ptr %30, i32 0, i32 1
  store i64 %28, ptr %31, align 8, !tbaa !17
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ircode_t, ptr %32, i32 0, i32 11
  %34 = getelementptr inbounds %struct.uint32_r, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ircode_t, ptr %36, i32 0, i32 11
  %38 = getelementptr inbounds %struct.uint32_r, ptr %37, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !17
  %40 = mul i64 4, %39
  %41 = call ptr @realloc(ptr noundef %35, i64 noundef %40) #2
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ircode_t, ptr %42, i32 0, i32 11
  %44 = getelementptr inbounds %struct.uint32_r, ptr %43, i32 0, i32 2
  store ptr %41, ptr %44, align 8, !tbaa !18
  br label %45

45:                                               ; preds = %27, %2
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ircode_t, ptr %47, i32 0, i32 11
  %49 = getelementptr inbounds %struct.uint32_r, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ircode_t, ptr %51, i32 0, i32 11
  %53 = getelementptr inbounds %struct.uint32_r, ptr %52, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !11
  %55 = add i64 %54, 1
  store i64 %55, ptr %53, align 8, !tbaa !11
  %56 = getelementptr inbounds i32, ptr %50, i64 %54
  store i32 %46, ptr %56, align 4, !tbaa !9
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = call zeroext i1 @ircode_register_istemp(ptr noundef %57, i32 noundef %58)
  br i1 %59, label %60, label %65

60:                                               ; preds = %45
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ircode_t, ptr %61, i32 0, i32 6
  %63 = load i32, ptr %62, align 8, !tbaa !19
  %64 = add i32 %63, 1
  store i32 %64, ptr %62, align 8, !tbaa !19
  br label %65

65:                                               ; preds = %60, %45
  %66 = load i32, ptr %4, align 4, !tbaa !9
  ret i32 %66
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ircode_register_istemp(ptr noundef, i32 noundef) #1

attributes #0 = { nounwind allocsize(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 #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(1) }

!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, !14, i64 608}
!12 = !{!"ircode_t", !6, i64 0, !13, i64 8, !13, i64 32, !13, i64 56, !10, i64 80, !10, i64 84, !10, i64 88, !15, i64 92, !16, i64 94, !7, i64 95, !7, i64 351, !13, i64 608, !13, i64 632}
!13 = !{!"", !14, i64 0, !14, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!12, !14, i64 616}
!18 = !{!12, !6, i64 624}
!19 = !{!12, !10, i64 88}


; 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 nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ircode_register_push(ptr noundef %0, i32 noundef returned %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 608
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 616
  %6 = load i64, ptr %5, align 8, !tbaa !15
  %7 = icmp eq i64 %4, %6
  br i1 %7, label %8, label %._crit_edge

._crit_edge:                                      ; preds = %2
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 624
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !16
  br label %14

8:                                                ; preds = %2
  %.not = icmp eq i64 %4, 0
  %9 = shl i64 %4, 1
  %spec.select = select i1 %.not, i64 8, i64 %9
  store i64 %spec.select, ptr %5, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 624
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = shl i64 %spec.select, 2
  %13 = tail call ptr @realloc(ptr noundef %11, i64 noundef %12) #2
  store ptr %13, ptr %10, align 8, !tbaa !16
  %.pre14 = load i64, ptr %3, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %._crit_edge, %8
  %15 = phi i64 [ %4, %._crit_edge ], [ %.pre14, %8 ]
  %16 = phi ptr [ %.pre, %._crit_edge ], [ %13, %8 ]
  %17 = add i64 %15, 1
  store i64 %17, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds i32, ptr %16, i64 %15
  store i32 %1, ptr %18, align 4, !tbaa !17
  %19 = tail call zeroext i1 @ircode_register_istemp(ptr noundef nonnull %0, i32 noundef %1)
  br i1 %19, label %20, label %24

20:                                               ; preds = %14
  %21 = getelementptr inbounds i8, ptr %0, i64 88
  %22 = load i32, ptr %21, align 8, !tbaa !18
  %23 = add i32 %22, 1
  store i32 %23, ptr %21, align 8, !tbaa !18
  br label %24

24:                                               ; preds = %20, %14
  ret i32 %1
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ircode_register_istemp(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, 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 #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(1) }

!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, !11, i64 608}
!6 = !{!"ircode_t", !7, i64 0, !10, i64 8, !10, i64 32, !10, i64 56, !12, i64 80, !12, i64 84, !12, i64 88, !13, i64 92, !14, i64 94, !8, i64 95, !8, i64 351, !10, i64 608, !10, i64 632}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 8, !7, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!6, !11, i64 616}
!16 = !{!6, !7, i64 624}
!17 = !{!12, !12, i64 0}
!18 = !{!6, !12, i64 88}


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