; LLVM IR from csviragh/robotsim :: src/utilities (arenas)

; 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.arenas_t = type { [32 x %struct.arena_t], i32 }
%struct.arena_t = type { i32, [32 x i8], [128 x [3 x double]], i32 }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ParseArenaFile(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = zext i1 %2 to i8
  store i8 %8, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 99848, i1 false)
  %10 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %87

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.arenas_t, ptr %13, i32 0, i32 1
  store i32 2, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.arenas_t, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds [32 x %struct.arena_t], ptr %16, i64 0, i64 0
  %18 = getelementptr inbounds %struct.arena_t, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds [32 x i8], ptr %18, i64 0, i64 0
  %20 = call ptr @strcpy(ptr noundef %19, ptr noundef @.str) #5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.arenas_t, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds [32 x %struct.arena_t], ptr %22, i64 0, i64 0
  %24 = getelementptr inbounds %struct.arena_t, ptr %23, i32 0, i32 0
  store i32 0, ptr %24, align 8, !tbaa !16
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.arenas_t, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds [32 x %struct.arena_t], ptr %26, i64 0, i64 1
  %28 = getelementptr inbounds %struct.arena_t, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds [32 x i8], ptr %28, i64 0, i64 0
  %30 = call ptr @strcpy(ptr noundef %29, ptr noundef @.str.1) #5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.arenas_t, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [32 x %struct.arena_t], ptr %32, i64 0, i64 1
  %34 = getelementptr inbounds %struct.arena_t, ptr %33, i32 0, i32 0
  store i32 1, ptr %34, align 8, !tbaa !16
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.arenas_t, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds [32 x %struct.arena_t], ptr %36, i64 0, i64 1
  %38 = getelementptr inbounds %struct.arena_t, ptr %37, i32 0, i32 3
  store i32 4, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.arenas_t, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds [32 x %struct.arena_t], ptr %40, i64 0, i64 1
  %42 = getelementptr inbounds %struct.arena_t, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds [128 x [3 x double]], ptr %42, i64 0, i64 0
  %44 = getelementptr inbounds [3 x double], ptr %43, i64 0, i64 0
  store double -1.000000e+00, ptr %44, align 8, !tbaa !19
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.arenas_t, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds [32 x %struct.arena_t], ptr %46, i64 0, i64 1
  %48 = getelementptr inbounds %struct.arena_t, ptr %47, i32 0, i32 2
  %49 = getelementptr inbounds [128 x [3 x double]], ptr %48, i64 0, i64 0
  %50 = getelementptr inbounds [3 x double], ptr %49, i64 0, i64 1
  store double -1.000000e+00, ptr %50, align 8, !tbaa !19
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.arenas_t, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds [32 x %struct.arena_t], ptr %52, i64 0, i64 1
  %54 = getelementptr inbounds %struct.arena_t, ptr %53, i32 0, i32 2
  %55 = getelementptr inbounds [128 x [3 x double]], ptr %54, i64 0, i64 1
  %56 = getelementptr inbounds [3 x double], ptr %55, i64 0, i64 0
  store double -1.000000e+00, ptr %56, align 8, !tbaa !19
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.arenas_t, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [32 x %struct.arena_t], ptr %58, i64 0, i64 1
  %60 = getelementptr inbounds %struct.arena_t, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds [128 x [3 x double]], ptr %60, i64 0, i64 1
  %62 = getelementptr inbounds [3 x double], ptr %61, i64 0, i64 1
  store double 1.000000e+00, ptr %62, align 8, !tbaa !19
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.arenas_t, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds [32 x %struct.arena_t], ptr %64, i64 0, i64 1
  %66 = getelementptr inbounds %struct.arena_t, ptr %65, i32 0, i32 2
  %67 = getelementptr inbounds [128 x [3 x double]], ptr %66, i64 0, i64 2
  %68 = getelementptr inbounds [3 x double], ptr %67, i64 0, i64 0
  store double 1.000000e+00, ptr %68, align 8, !tbaa !19
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.arenas_t, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds [32 x %struct.arena_t], ptr %70, i64 0, i64 1
  %72 = getelementptr inbounds %struct.arena_t, ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds [128 x [3 x double]], ptr %72, i64 0, i64 2
  %74 = getelementptr inbounds [3 x double], ptr %73, i64 0, i64 1
  store double 1.000000e+00, ptr %74, align 8, !tbaa !19
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.arenas_t, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds [32 x %struct.arena_t], ptr %76, i64 0, i64 1
  %78 = getelementptr inbounds %struct.arena_t, ptr %77, i32 0, i32 2
  %79 = getelementptr inbounds [128 x [3 x double]], ptr %78, i64 0, i64 3
  %80 = getelementptr inbounds [3 x double], ptr %79, i64 0, i64 0
  store double 1.000000e+00, ptr %80, align 8, !tbaa !19
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.arenas_t, ptr %81, i32 0, i32 0
  %83 = getelementptr inbounds [32 x %struct.arena_t], ptr %82, i64 0, i64 1
  %84 = getelementptr inbounds %struct.arena_t, ptr %83, i32 0, i32 2
  %85 = getelementptr inbounds [128 x [3 x double]], ptr %84, i64 0, i64 3
  %86 = getelementptr inbounds [3 x double], ptr %85, i64 0, i64 1
  store double -1.000000e+00, ptr %86, align 8, !tbaa !19
  br label %87

