; LLVM IR from ihucos/plash :: push:dir (push_dir_main)

; 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"

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@constinit = external hidden constant [3 x ptr], align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @push_dir_main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [3 x ptr], align 8
  %10 = alloca [8 x ptr], align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp ne i32 %11, 3
  br i1 %12, label %13, label %16

13:                                               ; preds = %2
  %14 = load ptr, ptr @stderr, align 8, !tbaa !9
  %15 = call i32 @fputs(ptr noundef @.str, ptr noundef %14)
  store i32 1, ptr %3, align 4
  br label %47

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = getelementptr inbounds ptr, ptr %17, i64 1
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds ptr, ptr %20, i64 2
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  store ptr %22, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 @constinit, i64 24, i1 false), !tbaa.struct !11
  %23 = getelementptr inbounds [3 x ptr], ptr %9, i64 0, i64 0
  %24 = call ptr @pl_check_output(ptr noundef %23)
  %25 = call ptr @pl_firstline(ptr noundef %24)
  store ptr %25, ptr %8, align 8, !tbaa !9
  call void (...) @pl_unshare_user()
  store ptr @.str.1, ptr %10, align 8, !tbaa !9
  %26 = getelementptr inbounds ptr, ptr %10, i64 1
  store ptr @.str.3, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds ptr, ptr %10, i64 2
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %28, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds ptr, ptr %10, i64 3
  store ptr @.str.4, ptr %29, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %10, i64 4
  store ptr @.str.5, ptr %30, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %10, i64 5
  store ptr @.str.6, ptr %31, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %10, i64 6
  %33 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %33, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %10, i64 7
  store ptr null, ptr %34, align 8, !tbaa !9
  %35 = getelementptr inbounds [8 x ptr], ptr %10, i64 0, i64 0
  %36 = call ptr @pl_check_output(ptr noundef %35)
  %37 = call ptr @pl_firstline(ptr noundef %36)
  %38 = load ptr, ptr %8, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = call i32 @rename(ptr noundef %38, ptr noundef %39) #5
  %41 = icmp eq i32 %40, -1
  br i1 %41, label %42, label %46

42:                                               ; preds = %16
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.7, ptr noundef %43, ptr noundef %44)
  br label %46

46:                                               ; preds = %42, %16
  store i32 0, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %47

47:                                               ; preds = %46, %13
  %48 = load i32, ptr %3, align 4
  ret i32 %48
}

declare i32 @fputs(ptr noundef, ptr noundef) #1

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

declare ptr @pl_firstline(ptr noundef) #1

declare ptr @pl_check_output(ptr noundef) #1

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

declare void @pl_unshare_user(...) #1

; Function Attrs: nounwind
declare i32 @rename(ptr noundef, ptr noundef) #4

declare i32 @pl_fatal(ptr noundef, ...) #1

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !6, i64 0}
!6 = !{!"int", !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 = !{i64 0, i64 24, !12}
!12 = !{!7, !7, 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 [32 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@constinit = external hidden local_unnamed_addr constant [3 x ptr], align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @push_dir_main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [3 x ptr], align 8
  %4 = alloca [8 x ptr], align 8
  %.not = icmp eq i32 %0, 3
  br i1 %.not, label %8, label %5

5:                                                ; preds = %2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 @fputs(ptr noundef nonnull @.str, ptr noundef %6) #4
  br label %28

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) @constinit, i64 24, i1 false), !tbaa.struct !9
  %13 = call ptr @pl_check_output(ptr noundef nonnull %3) #5
  %14 = call ptr @pl_firstline(ptr noundef %13) #5
  call void (...) @pl_unshare_user() #5
  store ptr @.str.1, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr @.str.3, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %10, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %4, i64 24
  store ptr @.str.4, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr @.str.5, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %4, i64 40
  store ptr @.str.6, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %4, i64 48
  store ptr %14, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %4, i64 56
  store ptr null, ptr %21, align 8, !tbaa !5
  %22 = call ptr @pl_check_output(ptr noundef nonnull %4) #5
  %23 = call ptr @pl_firstline(ptr noundef %22) #5
  %24 = call i32 @rename(ptr noundef %14, ptr noundef %12) #5
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %26, label %28

26:                                               ; preds = %8
  %27 = call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.7, ptr noundef %14, ptr noundef %12) #5
  br label %28

28:                                               ; preds = %8, %26, %5
  %.0 = phi i32 [ 1, %5 ], [ 0, %26 ], [ 0, %8 ]
  ret i32 %.0
}

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

declare ptr @pl_firstline(ptr noundef) local_unnamed_addr #2

declare ptr @pl_check_output(ptr noundef) local_unnamed_addr #2

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

declare void @pl_unshare_user(...) local_unnamed_addr #2

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

declare i32 @pl_fatal(ptr noundef, ...) local_unnamed_addr #2

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 = { 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 = { "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: readwrite) }
attributes #4 = { cold }
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 = !{i64 0, i64 24, !10}
!10 = !{!7, !7, i64 0}


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