; LLVM IR from wumo/vkg :: src/par/test (test_filecache)

; 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.6 = external hidden unnamed_addr constant [66 x i8], align 1
@_fileprefix = external hidden global [4096 x i8], align 16
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__.par_filecache_save = external hidden unnamed_addr constant [82 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 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 willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: nounwind
declare ptr @strcat(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) #0

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

declare i32 @fclose(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @_update_table(ptr noundef, i32 noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @par_filecache_save(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #5 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca [4096 x i8], align 16
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4096, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call i64 @strlen(ptr noundef %17) #7
  store i64 %18, ptr %12, align 8, !tbaa !11
  %19 = load i64, ptr %12, align 8, !tbaa !11
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  store i32 1, ptr %13, align 4
  br label %85

22:                                               ; preds = %5
  %23 = load i64, ptr %12, align 8, !tbaa !11
  %24 = call i64 @strlen(ptr noundef @_fileprefix) #7
  %25 = add i64 %23, %24
  %26 = icmp ult i64 %25, 4096
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  br label %29

28:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.6, i32 noundef 240, ptr noundef @__PRETTY_FUNCTION__.par_filecache_save) #8
  unreachable

29:                                               ; preds = %27
  %30 = getelementptr inbounds [4096 x i8], ptr %11, i64 0, i64 0
  %31 = call ptr @strcpy(ptr noundef %30, ptr noundef @_fileprefix) #6
  %32 = getelementptr inbounds [4096 x i8], ptr %11, i64 0, i64 0
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call ptr @strcat(ptr noundef %32, ptr noundef %33) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %35 = getelementptr inbounds [4096 x i8], ptr %11, i64 0, i64 0
  %36 = call noalias ptr @fopen(ptr noundef %35, ptr noundef @.str.12)
  store ptr %36, ptr %14, align 8, !tbaa !5
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %41

39:                                               ; preds = %29
  br i1 true, label %40, label %41

40:                                               ; preds = %39
  br label %42

41:                                               ; preds = %39, %29
  call void @__assert_fail(ptr noundef @.str.14, ptr noundef @.str.6, i32 noundef 244, ptr noundef @__PRETTY_FUNCTION__.par_filecache_save) #8
  unreachable

42:                                               ; preds = %40
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %45, label %51

45:                                               ; preds = %42
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = call i64 @fwrite(ptr noundef %46, i64 noundef 1, i64 noundef %48, ptr noundef %49)
  br label %51

51:                                               ; preds = %45, %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %77

54:                                               ; preds = %51
  %55 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %55, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = call i64 @fwrite(ptr noundef %56, i64 noundef 1, i64 noundef %58, ptr noundef %59)
  %61 = trunc i64 %60 to i32
  store i32 %61, ptr %16, align 4, !tbaa !9
  %62 = load i32, ptr %16, align 4, !tbaa !9
  %63 = load i32, ptr %15, align 4, !tbaa !9
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %65, label %73

65:                                               ; preds = %54
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = call i32 @fclose(ptr noundef %66)
  %68 = getelementptr inbounds [4096 x i8], ptr %11, i64 0, i64 0
  %69 = call i32 @remove(ptr noundef %68) #6
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i32, ptr %15, align 4, !tbaa !9
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, ptr noundef %70, i32 noundef %71)
  store i32 1, ptr %13, align 4
  br label %74

73:                                               ; preds = %54
  store i32 0, ptr %13, align 4
  br label %74

74:                                               ; preds = %73, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  %75 = load i32, ptr %13, align 4
  switch i32 %75, label %84 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %77

77:                                               ; preds = %76, %51
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  %79 = call i32 @fclose(ptr noundef %78)
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = load i32, ptr %15, align 4, !tbaa !9
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = add nsw i32 %81, %82
  call void @_update_table(ptr noundef %80, i32 noundef %83)
  store i32 0, ptr %13, align 4
  br label %84

84:                                               ; preds = %77, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %85

85:                                               ; preds = %84, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4096, ptr %11) #6
  %86 = load i32, ptr %13, align 4
  switch i32 %86, label %88 [
    i32 0, label %87
    i32 1, label %87
  ]

87:                                               ; preds = %85, %85
  ret void

88:                                               ; preds = %85
  unreachable
}

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

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

declare i32 @printf(ptr noundef, ...) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 = { noreturn 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 #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 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { noreturn 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, !12, i64 0}
!12 = !{!"long", !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.6 = external hidden unnamed_addr constant [66 x i8], align 1
@_fileprefix = external hidden global [4096 x i8], align 16
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__.par_filecache_save = external hidden unnamed_addr constant [82 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @_update_table(ptr noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local void @par_filecache_save(ptr noundef %0, ptr nocapture noundef %1, i32 noundef %2, ptr nocapture noundef %3, i32 noundef %4) local_unnamed_addr #5 {
  %6 = alloca [4096 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %6) #6
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %36, label %9

9:                                                ; preds = %5
  %10 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @_fileprefix) #7
  %11 = add i64 %10, %7
  %12 = icmp ult i64 %11, 4096
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.6, i32 noundef 240, ptr noundef nonnull @__PRETTY_FUNCTION__.par_filecache_save) #8
  unreachable

14:                                               ; preds = %9
  %15 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @_fileprefix) #6
  %16 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) %0) #6
  %17 = call noalias ptr @fopen(ptr noundef nonnull %6, ptr noundef nonnull @.str.12)
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %18, label %19

18:                                               ; preds = %14
  call void @__assert_fail(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.6, i32 noundef 244, ptr noundef nonnull @__PRETTY_FUNCTION__.par_filecache_save) #8
  unreachable

19:                                               ; preds = %14
  %20 = icmp sgt i32 %4, 0
  br i1 %20, label %21, label %24

21:                                               ; preds = %19
  %22 = zext nneg i32 %4 to i64
  %23 = call i64 @fwrite(ptr noundef %3, i64 noundef 1, i64 noundef %22, ptr noundef nonnull %17)
  br label %24

24:                                               ; preds = %21, %19
  %25 = icmp sgt i32 %2, 0
  br i1 %25, label %26, label %.critedge

26:                                               ; preds = %24
  %27 = zext nneg i32 %2 to i64
  %28 = call i64 @fwrite(ptr noundef %1, i64 noundef 1, i64 noundef %27, ptr noundef nonnull %17)
  %29 = trunc i64 %28 to i32
  %.not28 = icmp slt i32 %29, %2
  br i1 %.not28, label %30, label %.critedge

30:                                               ; preds = %26
  %31 = call i32 @fclose(ptr noundef nonnull %17)
  %32 = call i32 @remove(ptr noundef nonnull %6) #6
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef %0, i32 noundef %2)
  br label %36

.critedge:                                        ; preds = %26, %24
  %.023 = phi i32 [ 0, %24 ], [ %2, %26 ]
  %34 = call i32 @fclose(ptr noundef nonnull %17)
  %35 = add nsw i32 %.023, %4
  call void @_update_table(ptr noundef %0, i32 noundef %35)
  br label %36

36:                                               ; preds = %30, %.critedge, %5
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %6) #6
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

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

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

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


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