; LLVM IR from ihucos/plash :: mounted (mounted_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 [58 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@constinit = external hidden constant [3 x ptr], align 8
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @mounted_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 [5 x ptr], align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 2
  br i1 %14, label %15, label %18

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

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

41:                                               ; preds = %18
  %42 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.5)
  br label %43

43:                                               ; preds = %41, %18
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %52

46:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %47 = call ptr (...) @pl_get_default_root_shell()
  store ptr %47, ptr %11, align 8, !tbaa !9
  %48 = load ptr, ptr %11, align 8, !tbaa !9
  %49 = load ptr, ptr %11, align 8, !tbaa !9
  %50 = call i32 (ptr, ptr, ...) @execlp(ptr noundef %48, ptr noundef %49, ptr noundef null) #6
  %51 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %71

52:                                               ; preds = %43
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = getelementptr inbounds ptr, ptr %53, i32 1
  store ptr %54, ptr %5, align 8, !tbaa !9
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = getelementptr inbounds ptr, ptr %55, i32 1
  store ptr %56, ptr %5, align 8, !tbaa !9
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %5, align 8, !tbaa !9
  %60 = call i32 @execvp(ptr noundef %58, ptr noundef %59) #6
  %61 = call ptr @__errno_location() #7
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = icmp eq i32 %62, 2
  br i1 %63, label %64, label %69

64:                                               ; preds = %52
  %65 = load ptr, ptr @stderr, align 8, !tbaa !9
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = load ptr, ptr %66, align 8, !tbaa !9
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.7, ptr noundef %67) #6
  store i32 127, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %72

69:                                               ; preds = %52
  %70 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.8)
  br label %71

71:                                               ; preds = %69, %46
  store i32 0, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %72

72:                                               ; preds = %71, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %73

73:                                               ; preds = %72, %15
  %74 = load i32, ptr %3, align 4
  ret i32 %74
}

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 void @pl_unshare_user(...) #1

declare void @pl_unshare_mount(...) #1

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) #3

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) #4

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

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

declare ptr @pl_get_default_root_shell(...) #1

; Function Attrs: nounwind
declare i32 @execlp(ptr noundef, ptr noundef, ...) #3

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

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"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 [58 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@constinit = external hidden local_unnamed_addr constant [3 x ptr], align 8
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 128) i32 @mounted_main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca [3 x ptr], align 8
  %5 = alloca [5 x ptr], align 8
  %6 = icmp slt i32 %0, 2
  br i1 %6, label %7, label %10

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

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

28:                                               ; preds = %10
  %29 = call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.5) #8
  br label %30

30:                                               ; preds = %28, %10
  %31 = icmp eq ptr %14, null
  br i1 %31, label %32, label %36

32:                                               ; preds = %30
  %33 = call ptr (...) @pl_get_default_root_shell() #8
  %34 = call i32 (ptr, ptr, ...) @execlp(ptr noundef %33, ptr noundef %33, ptr noundef null) #8
  %35 = call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.6) #8
  br label %48

36:                                               ; preds = %30
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = call i32 @execvp(ptr noundef %37, ptr noundef nonnull %13) #8
  %39 = tail call ptr @__errno_location() #9
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = icmp eq i32 %40, 2
  br i1 %41, label %42, label %46

42:                                               ; preds = %36
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.7, ptr noundef %44) #10
  br label %48

46:                                               ; preds = %36
  %47 = call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.8) #8
  br label %48

48:                                               ; preds = %32, %46, %42
  %.0 = phi i32 [ 127, %42 ], [ 0, %46 ], [ 0, %32 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  br label %49

49:                                               ; preds = %48, %7
  %.1 = phi i32 [ 1, %7 ], [ %.0, %48 ]
  ret i32 %.1
}

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

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

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

declare void @pl_unshare_mount(...) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #4

declare ptr @pl_firstline(ptr noundef) local_unnamed_addr #3

declare ptr @pl_check_output(ptr noundef) local_unnamed_addr #3

; 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: nounwind
declare i32 @chdir(ptr noundef) local_unnamed_addr #4

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

declare ptr @pl_get_default_root_shell(...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare i32 @execlp(ptr noundef, ptr noundef, ...) 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) #2

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { 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 #7 = { cold }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
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 = !{i64 0, i64 24, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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