; LLVM IR from Softmotions/iowow :: src/fs (iwfs)

; 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 [65 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @iwfs_init() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %5 = call i64 @iwfs_file_init()
  store i64 %5, ptr %2, align 8, !tbaa !5
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %7 = icmp ne i64 %6, 0
  br i1 %7, label %8, label %16

8:                                                ; preds = %0
  %9 = load i64, ptr %1, align 8, !tbaa !5
  %10 = icmp ne i64 %9, 0
  br i1 %10, label %13, label %11

11:                                               ; preds = %8
  %12 = load i64, ptr %2, align 8, !tbaa !5
  store i64 %12, ptr %1, align 8, !tbaa !5
  br label %15

13:                                               ; preds = %8
  %14 = load i64, ptr %2, align 8, !tbaa !5
  call void @iwlog3(i32 noundef 0, i64 noundef %14, ptr noundef @.str, i32 noundef 33, ptr noundef @.str.1)
  br label %15

15:                                               ; preds = %13, %11
  br label %16

16:                                               ; preds = %15, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %17 = call i64 @iwfs_exfile_init()
  store i64 %17, ptr %3, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %28

20:                                               ; preds = %16
  %21 = load i64, ptr %1, align 8, !tbaa !5
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %25, label %23

23:                                               ; preds = %20
  %24 = load i64, ptr %3, align 8, !tbaa !5
  store i64 %24, ptr %1, align 8, !tbaa !5
  br label %27

25:                                               ; preds = %20
  %26 = load i64, ptr %3, align 8, !tbaa !5
  call void @iwlog3(i32 noundef 0, i64 noundef %26, ptr noundef @.str, i32 noundef 34, ptr noundef @.str.1)
  br label %27

27:                                               ; preds = %25, %23
  br label %28

28:                                               ; preds = %27, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %29 = call i64 @iwfs_fsmfile_init()
  store i64 %29, ptr %4, align 8, !tbaa !5
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %40

32:                                               ; preds = %28
  %33 = load i64, ptr %1, align 8, !tbaa !5
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %37, label %35

35:                                               ; preds = %32
  %36 = load i64, ptr %4, align 8, !tbaa !5
  store i64 %36, ptr %1, align 8, !tbaa !5
  br label %39

37:                                               ; preds = %32
  %38 = load i64, ptr %4, align 8, !tbaa !5
  call void @iwlog3(i32 noundef 0, i64 noundef %38, ptr noundef @.str, i32 noundef 35, ptr noundef @.str.1)
  br label %39

39:                                               ; preds = %37, %35
  br label %40

40:                                               ; preds = %39, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %41 = load i64, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret i64 %41
}

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

declare i64 @iwfs_file_init() #2

declare void @iwlog3(i32 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

declare i64 @iwfs_exfile_init() #2

declare i64 @iwfs_fsmfile_init() #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; 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 [65 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @iwfs_init() local_unnamed_addr #0 {
  %1 = tail call i64 @iwfs_file_init() #2
  %.not = icmp eq i64 %1, 0
  %2 = tail call i64 @iwfs_exfile_init() #2
  %.not16 = icmp eq i64 %2, 0
  %brmerge = select i1 %.not16, i1 true, i1 %.not
  %.mux = select i1 %.not16, i64 %1, i64 %2
  br i1 %brmerge, label %4, label %3

3:                                                ; preds = %0
  tail call void @iwlog3(i32 noundef 0, i64 noundef %2, ptr noundef nonnull @.str, i32 noundef 34, ptr noundef nonnull @.str.1) #2
  br label %4

4:                                                ; preds = %0, %3
  %.1 = phi i64 [ %1, %3 ], [ %.mux, %0 ]
  %5 = tail call i64 @iwfs_fsmfile_init() #2
  %.not18 = icmp eq i64 %5, 0
  br i1 %.not18, label %8, label %6

6:                                                ; preds = %4
  %.not19 = icmp eq i64 %.1, 0
  br i1 %.not19, label %8, label %7

7:                                                ; preds = %6
  tail call void @iwlog3(i32 noundef 0, i64 noundef %5, ptr noundef nonnull @.str, i32 noundef 35, ptr noundef nonnull @.str.1) #2
  br label %8

8:                                                ; preds = %6, %7, %4
  %.2 = phi i64 [ %.1, %7 ], [ %.1, %4 ], [ %5, %6 ]
  ret i64 %.2
}

declare i64 @iwfs_file_init() local_unnamed_addr #1

declare void @iwlog3(i32 noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i64 @iwfs_exfile_init() local_unnamed_addr #1

declare i64 @iwfs_fsmfile_init() 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 = { "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 }

!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,SROAPass,SimplifyCFGPass,TailCallElimPass