87:                                               ; preds = %12, %3
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = call i32 @IniParse(ptr noundef %88, ptr noundef @ArenaCallback, ptr noundef %89)
  store i32 %90, ptr %7, align 4, !tbaa !21
  %91 = load i32, ptr %7, align 4, !tbaa !21
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %96

93:                                               ; preds = %87
  %94 = load i32, ptr %7, align 4, !tbaa !21
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %94)
  br label %96

96:                                               ; preds = %93, %87
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.arenas_t, ptr %97, i32 0, i32 1
  %99 = load i32, ptr %98, align 8, !tbaa !13
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %99)
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.arenas_t, ptr %101, i32 0, i32 1
  %103 = load i32, ptr %102, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 %103
}

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

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

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #3

declare i32 @IniParse(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @ArenaCallback(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !15, i64 99840}
!14 = !{!"", !7, i64 0, !15, i64 99840}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !15, i64 0}
!17 = !{!"", !15, i64 0, !7, i64 4, !7, i64 40, !15, i64 3112}
!18 = !{!17, !15, i64 3112}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{!15, !15, 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"

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ParseArenaFile(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(99848) %1, i8 0, i64 99848, i1 false)
  br i1 %2, label %4, label %16

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %1, i64 99840
  store i32 2, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str) #5
  store i32 0, ptr %1, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %1, i64 3120
  %9 = getelementptr inbounds i8, ptr %1, i64 3124
  %10 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str.1) #5
  store i32 1, ptr %8, align 8, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %1, i64 6232
  store i32 4, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %1, i64 3160
  store <2 x double> <double -1.000000e+00, double -1.000000e+00>, ptr %12, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %1, i64 3184
  store <2 x double> <double -1.000000e+00, double 1.000000e+00>, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %1, i64 3208
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %1, i64 3232
  store <2 x double> <double 1.000000e+00, double -1.000000e+00>, ptr %15, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %4, %3
  %17 = tail call i32 @IniParse(ptr noundef %0, ptr noundef nonnull @ArenaCallback, ptr noundef nonnull %1) #5
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %20, label %18

18:                                               ; preds = %16
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %17)
  br label %20

20:                                               ; preds = %18, %16
  %21 = getelementptr inbounds i8, ptr %1, i64 99840
  %22 = load i32, ptr %21, align 8, !tbaa !5
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %22)
  %24 = load i32, ptr %21, align 8, !tbaa !5
  ret i32 %24
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

declare i32 @IniParse(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @ArenaCallback(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { "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 = { nofree 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 #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, !9, i64 99840}
!6 = !{!"", !7, i64 0, !9, i64 99840}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!11, !9, i64 0}
!11 = !{!"", !9, i64 0, !7, i64 4, !7, i64 40, !9, i64 3112}
!12 = !{!11, !9, i64 3112}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass