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

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

@scr = external global %struct.Screen, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @createwindow_rgba(ptr noundef %0, i64 %1, i64 %2, ptr noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca %struct.Rectangle, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.XSetWindowAttributes, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.XSetWindowAttributes, align 8
  %14 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  store i64 %1, ptr %14, align 4
  %15 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  store i64 %2, ptr %15, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  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 112, ptr %11) #5
  %16 = load ptr, ptr getelementptr inbounds (%struct.Screen, ptr @scr, i32 0, i32 6), align 8, !tbaa !11
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %28

18:                                               ; preds = %5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load i32, ptr getelementptr inbounds (%struct.Screen, ptr @scr, i32 0, i32 8), align 8, !tbaa !19
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %24 = load i64, ptr %23, align 4
  %25 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %26 = load i64, ptr %25, align 4
  %27 = call ptr @createwindow(ptr noundef %19, i64 %24, i64 %26, i32 noundef %20, i32 noundef 1, ptr noundef %21, i32 noundef %22)
  store ptr %27, ptr %6, align 8
  store i32 1, ptr %12, align 4
  br label %65

28:                                               ; preds = %5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %33

31:                                               ; preds = %28
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %32, i64 112, i1 false), !tbaa.struct !20
  br label %49

33:                                               ; preds = %28
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 112, i1 false)
  %34 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 0
  %35 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 1
  %36 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 2
  %37 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 3
  %38 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 4
  %39 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 5
  %40 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 6
  %41 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 7
  %42 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 8
  %43 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 9
  %44 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 10
  %45 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 11
  %46 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 12
  %47 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 13
  %48 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %13, i32 0, i32 14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %13, i64 112, i1 false), !tbaa.struct !20
  br label %49

49:                                               ; preds = %33, %31
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = or i64 %51, 8200
  %53 = trunc i64 %52 to i32
  store i32 %53, ptr %10, align 4, !tbaa !9
  %54 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %11, i32 0, i32 3
  store i64 0, ptr %54, align 8, !tbaa !22
  %55 = load i64, ptr getelementptr inbounds (%struct.Screen, ptr @scr, i32 0, i32 4), align 8, !tbaa !24
  %56 = getelementptr inbounds %struct.XSetWindowAttributes, ptr %11, i32 0, i32 13
  store i64 %55, ptr %56, align 8, !tbaa !25
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load ptr, ptr getelementptr inbounds (%struct.Screen, ptr @scr, i32 0, i32 6), align 8, !tbaa !11
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %61 = load i64, ptr %60, align 4
  %62 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %63 = load i64, ptr %62, align 4
  %64 = call ptr @createwindow_visual(ptr noundef %57, i64 %61, i64 %63, i32 noundef 32, ptr noundef %58, i32 noundef 1, ptr noundef %11, i32 noundef %59)
  store ptr %64, ptr %6, align 8
  store i32 1, ptr %12, align 4
  br label %65

65:                                               ; preds = %49, %18
  call void @llvm.lifetime.end.p0(i64 112, ptr %11) #5
  %66 = load ptr, ptr %6, align 8
  ret ptr %66
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !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 232}
!12 = !{!"Screen", !10, i64 0, !13, i64 8, !6, i64 200, !14, i64 208, !14, i64 216, !6, i64 224, !6, i64 232, !15, i64 240, !10, i64 256, !10, i64 260, !6, i64 264}
!13 = !{!"Window", !10, i64 0, !14, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !6, i64 48, !15, i64 56, !10, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !17, i64 128, !14, i64 152, !6, i64 160, !6, i64 168, !18, i64 176, !10, i64 180, !10, i64 184}
!14 = !{!"long", !7, i64 0}
!15 = !{!"Rectangle", !16, i64 0, !16, i64 8}
!16 = !{!"Point", !10, i64 0, !10, i64 4}
!17 = !{!"Ewmh", !14, i64 0, !14, i64 8, !14, i64 16}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!12, !10, i64 256}
!20 = !{i64 0, i64 8, !21, i64 8, i64 8, !21, i64 16, i64 8, !21, i64 24, i64 8, !21, i64 32, i64 4, !9, i64 36, i64 4, !9, i64 40, i64 4, !9, i64 48, i64 8, !21, i64 56, i64 8, !21, i64 64, i64 4, !9, i64 72, i64 8, !21, i64 80, i64 8, !21, i64 88, i64 4, !9, i64 96, i64 8, !21, i64 104, i64 8, !21}
!21 = !{!14, !14, i64 0}
!22 = !{!23, !14, i64 24}
!23 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !14, i64 48, !14, i64 56, !10, i64 64, !14, i64 72, !14, i64 80, !10, i64 88, !14, i64 96, !14, i64 104}
!24 = !{!12, !14, i64 216}
!25 = !{!23, !14, i64 96}


