; LLVM IR from 0intro/wmii :: lib/libstuff/event (configurerequest)

; 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.XWindowChanges = type { i32, i32, i32, i32, i32, i64, i32 }
%struct.XConfigureRequestEvent = type { i32, i64, i32, ptr, i64, i64, i32, i32, i32, i32, i32, i64, i32, i64 }
%struct.Handlers = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@display = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @event_configurerequest(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.XWindowChanges, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %5, i32 0, i32 5
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = call ptr @findwin(i64 noundef %7)
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %13

10:                                               ; preds = %1
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_event_handle(ptr noundef %11, i64 noundef ptrtoint (ptr getelementptr inbounds (%struct.Handlers, ptr null, i32 0, i32 4) to i64), ptr noundef %12)
  br label %51

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %14, i32 0, i32 6
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 0
  store i32 %16, ptr %17, align 8, !tbaa !14
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %18, i32 0, i32 7
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %21 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 1
  store i32 %20, ptr %21, align 4, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %22, i32 0, i32 8
  %24 = load i32, ptr %23, align 8, !tbaa !18
  %25 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 2
  store i32 %24, ptr %25, align 8, !tbaa !19
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %26, i32 0, i32 9
  %28 = load i32, ptr %27, align 4, !tbaa !20
  %29 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 3
  store i32 %28, ptr %29, align 4, !tbaa !21
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %30, i32 0, i32 10
  %32 = load i32, ptr %31, align 8, !tbaa !22
  %33 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 4
  store i32 %32, ptr %33, align 8, !tbaa !23
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %34, i32 0, i32 11
  %36 = load i64, ptr %35, align 8, !tbaa !24
  %37 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 5
  store i64 %36, ptr %37, align 8, !tbaa !25
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %38, i32 0, i32 12
  %40 = load i32, ptr %39, align 8, !tbaa !26
  %41 = getelementptr inbounds %struct.XWindowChanges, ptr %3, i32 0, i32 6
  store i32 %40, ptr %41, align 8, !tbaa !27
  %42 = load ptr, ptr @display, align 8, !tbaa !5
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %43, i32 0, i32 5
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.XConfigureRequestEvent, ptr %46, i32 0, i32 13
  %48 = load i64, ptr %47, align 8, !tbaa !28
  %49 = trunc i64 %48 to i32
  %50 = call i32 @XConfigureWindow(ptr noundef %42, i64 noundef %45, i32 noundef %49, ptr noundef %3)
  br label %51

51:                                               ; preds = %13, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #3
  ret void
}

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

declare ptr @findwin(i64 noundef) #2

declare void @_event_handle(ptr noundef, i64 noundef, ptr noundef) #2

declare i32 @XConfigureWindow(ptr noundef, i64 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

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 40}
!10 = !{!"", !11, i64 0, !12, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !12, i64 72, !11, i64 80, !12, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, i64 48}
!14 = !{!15, !11, i64 0}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 24, !11, i64 32}
!16 = !{!10, !11, i64 52}
!17 = !{!15, !11, i64 4}
!18 = !{!10, !11, i64 56}
!19 = !{!15, !11, i64 8}
!20 = !{!10, !11, i64 60}
!21 = !{!15, !11, i64 12}
!22 = !{!10, !11, i64 64}
!23 = !{!15, !11, i64 16}
!24 = !{!10, !12, i64 72}
!25 = !{!15, !12, i64 24}
!26 = !{!10, !11, i64 80}
!27 = !{!15, !11, i64 32}
!28 = !{!10, !12, i64 88}


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

@display = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @event_configurerequest(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.XWindowChanges, align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = tail call ptr @findwin(i64 noundef %4) #3
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  tail call void @_event_handle(ptr noundef nonnull %5, i64 noundef 32, ptr noundef nonnull %0) #3
  br label %25

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load <4 x i32>, ptr %8, align 8, !tbaa !12
  store <4 x i32> %9, ptr %2, align 16, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %11, ptr %12, align 16, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  %14 = load i64, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %2, i64 24
  store i64 %14, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %0, i64 80
  %17 = load i32, ptr %16, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %2, i64 32
  store i32 %17, ptr %18, align 16, !tbaa !19
  %19 = load ptr, ptr @display, align 8, !tbaa !20
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 88
  %22 = load i64, ptr %21, align 8, !tbaa !21
  %23 = trunc i64 %22 to i32
  %24 = call i32 @XConfigureWindow(ptr noundef %19, i64 noundef %20, i32 noundef %23, ptr noundef nonnull %2) #3
  br label %25

25:                                               ; preds = %7, %6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #3
  ret void
}

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

declare ptr @findwin(i64 noundef) local_unnamed_addr #2

declare void @_event_handle(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @XConfigureWindow(ptr noundef, i64 noundef, i32 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) #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 = { 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 40}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !10, i64 32, !10, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !10, i64 72, !7, i64 80, !10, i64 88}
!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 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 64}
!14 = !{!15, !7, i64 16}
!15 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !7, i64 32}
!16 = !{!6, !10, i64 72}
!17 = !{!15, !10, i64 24}
!18 = !{!6, !7, i64 80}
!19 = !{!15, !7, i64 32}
!20 = !{!11, !11, i64 0}
!21 = !{!6, !10, i64 88}


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