; LLVM IR from 0intro/wmii :: lib/libstuff/x11/windows (unmapwin)

; 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.Window = type { i32, i64, ptr, ptr, ptr, i64, ptr, %struct.Rectangle, i32, ptr, ptr, ptr, ptr, ptr, ptr, %struct.Ewmh, i64, ptr, ptr, i8, i32, i32 }
%struct.Rectangle = type { %struct.Point, %struct.Point }
%struct.Point = type { i32, i32 }
%struct.Ewmh = type { i64, i64, i64 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.unmapwin = external hidden unnamed_addr constant [23 x i8], align 1
@display = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @unmapwin(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.Window, ptr %4, i32 0, i32 0
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %10

9:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 8, ptr noundef @__PRETTY_FUNCTION__.unmapwin) #3
  unreachable

10:                                               ; preds = %8
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Window, ptr %11, i32 0, i32 19
  %13 = load i8, ptr %12, align 8, !tbaa !17, !range !18, !noundef !19
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %27

15:                                               ; preds = %10
  %16 = load ptr, ptr @display, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Window, ptr %17, i32 0, i32 1
  %19 = load i64, ptr %18, align 8, !tbaa !20
  %20 = call i32 @XUnmapWindow(ptr noundef %16, i64 noundef %19)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Window, ptr %21, i32 0, i32 19
  store i8 0, ptr %22, align 8, !tbaa !17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Window, ptr %23, i32 0, i32 20
  %25 = load i32, ptr %24, align 4, !tbaa !21
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %24, align 4, !tbaa !21
  store i32 1, ptr %2, align 4
  br label %28

27:                                               ; preds = %10
  store i32 0, ptr %2, align 4
  br label %28

28:                                               ; preds = %27, %15
  %29 = load i32, ptr %2, align 4
  ret i32 %29
}

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

declare i32 @XUnmapWindow(ptr noundef, i64 noundef) #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 = { 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 #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 }

!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, !11, i64 0}
!10 = !{!"Window", !11, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !13, i64 56, !11, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !15, i64 128, !12, i64 152, !6, i64 160, !6, i64 168, !16, i64 176, !11, i64 180, !11, i64 184}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"Rectangle", !14, i64 0, !14, i64 8}
!14 = !{!"Point", !11, i64 0, !11, i64 4}
!15 = !{!"Ewmh", !12, i64 0, !12, i64 8, !12, i64 16}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!10, !16, i64 176}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!10, !12, i64 8}
!21 = !{!10, !11, i64 180}


; 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 [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.unmapwin = external hidden unnamed_addr constant [23 x i8], align 1
@display = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @unmapwin(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %5, label %4

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

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 176
  %7 = load i8, ptr %6, align 8, !tbaa !16, !range !17, !noundef !18
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %17

9:                                                ; preds = %5
  %10 = load ptr, ptr @display, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !20
  %13 = tail call i32 @XUnmapWindow(ptr noundef %10, i64 noundef %12) #4
  store i8 0, ptr %6, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 180
  %15 = load i32, ptr %14, align 4, !tbaa !21
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %14, align 4, !tbaa !21
  br label %17

17:                                               ; preds = %5, %9
  %.0 = phi i32 [ 1, %9 ], [ 0, %5 ]
  ret i32 %.0
}

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

declare i32 @XUnmapWindow(ptr noundef, i64 noundef) local_unnamed_addr #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 = { 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 #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 = !{!"Window", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !10, i64 40, !11, i64 48, !12, i64 56, !7, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !14, i64 128, !10, i64 152, !11, i64 160, !11, i64 168, !15, i64 176, !7, i64 180, !7, i64 184}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"Rectangle", !13, i64 0, !13, i64 8}
!13 = !{!"Point", !7, i64 0, !7, i64 4}
!14 = !{!"Ewmh", !10, i64 0, !10, i64 8, !10, i64 16}
!15 = !{!"_Bool", !8, i64 0}
!16 = !{!6, !15, i64 176}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!11, !11, i64 0}
!20 = !{!6, !10, i64 8}
!21 = !{!6, !7, i64 180}


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