; 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"

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

@scr = external local_unnamed_addr global %struct.Screen, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @createwindow_rgba(ptr noundef %0, i64 %1, i64 %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.XSetWindowAttributes, align 8
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %6) #5
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @scr, i64 232), align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %12

9:                                                ; preds = %5
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @scr, i64 256), align 8, !tbaa !17
  %11 = tail call ptr @createwindow(ptr noundef %0, i64 %1, i64 %2, i32 noundef %10, i32 noundef 1, ptr noundef %3, i32 noundef %4) #5
  br label %21

12:                                               ; preds = %5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %14, label %13

13:                                               ; preds = %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %6, ptr noundef nonnull align 8 dereferenceable(112) %3, i64 112, i1 false), !tbaa.struct !18
  br label %15

14:                                               ; preds = %12
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %6, i8 0, i64 112, i1 false)
  br label %15

15:                                               ; preds = %14, %13
  %16 = or i32 %4, 8200
  %17 = getelementptr inbounds i8, ptr %6, i64 24
  store i64 0, ptr %17, align 8, !tbaa !21
  %18 = load i64, ptr getelementptr inbounds (i8, ptr @scr, i64 216), align 8, !tbaa !23
  %19 = getelementptr inbounds i8, ptr %6, i64 96
  store i64 %18, ptr %19, align 8, !tbaa !24
  %20 = call ptr @createwindow_visual(ptr noundef %0, i64 %1, i64 %2, i32 noundef 32, ptr noundef nonnull %7, i32 noundef 1, ptr noundef nonnull %6, i32 noundef %16) #5
  br label %21

21:                                               ; preds = %15, %9
  %.0 = phi ptr [ %11, %9 ], [ %20, %15 ]
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %6) #5
  ret ptr %.0
}

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

declare ptr @createwindow(ptr noundef, i64, i64, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare ptr @createwindow_visual(ptr noundef, i64, i64, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 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) #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 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !12, i64 232}
!6 = !{!"Screen", !7, i64 0, !10, i64 8, !12, i64 200, !11, i64 208, !11, i64 216, !12, i64 224, !12, i64 232, !13, i64 240, !7, i64 256, !7, i64 260, !12, i64 264}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"Window", !7, i64 0, !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !11, i64 40, !12, i64 48, !13, i64 56, !7, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !15, i64 128, !11, i64 152, !12, i64 160, !12, i64 168, !16, i64 176, !7, i64 180, !7, i64 184}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"Rectangle", !14, i64 0, !14, i64 8}
!14 = !{!"Point", !7, i64 0, !7, i64 4}
!15 = !{!"Ewmh", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!6, !7, i64 256}
!18 = !{i64 0, i64 8, !19, i64 8, i64 8, !19, i64 16, i64 8, !19, i64 24, i64 8, !19, i64 32, i64 4, !20, i64 36, i64 4, !20, i64 40, i64 4, !20, i64 48, i64 8, !19, i64 56, i64 8, !19, i64 64, i64 4, !20, i64 72, i64 8, !19, i64 80, i64 8, !19, i64 88, i64 4, !20, i64 96, i64 8, !19, i64 104, i64 8, !19}
!19 = !{!11, !11, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !11, i64 24}
!22 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !11, i64 48, !11, i64 56, !7, i64 64, !11, i64 72, !11, i64 80, !7, i64 88, !11, i64 96, !11, i64 104}
!23 = !{!6, !11, i64 216}
!24 = !{!22, !11, i64 96}


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