; LLVM IR from jspd-group/pegit :: src (project-init)

; 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.peg_env = type { i32, ptr, ptr, ptr, %struct.strbuf, ptr, i8 }
%struct.strbuf = type { i64, i64, ptr }
%struct.project_cache = type { %struct.project_details, %struct.timestamp }
%struct.project_details = type { %struct.strbuf, %struct.strbuf, %struct.strbuf, %struct.strbuf }
%struct.timestamp = type { i64, ptr }

@environment = external dso_local global %struct.peg_env, align 8
@stderr = external global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1
@__const.create_description_file.buf = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.13 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr 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: nounwind uwtable
define dso_local i32 @create_description_file(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.strbuf, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %7 = call noalias ptr @fopen(ptr noundef @.str.10, ptr noundef @.str.11)
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %16, label %10

10:                                               ; preds = %1
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = call ptr @__errno_location() #8
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = call ptr @strerror(i32 noundef %13) #7
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str.12, ptr noundef %14) #7
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %49

16:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @__const.create_description_file.buf, i64 24, i1 false)
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.project_cache, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.project_details, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds %struct.strbuf, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %16
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.project_cache, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds %struct.project_details, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr getelementptr inbounds (%struct.peg_env, ptr @environment, i32 0, i32 2), align 8, !tbaa !17
  call void @strbuf_addstr(ptr noundef %26, ptr noundef %27)
  br label %28

28:                                               ; preds = %23, %16
  call void @strbuf_addstr(ptr noundef %6, ptr noundef @.str.13)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.project_cache, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.project_details, ptr %30, i32 0, i32 0
  call void @strbuf_addbuf(ptr noundef %6, ptr noundef %31)
  call void @strbuf_addstr(ptr noundef %6, ptr noundef @.str.14)
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.project_cache, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.project_details, ptr %33, i32 0, i32 2
  call void @strbuf_addbuf(ptr noundef %6, ptr noundef %34)
  call void @strbuf_addstr(ptr noundef %6, ptr noundef @.str.15)
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.project_cache, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.project_details, ptr %36, i32 0, i32 1
  call void @strbuf_addbuf(ptr noundef %6, ptr noundef %37)
  call void @strbuf_addstr(ptr noundef %6, ptr noundef @.str.16)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.project_cache, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds %struct.timestamp, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = call ptr @asctime(ptr noundef %41) #7
  call void @strbuf_addstr(ptr noundef %6, ptr noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.strbuf, ptr %6, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !21
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.17, ptr noundef %45) #7
  call void @strbuf_release(ptr noundef %6)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i32 @fclose(ptr noundef %47)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #7
  br label %49

49:                                               ; preds = %28, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  %50 = load i32, ptr %2, align 4
  ret i32 %50
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #1

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #4

; 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) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addstr(ptr noundef, ptr noundef) #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addbuf(ptr noundef, ptr noundef) #6

; Function Attrs: nounwind
declare ptr @asctime(ptr noundef) #1

declare void @strbuf_release(ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 willreturn memory(none) "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { inlinehint 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }

!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, !15, i64 32}
!12 = !{!"project_cache", !13, i64 0, !16, i64 96}
!13 = !{!"project_details", !14, i64 0, !14, i64 24, !14, i64 48, !14, i64 72}
!14 = !{!"strbuf", !15, i64 0, !15, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"timestamp", !15, i64 0, !6, i64 8}
!17 = !{!18, !6, i64 16}
!18 = !{!"peg_env", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !6, i64 56, !19, i64 64}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{!12, !6, i64 104}
!21 = !{!14, !6, i64 16}


; 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.peg_env = type { i32, ptr, ptr, ptr, %struct.strbuf, ptr, i8 }
%struct.strbuf = type { i64, i64, ptr }

@environment = external dso_local local_unnamed_addr global %struct.peg_env, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1
@__const.create_description_file.buf = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.13 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress 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 range(i32 -1, 1) i32 @create_description_file(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.strbuf, align 8
  %3 = tail call noalias ptr @fopen(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.11)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %10

4:                                                ; preds = %1
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call ptr @__errno_location() #8
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = tail call ptr @strerror(i32 noundef %7) #9
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.12, ptr noundef %8) #10
  br label %26

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) @__const.create_description_file.buf, i64 24, i1 false)
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %10
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @environment, i64 16), align 8, !tbaa !17
  tail call void @strbuf_addstr(ptr noundef nonnull %11, ptr noundef %16)
  br label %17

17:                                               ; preds = %15, %10
  call void @strbuf_addstr(ptr noundef nonnull %2, ptr noundef nonnull @.str.13)
  call void @strbuf_addbuf(ptr noundef nonnull %2, ptr noundef nonnull %0)
  call void @strbuf_addstr(ptr noundef nonnull %2, ptr noundef nonnull @.str.14)
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  call void @strbuf_addbuf(ptr noundef nonnull %2, ptr noundef nonnull %18)
  call void @strbuf_addstr(ptr noundef nonnull %2, ptr noundef nonnull @.str.15)
  call void @strbuf_addbuf(ptr noundef nonnull %2, ptr noundef nonnull %11)
  call void @strbuf_addstr(ptr noundef nonnull %2, ptr noundef nonnull @.str.16)
  %19 = getelementptr inbounds i8, ptr %0, i64 104
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  %21 = call ptr @asctime(ptr noundef %20) #9
  call void @strbuf_addstr(ptr noundef nonnull %2, ptr noundef %21)
  %22 = getelementptr inbounds i8, ptr %2, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.17, ptr noundef %23) #9
  call void @strbuf_release(ptr noundef nonnull %2) #9
  %25 = call i32 @fclose(ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #9
  br label %26

26:                                               ; preds = %17, %4
  %.0 = phi i32 [ 0, %17 ], [ -1, %4 ]
  ret i32 %.0
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #4

; 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) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addstr(ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addbuf(ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind
declare ptr @asctime(ptr noundef) local_unnamed_addr #3

declare void @strbuf_release(ptr noundef) local_unnamed_addr #7

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { inlinehint 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 #7 = { "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 #8 = { nounwind willreturn memory(none) }
attributes #9 = { nounwind }
attributes #10 = { cold 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 = !{!"int", !7, i64 0}
!11 = !{!12, !15, i64 32}
!12 = !{!"project_cache", !13, i64 0, !16, i64 96}
!13 = !{!"project_details", !14, i64 0, !14, i64 24, !14, i64 48, !14, i64 72}
!14 = !{!"strbuf", !15, i64 0, !15, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"timestamp", !15, i64 0, !6, i64 8}
!17 = !{!18, !6, i64 16}
!18 = !{!"peg_env", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !6, i64 56, !19, i64 64}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{!12, !6, i64 104}
!21 = !{!14, !6, i64 16}


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