; 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 }
%struct.code_r = type { i64, i64, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @ircode_create(i16 noundef zeroext %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i16, align 2
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i16 %0, ptr %3, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %7 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 656)
  store ptr %7, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %11, label %10

10:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %113

11:                                               ; preds = %1
  %12 = load ptr, ptr %4, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.ircode_t, ptr %12, i32 0, i32 4
  store i32 0, ptr %13, align 8, !tbaa !11
  %14 = load i16, ptr %3, align 2, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.ircode_t, ptr %15, i32 0, i32 7
  store i16 %14, ptr %16, align 4, !tbaa !17
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.ircode_t, ptr %17, i32 0, i32 6
  store i32 0, ptr %18, align 8, !tbaa !18
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.ircode_t, ptr %19, i32 0, i32 5
  store i32 0, ptr %20, align 4, !tbaa !19
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.ircode_t, ptr %21, i32 0, i32 8
  store i8 0, ptr %22, align 2, !tbaa !20
  %23 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 24)
  %24 = load ptr, ptr %4, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.ircode_t, ptr %24, i32 0, i32 0
  store ptr %23, ptr %25, align 8, !tbaa !21
  %26 = load ptr, ptr %4, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.ircode_t, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = icmp ne ptr %28, null
  br i1 %29, label %32, label %30

30:                                               ; preds = %11
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %31) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %113

32:                                               ; preds = %11
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.ircode_t, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = getelementptr inbounds %struct.code_r, ptr %35, i32 0, i32 1
  store i64 0, ptr %36, align 8, !tbaa !22
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.ircode_t, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !21
  %40 = getelementptr inbounds %struct.code_r, ptr %39, i32 0, i32 0
  store i64 0, ptr %40, align 8, !tbaa !23
  %41 = load ptr, ptr %4, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.ircode_t, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = getelementptr inbounds %struct.code_r, ptr %43, i32 0, i32 2
  store ptr null, ptr %44, align 8, !tbaa !24
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.ircode_t, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.uint32_r, ptr %46, i32 0, i32 1
  store i64 0, ptr %47, align 8, !tbaa !25
  %48 = load ptr, ptr %4, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.ircode_t, ptr %48, i32 0, i32 1
  %50 = getelementptr inbounds %struct.uint32_r, ptr %49, i32 0, i32 0
  store i64 0, ptr %50, align 8, !tbaa !26
  %51 = load ptr, ptr %4, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.ircode_t, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %struct.uint32_r, ptr %52, i32 0, i32 2
  store ptr null, ptr %53, align 8, !tbaa !27
  %54 = load ptr, ptr %4, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.ircode_t, ptr %54, i32 0, i32 2
  %56 = getelementptr inbounds %struct.uint32_r, ptr %55, i32 0, i32 1
  store i64 0, ptr %56, align 8, !tbaa !28
  %57 = load ptr, ptr %4, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.ircode_t, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds %struct.uint32_r, ptr %58, i32 0, i32 0
  store i64 0, ptr %59, align 8, !tbaa !29
  %60 = load ptr, ptr %4, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.ircode_t, ptr %60, i32 0, i32 2
  %62 = getelementptr inbounds %struct.uint32_r, ptr %61, i32 0, i32 2
  store ptr null, ptr %62, align 8, !tbaa !30
  %63 = load ptr, ptr %4, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.ircode_t, ptr %63, i32 0, i32 3
  %65 = getelementptr inbounds %struct.uint32_r, ptr %64, i32 0, i32 1
  store i64 0, ptr %65, align 8, !tbaa !31
  %66 = load ptr, ptr %4, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.ircode_t, ptr %66, i32 0, i32 3
  %68 = getelementptr inbounds %struct.uint32_r, ptr %67, i32 0, i32 0
  store i64 0, ptr %68, align 8, !tbaa !32
  %69 = load ptr, ptr %4, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.ircode_t, ptr %69, i32 0, i32 3
  %71 = getelementptr inbounds %struct.uint32_r, ptr %70, i32 0, i32 2
  store ptr null, ptr %71, align 8, !tbaa !33
  %72 = load ptr, ptr %4, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.ircode_t, ptr %72, i32 0, i32 11
  %74 = getelementptr inbounds %struct.uint32_r, ptr %73, i32 0, i32 1
  store i64 0, ptr %74, align 8, !tbaa !34
  %75 = load ptr, ptr %4, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.ircode_t, ptr %75, i32 0, i32 11
  %77 = getelementptr inbounds %struct.uint32_r, ptr %76, i32 0, i32 0
  store i64 0, ptr %77, align 8, !tbaa !35
  %78 = load ptr, ptr %4, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.ircode_t, ptr %78, i32 0, i32 11
  %80 = getelementptr inbounds %struct.uint32_r, ptr %79, i32 0, i32 2
  store ptr null, ptr %80, align 8, !tbaa !36
  %81 = load ptr, ptr %4, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.ircode_t, ptr %81, i32 0, i32 12
  %83 = getelementptr inbounds %struct.context_r, ptr %82, i32 0, i32 1
  store i64 0, ptr %83, align 8, !tbaa !37
  %84 = load ptr, ptr %4, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct.ircode_t, ptr %84, i32 0, i32 12
  %86 = getelementptr inbounds %struct.context_r, ptr %85, i32 0, i32 0
  store i64 0, ptr %86, align 8, !tbaa !38
  %87 = load ptr, ptr %4, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.ircode_t, ptr %87, i32 0, i32 12
  %89 = getelementptr inbounds %struct.context_r, ptr %88, i32 0, i32 2
  store ptr null, ptr %89, align 8, !tbaa !39
  %90 = load ptr, ptr %4, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.ircode_t, ptr %90, i32 0, i32 9
  %92 = getelementptr inbounds [256 x i8], ptr %91, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %92, i8 0, i64 256, i1 false)
  %93 = load ptr, ptr %4, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.ircode_t, ptr %93, i32 0, i32 9
  %95 = getelementptr inbounds [256 x i8], ptr %94, i64 0, i64 0
  store i8 1, ptr %95, align 1, !tbaa !40
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !41
  br label %96

96:                                               ; preds = %108, %32
  %97 = load i32, ptr %6, align 4, !tbaa !41
  %98 = load i16, ptr %3, align 2, !tbaa !5
  %99 = zext i16 %98 to i32
  %100 = icmp ult i32 %97, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %96
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %111

102:                                              ; preds = %96
  %103 = load ptr, ptr %4, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.ircode_t, ptr %103, i32 0, i32 9
  %105 = load i32, ptr %6, align 4, !tbaa !41
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds [256 x i8], ptr %104, i64 0, i64 %106
  store i8 1, ptr %107, align 1, !tbaa !40
  br label %108

108:                                              ; preds = %102
  %109 = load i32, ptr %6, align 4, !tbaa !41
  %110 = add i32 %109, 1
  store i32 %110, ptr %6, align 4, !tbaa !41
  br label %96, !llvm.loop !42

111:                                              ; preds = %101
  %112 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %112, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %113

113:                                              ; preds = %111, %30, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %114 = load ptr, ptr %2, align 8
  ret ptr %114
}

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

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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 = { "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 "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 = !{!"short", !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, !15, i64 80}
!12 = !{!"ircode_t", !10, i64 0, !13, i64 8, !13, i64 32, !13, i64 56, !15, i64 80, !15, i64 84, !15, i64 88, !6, i64 92, !16, i64 94, !7, i64 95, !7, i64 351, !13, i64 608, !13, i64 632}
!13 = !{!"", !14, i64 0, !14, i64 8, !10, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!12, !6, i64 92}
!18 = !{!12, !15, i64 88}
!19 = !{!12, !15, i64 84}
!20 = !{!12, !16, i64 94}
!21 = !{!12, !10, i64 0}
!22 = !{!13, !14, i64 8}
!23 = !{!13, !14, i64 0}
!24 = !{!13, !10, i64 16}
!25 = !{!12, !14, i64 16}
!26 = !{!12, !14, i64 8}
!27 = !{!12, !10, i64 24}
!28 = !{!12, !14, i64 40}
!29 = !{!12, !14, i64 32}
!30 = !{!12, !10, i64 48}
!31 = !{!12, !14, i64 64}
!32 = !{!12, !14, i64 56}
!33 = !{!12, !10, i64 72}
!34 = !{!12, !14, i64 616}
!35 = !{!12, !14, i64 608}
!36 = !{!12, !10, i64 624}
!37 = !{!12, !14, i64 640}
!38 = !{!12, !14, i64 632}
!39 = !{!12, !10, i64 648}
!40 = !{!16, !16, i64 0}
!41 = !{!15, !15, i64 0}
!42 = distinct !{!42, !43}
!43 = !{!"llvm.loop.mustprogress"}


; 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
define dso_local ptr @ircode_create(i16 noundef zeroext %0) local_unnamed_addr #0 {
  %2 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 656) #4
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %2, i64 80
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 92
  store i16 %0, ptr %5, align 4, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %2, i64 88
  store i32 0, ptr %6, align 8, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %2, i64 84
  store i32 0, ptr %7, align 4, !tbaa !17
  %8 = getelementptr inbounds i8, ptr %2, i64 94
  store i8 0, ptr %8, align 2, !tbaa !18
  %9 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 24) #4
  store ptr %9, ptr %2, align 8, !tbaa !19
  %.not39 = icmp eq ptr %9, null
  br i1 %.not39, label %10, label %11

10:                                               ; preds = %3
  tail call void @free(ptr noundef nonnull %2) #4
  br label %.loopexit

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %9, i8 0, i64 24, i1 false)
  %13 = getelementptr inbounds i8, ptr %2, i64 608
  %14 = getelementptr inbounds i8, ptr %2, i64 95
  %15 = getelementptr inbounds i8, ptr %2, i64 96
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(256) %15, i8 0, i64 255, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %12, i8 0, i64 72, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %13, i8 0, i64 48, i1 false)
  store i8 1, ptr %14, align 1, !tbaa !20
  %.not41 = icmp eq i16 %0, 0
  br i1 %.not41, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %11
  %16 = zext i16 %0 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %14, i8 1, i64 %16, i1 false), !tbaa !20
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.preheader, %11, %1, %10
  %.036 = phi ptr [ null, %10 ], [ null, %1 ], [ %2, %11 ], [ %2, %.lr.ph.preheader ]
  ret ptr %.036
}

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { "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 = { mustprogress nounwind willreturn allockind("free") 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !12, i64 80}
!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, !13, i64 92}
!16 = !{!6, !12, i64 88}
!17 = !{!6, !12, i64 84}
!18 = !{!6, !14, i64 94}
!19 = !{!6, !7, i64 0}
!20 = !{!14, !14, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass