; LLVM IR from Vishnuparammal/maze_runner :: src (maze)

; 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.Graph = type { i32, ptr }
%struct.AdjList = type { ptr, float, float, i32, [4 x float] }

@graph = external dso_local global ptr, align 8

; 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 void @updateGraph() #1 {
  %1 = alloca i32, align 4
  %2 = load ptr, ptr @graph, align 8, !tbaa !5
  %3 = getelementptr inbounds %struct.Graph, ptr %2, i32 0, i32 0
  %4 = load i32, ptr %3, align 8, !tbaa !9
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr %3, align 8, !tbaa !9
  %6 = load ptr, ptr @graph, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Graph, ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = load ptr, ptr @graph, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Graph, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = mul i64 %12, 40
  %14 = call ptr @realloc(ptr noundef %8, i64 noundef %13) #3
  %15 = load ptr, ptr @graph, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Graph, ptr %15, i32 0, i32 1
  store ptr %14, ptr %16, align 8, !tbaa !12
  %17 = load ptr, ptr @graph, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Graph, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = load ptr, ptr @graph, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Graph, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %struct.AdjList, ptr %19, i64 %24
  %26 = getelementptr inbounds %struct.AdjList, ptr %25, i32 0, i32 0
  store ptr null, ptr %26, align 8, !tbaa !13
  %27 = load ptr, ptr @graph, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Graph, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %30 = load ptr, ptr @graph, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Graph, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.AdjList, ptr %29, i64 %34
  %36 = getelementptr inbounds %struct.AdjList, ptr %35, i32 0, i32 1
  store float 0.000000e+00, ptr %36, align 8, !tbaa !16
  %37 = load ptr, ptr @graph, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Graph, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !12
  %40 = load ptr, ptr @graph, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Graph, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !9
  %43 = sub nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.AdjList, ptr %39, i64 %44
  %46 = getelementptr inbounds %struct.AdjList, ptr %45, i32 0, i32 2
  store float 0.000000e+00, ptr %46, align 4, !tbaa !17
  %47 = load ptr, ptr @graph, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Graph, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !12
  %50 = load ptr, ptr @graph, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Graph, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !9
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.AdjList, ptr %49, i64 %54
  %56 = getelementptr inbounds %struct.AdjList, ptr %55, i32 0, i32 3
  store i32 0, ptr %56, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !19
  br label %57

57:                                               ; preds = %75, %0
  %58 = load i32, ptr %1, align 4, !tbaa !19
  %59 = icmp slt i32 %58, 4
  br i1 %59, label %61, label %60

60:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %78

61:                                               ; preds = %57
  %62 = load ptr, ptr @graph, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Graph, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !12
  %65 = load ptr, ptr @graph, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Graph, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !9
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %struct.AdjList, ptr %64, i64 %69
  %71 = getelementptr inbounds %struct.AdjList, ptr %70, i32 0, i32 4
  %72 = load i32, ptr %1, align 4, !tbaa !19
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [4 x float], ptr %71, i64 0, i64 %73
  store float -1.000000e+00, ptr %74, align 4, !tbaa !20
  br label %75

75:                                               ; preds = %61
  %76 = load i32, ptr %1, align 4, !tbaa !19
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %1, align 4, !tbaa !19
  br label %57, !llvm.loop !21

78:                                               ; preds = %60
  ret void
}

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, 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(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 #3 = { nounwind allocsize(1) }
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, !11, i64 0}
!10 = !{!"Graph", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !6, i64 0}
!14 = !{!"AdjList", !6, i64 0, !15, i64 8, !15, i64 12, !11, i64 16, !7, i64 20}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{!14, !15, i64 12}
!18 = !{!14, !11, i64 16}
!19 = !{!11, !11, i64 0}
!20 = !{!15, !15, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

%struct.AdjList = type { ptr, float, float, i32, [4 x float] }

@graph = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind willreturn uwtable
define dso_local void @updateGraph() local_unnamed_addr #0 {
  %1 = load ptr, ptr @graph, align 8, !tbaa !5
  %2 = load i32, ptr %1, align 8, !tbaa !9
  %3 = add nsw i32 %2, 1
  store i32 %3, ptr %1, align 8, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = sext i32 %3 to i64
  %7 = mul nsw i64 %6, 40
  %8 = tail call ptr @realloc(ptr noundef %5, i64 noundef %7) #3
  %9 = load ptr, ptr @graph, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %8, ptr %10, align 8, !tbaa !12
  %11 = load i32, ptr %9, align 8, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr %struct.AdjList, ptr %8, i64 %12
  %14 = getelementptr i8, ptr %13, i64 -40
  %15 = getelementptr i8, ptr %13, i64 -20
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %14, i8 0, i64 20, i1 false)
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %15, align 4, !tbaa !13
  ret void
}

; 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 #1

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

attributes #0 = { mustprogress nounwind willreturn 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 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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, !11, i64 0}
!10 = !{!"Graph", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass