; LLVM IR from jingweizhanghuai/Morn :: src/ptc (morn_message)

; 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.MHandle = type { i32, i32, ptr, ptr }
%struct.HandleProcLock = type { i32, i32, i32, [256 x i8] }

@.str = external hidden unnamed_addr constant [78 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [13 x i8], align 1
@__FUNCTION__.m_ProcLockEnd = external hidden unnamed_addr constant [14 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [13 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 i64 @lseek(i32 noundef, i64 noundef, i32 noundef) #1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #2

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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #2

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #2

declare ptr @mMornObject(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @endProcLock(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @m_ProcLockEnd(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store ptr @.str.26, ptr %2, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %12, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = call ptr @mMornObject(ptr noundef %14, i32 noundef -1)
  %16 = call ptr @GetHandle(ptr noundef %15, i32 noundef 268, i32 noundef 69658724, ptr noundef @endProcLock)
  store ptr %16, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.MHandle, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %4, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.MHandle, ptr %21, i32 0, i32 1
  %23 = load volatile i32, ptr %22, align 4, !tbaa !12
  %24 = icmp eq i32 %23, 0
  %25 = zext i1 %24 to i32
  store i32 %25, ptr %5, align 4, !tbaa !13
  %26 = load i32, ptr %5, align 4, !tbaa !13
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %20
  %29 = load i32, ptr %5, align 4, !tbaa !13
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %29, i32 noundef -1, ptr noundef @.str, i32 noundef 851, ptr noundef @__FUNCTION__.m_ProcLockEnd, ptr noundef @.str.27, ptr noundef %30)
  br label %31

31:                                               ; preds = %28, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.HandleProcLock, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !14
  %38 = icmp ne i32 %37, 1
  %39 = zext i1 %38 to i32
  store i32 %39, ptr %6, align 4, !tbaa !13
  %40 = load i32, ptr %6, align 4, !tbaa !13
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %34
  %43 = load i32, ptr %6, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %43, i32 noundef -1, ptr noundef @.str, i32 noundef 852, ptr noundef @__FUNCTION__.m_ProcLockEnd, ptr noundef @.str.28)
  br label %44

44:                                               ; preds = %42, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.HandleProcLock, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !16
  %52 = call i64 @lseek(i32 noundef %51, i64 noundef 0, i32 noundef 0) #4
  %53 = icmp ne i64 %52, 0
  %54 = zext i1 %53 to i32
  store i32 %54, ptr %8, align 4, !tbaa !13
  %55 = load i32, ptr %8, align 4, !tbaa !13
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %48
  %58 = load i32, ptr %8, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %58, i32 noundef -1, ptr noundef @.str, i32 noundef 855, ptr noundef @__FUNCTION__.m_ProcLockEnd, ptr noundef @.str.1)
  br label %59

59:                                               ; preds = %57, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.HandleProcLock, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !16
  %66 = call i64 @write(i32 noundef %65, ptr noundef %7, i64 noundef 4)
  %67 = icmp ne i64 %66, 4
  %68 = zext i1 %67 to i32
  store i32 %68, ptr %9, align 4, !tbaa !13
  %69 = load i32, ptr %9, align 4, !tbaa !13
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %62
  %72 = load i32, ptr %9, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %72, i32 noundef -1, ptr noundef @.str, i32 noundef 855, ptr noundef @__FUNCTION__.m_ProcLockEnd, ptr noundef @.str.3)
  br label %73

73:                                               ; preds = %71, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.HandleProcLock, ptr %78, i32 0, i32 1
  store i32 0, ptr %79, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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 = { "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 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 #4 = { 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, !6, i64 16}
!10 = !{!"MHandle", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !11, i64 4}
!15 = !{!"HandleProcLock", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12}
!16 = !{!15, !11, i64 8}


; 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 [78 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [13 x i8], align 1
@__FUNCTION__.m_ProcLockEnd = external hidden unnamed_addr constant [14 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [13 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: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

; 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
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @mMornObject(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @endProcLock(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @m_ProcLockEnd(ptr noundef %0) local_unnamed_addr #4 {
  %2 = alloca i32, align 4
  %3 = icmp eq ptr %0, null
  %spec.store.select = select i1 %3, ptr @.str.26, ptr %0
  %4 = tail call ptr @mMornObject(ptr noundef nonnull %spec.store.select, i32 noundef -1) #5
  %5 = tail call ptr @GetHandle(ptr noundef %4, i32 noundef 268, i32 noundef 69658724, ptr noundef nonnull @endProcLock) #5
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 4
  %9 = load volatile i32, ptr %8, align 4, !tbaa !11
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 851, ptr noundef nonnull @__FUNCTION__.m_ProcLockEnd, ptr noundef nonnull @.str.27, ptr noundef nonnull %spec.store.select) #5
  br label %12

12:                                               ; preds = %11, %1
  %13 = getelementptr inbounds i8, ptr %7, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %.not = icmp eq i32 %14, 1
  br i1 %.not, label %16, label %15

15:                                               ; preds = %12
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 852, ptr noundef nonnull @__FUNCTION__.m_ProcLockEnd, ptr noundef nonnull @.str.28) #5
  br label %16

16:                                               ; preds = %15, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %7, i64 8
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = tail call i64 @lseek(i32 noundef %18, i64 noundef 0, i32 noundef 0) #5
  %.not16 = icmp eq i64 %19, 0
  br i1 %.not16, label %21, label %20

20:                                               ; preds = %16
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 855, ptr noundef nonnull @__FUNCTION__.m_ProcLockEnd, ptr noundef nonnull @.str.1) #5
  br label %21

21:                                               ; preds = %20, %16
  %22 = load i32, ptr %17, align 4, !tbaa !15
  %23 = call i64 @write(i32 noundef %22, ptr noundef nonnull %2, i64 noundef 4) #5
  %.not17 = icmp eq i64 %23, 4
  br i1 %.not17, label %25, label %24

24:                                               ; preds = %21
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 855, ptr noundef nonnull @__FUNCTION__.m_ProcLockEnd, ptr noundef nonnull @.str.3) #5
  br label %25

25:                                               ; preds = %24, %21
  store i32 0, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  ret void
}

attributes #0 = { mustprogress 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 = { "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 = { nofree "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 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 #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, !10, i64 16}
!6 = !{!"MHandle", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!13, !7, i64 4}
!13 = !{!"HandleProcLock", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12}
!14 = !{!7, !7, i64 0}
!15 = !{!13, !7, i64 8}


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