; LLVM IR from clangen/musikcube :: src/3rdparty/win32_src/pdcurses (panel)

; 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.panel = type { ptr, i32, i32, i32, i32, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__.move_panel = external hidden unnamed_addr constant [34 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @_panel_is_linked(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @move_panel(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  br label %17

16:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 492, ptr noundef @__PRETTY_FUNCTION__.move_panel) #5
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %69

21:                                               ; preds = %17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call zeroext i1 @_panel_is_linked(ptr noundef %22)
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_override(ptr noundef %25, i32 noundef 0)
  br label %26

26:                                               ; preds = %24, %21
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.panel, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  store ptr %29, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = call i32 @mvwin(ptr noundef %30, i32 noundef %31, i32 noundef %32)
  store i32 %33, ptr %11, align 4, !tbaa !9
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp ne i32 %34, -1
  br i1 %35, label %36, label %63

36:                                               ; preds = %26
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call i32 @getbegy(ptr noundef %37)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.panel, ptr %39, i32 0, i32 1
  store i32 %38, ptr %40, align 8, !tbaa !13
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call i32 @getbegx(ptr noundef %41)
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.panel, ptr %43, i32 0, i32 3
  store i32 %42, ptr %44, align 8, !tbaa !14
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call i32 @getmaxy(ptr noundef %45)
  store i32 %46, ptr %9, align 4, !tbaa !9
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = call i32 @getmaxx(ptr noundef %47)
  store i32 %48, ptr %10, align 4, !tbaa !9
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.panel, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = add nsw i32 %51, %52
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.panel, ptr %54, i32 0, i32 2
  store i32 %53, ptr %55, align 4, !tbaa !15
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.panel, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = add nsw i32 %58, %59
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.panel, ptr %61, i32 0, i32 4
  store i32 %60, ptr %62, align 4, !tbaa !16
  br label %63

63:                                               ; preds = %36, %26
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = call zeroext i1 @_panel_is_linked(ptr noundef %64)
  br i1 %65, label %66, label %67

66:                                               ; preds = %63
  call void @_calculate_obscure()
  br label %67

67:                                               ; preds = %66, %63
  %68 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %68, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %69

69:                                               ; preds = %67, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %70 = load i32, ptr %4, align 4
  ret i32 %70
}

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

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

declare i32 @mvwin(ptr noundef, i32 noundef, i32 noundef) #3

declare i32 @getbegy(ptr noundef) #3

declare i32 @getbegx(ptr noundef) #3

declare i32 @getmaxy(ptr noundef) #3

declare i32 @getmaxx(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @_calculate_obscure() #1

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

attributes #0 = { 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 #1 = { 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 #2 = { 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 }
attributes #5 = { 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, !6, i64 0}
!12 = !{!"panel", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !10, i64 20}


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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @_panel_is_linked(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @move_panel(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 492, ptr noundef nonnull @__PRETTY_FUNCTION__.move_panel) #3
  unreachable

5:                                                ; preds = %3
  %6 = tail call zeroext i1 @_panel_is_linked(ptr noundef nonnull %0)
  br i1 %6, label %7, label %8

7:                                                ; preds = %5
  tail call void @_override(ptr noundef nonnull %0, i32 noundef 0)
  br label %8

8:                                                ; preds = %7, %5
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = tail call i32 @mvwin(ptr noundef %9, i32 noundef %1, i32 noundef %2) #4
  %.not24 = icmp eq i32 %10, -1
  br i1 %.not24, label %24, label %11

11:                                               ; preds = %8
  %12 = tail call i32 @getbegy(ptr noundef %9) #4
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %12, ptr %13, align 8, !tbaa !11
  %14 = tail call i32 @getbegx(ptr noundef %9) #4
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %14, ptr %15, align 8, !tbaa !12
  %16 = tail call i32 @getmaxy(ptr noundef %9) #4
  %17 = tail call i32 @getmaxx(ptr noundef %9) #4
  %18 = load i32, ptr %13, align 8, !tbaa !11
  %19 = add nsw i32 %18, %16
  %20 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %19, ptr %20, align 4, !tbaa !13
  %21 = load i32, ptr %15, align 8, !tbaa !12
  %22 = add nsw i32 %21, %17
  %23 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %22, ptr %23, align 4, !tbaa !14
  br label %24

24:                                               ; preds = %11, %8
  %25 = tail call zeroext i1 @_panel_is_linked(ptr noundef nonnull %0)
  br i1 %25, label %26, label %27

26:                                               ; preds = %24
  tail call void @_calculate_obscure()
  br label %27

27:                                               ; preds = %24, %26
  ret i32 %10
}

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

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

declare i32 @getbegy(ptr noundef) local_unnamed_addr #2

declare i32 @getbegx(ptr noundef) local_unnamed_addr #2

declare i32 @getmaxy(ptr noundef) local_unnamed_addr #2

declare i32 @getmaxx(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @_calculate_obscure() local_unnamed_addr #1

attributes #0 = { 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 #1 = { 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 #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 = { noreturn nounwind }
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, !7, i64 0}
!6 = !{!"panel", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 12}
!14 = !{!6, !10, i64 20}


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