; LLVM IR from InductiveComputerScience/infracore :: drivers/screen-linux-x11 (screen-linux-x11)

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

%union._XEvent = type { [24 x i64] }
%struct.anon = type { ptr, ptr, i32, i32, i32, i32, ptr, i64, i64, i64, i32, ptr, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, i32, i64, i64, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, i32, ptr, i64, i64, i32, i32, ptr, ptr, i32, ptr }
%struct.Screen = type { ptr, ptr, i64, i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, i64, i64, i64, i32, i32, i32, i32, i64 }

@.str = external hidden unnamed_addr constant [19 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_ximage(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %union._XEvent, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 192, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %15 = call ptr @XOpenDisplay(ptr noundef null)
  store ptr %15, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %16 = load ptr, ptr %11, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.anon, ptr %16, i32 0, i32 35
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %11, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.anon, ptr %19, i32 0, i32 33
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct.Screen, ptr %18, i64 %22
  %24 = getelementptr inbounds %struct.Screen, ptr %23, i32 0, i32 14
  %25 = load i64, ptr %24, align 8, !tbaa !15
  %26 = trunc i64 %25 to i32
  store i32 %26, ptr %6, align 4, !tbaa !5
  %27 = load ptr, ptr %11, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.anon, ptr %27, i32 0, i32 35
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = load ptr, ptr %11, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.anon, ptr %30, i32 0, i32 33
  %32 = load i32, ptr %31, align 8, !tbaa !14
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.Screen, ptr %29, i64 %33
  %35 = getelementptr inbounds %struct.Screen, ptr %34, i32 0, i32 14
  %36 = load i64, ptr %35, align 8, !tbaa !15
  %37 = trunc i64 %36 to i32
  store i32 %37, ptr %7, align 4, !tbaa !5
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = load ptr, ptr %11, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.anon, ptr %39, i32 0, i32 35
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = load ptr, ptr %11, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.anon, ptr %42, i32 0, i32 33
  %44 = load i32, ptr %43, align 8, !tbaa !14
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.Screen, ptr %41, i64 %45
  %47 = getelementptr inbounds %struct.Screen, ptr %46, i32 0, i32 2
  %48 = load i64, ptr %47, align 8, !tbaa !17
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = call i64 @XCreateSimpleWindow(ptr noundef %38, i64 noundef %48, i32 noundef 0, i32 noundef 0, i32 noundef 640, i32 noundef 480, i32 noundef 0, i64 noundef %50, i64 noundef %52)
  store i64 %53, ptr %9, align 8, !tbaa !18
  %54 = load ptr, ptr %11, align 8, !tbaa !9
  %55 = load i64, ptr %9, align 8, !tbaa !18
  %56 = call i32 @XStoreName(ptr noundef %54, i64 noundef %55, ptr noundef @.str)
  %57 = load ptr, ptr %11, align 8, !tbaa !9
  %58 = load i64, ptr %9, align 8, !tbaa !18
  %59 = call ptr @XCreateGC(ptr noundef %57, i64 noundef %58, i64 noundef 0, ptr noundef null)
  store ptr %59, ptr %10, align 8, !tbaa !9
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.anon, ptr %60, i32 0, i32 35
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.Screen, ptr %62, i64 0
  %64 = getelementptr inbounds %struct.Screen, ptr %63, i32 0, i32 10
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  store ptr %65, ptr %12, align 8, !tbaa !9
  %66 = load ptr, ptr %11, align 8, !tbaa !9
  %67 = load i64, ptr %9, align 8, !tbaa !18
  %68 = call i32 @XMapWindow(ptr noundef %66, i64 noundef %67)
  %69 = load ptr, ptr %11, align 8, !tbaa !9
  %70 = call i32 @XFlush(ptr noundef %69)
  %71 = load ptr, ptr %11, align 8, !tbaa !9
  %72 = load ptr, ptr %12, align 8, !tbaa !9
  %73 = call ptr @create_ximage(ptr noundef %71, ptr noundef %72, i32 noundef 640, i32 noundef 480)
  store ptr %73, ptr %13, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %75, %2
  br label %75

75:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %76 = load ptr, ptr %11, align 8, !tbaa !9
  %77 = load i64, ptr %9, align 8, !tbaa !18
  %78 = load ptr, ptr %10, align 8, !tbaa !9
  %79 = load ptr, ptr %13, align 8, !tbaa !9
  %80 = call i32 @XPutImage(ptr noundef %76, i64 noundef %77, ptr noundef %78, ptr noundef %79, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 640, i32 noundef 480)
  store i32 %80, ptr %14, align 4, !tbaa !5
  %81 = load ptr, ptr %11, align 8, !tbaa !9
  %82 = call i32 @XSync(ptr noundef %81, i32 noundef 1)
  %83 = load ptr, ptr %11, align 8, !tbaa !9
  %84 = call i32 @XFlush(ptr noundef %83)
  %85 = call i32 @usleep(i32 noundef 160000)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %74
}

declare ptr @XOpenDisplay(ptr noundef) #2

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

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

declare ptr @XCreateGC(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

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

declare i32 @XFlush(ptr noundef) #2

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

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

declare i32 @usleep(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 232}
!12 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !10, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !6, i64 64, !10, i64 72, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !10, i64 104, !6, i64 112, !6, i64 116, !10, i64 120, !10, i64 128, !6, i64 136, !13, i64 144, !13, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !6, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !6, i64 224, !6, i64 228, !10, i64 232, !13, i64 240, !13, i64 248, !6, i64 256, !6, i64 260, !10, i64 264, !10, i64 272, !6, i64 280, !10, i64 288}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 224}
!15 = !{!16, !13, i64 96}
!16 = !{!"", !10, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !10, i64 48, !6, i64 56, !10, i64 64, !10, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !6, i64 104, !6, i64 108, !6, i64 112, !6, i64 116, !13, i64 120}
!17 = !{!16, !13, i64 16}
!18 = !{!13, !13, i64 0}
!19 = !{!16, !10, i64 64}


; 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 { ptr, ptr, i64, i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, i64, i64, i64, i32, i32, i32, i32, i64 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_ximage(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = tail call ptr @XOpenDisplay(ptr noundef null) #3
  %4 = getelementptr inbounds i8, ptr %3, i64 232
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 224
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds %struct.Screen, ptr %5, i64 %8
  %10 = getelementptr inbounds i8, ptr %9, i64 96
  %11 = load i64, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %9, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !15
  %sext = shl i64 %11, 32
  %14 = ashr exact i64 %sext, 32
  %15 = tail call i64 @XCreateSimpleWindow(ptr noundef %3, i64 noundef %13, i32 noundef 0, i32 noundef 0, i32 noundef 640, i32 noundef 480, i32 noundef 0, i64 noundef %14, i64 noundef %14) #3
  %16 = tail call i32 @XStoreName(ptr noundef %3, i64 noundef %15, ptr noundef nonnull @.str) #3
  %17 = tail call ptr @XCreateGC(ptr noundef %3, i64 noundef %15, i64 noundef 0, ptr noundef null) #3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 64
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = tail call i32 @XMapWindow(ptr noundef %3, i64 noundef %15) #3
  %22 = tail call i32 @XFlush(ptr noundef %3) #3
  %23 = tail call ptr @create_ximage(ptr noundef %3, ptr noundef %20, i32 noundef 640, i32 noundef 480)
  br label %24

24:                                               ; preds = %24, %2
  %25 = tail call i32 @XPutImage(ptr noundef %3, i64 noundef %15, ptr noundef %17, ptr noundef %23, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 640, i32 noundef 480) #3
  %26 = tail call i32 @XSync(ptr noundef %3, i32 noundef 1) #3
  %27 = tail call i32 @XFlush(ptr noundef %3) #3
  %28 = tail call i32 @usleep(i32 noundef 160000) #3
  br label %24
}

declare ptr @XOpenDisplay(ptr noundef) local_unnamed_addr #2

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

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

declare ptr @XCreateGC(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @XFlush(ptr noundef) local_unnamed_addr #2

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

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

declare i32 @usleep(i32 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 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 = { 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 232}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !10, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !7, i64 104, !10, i64 112, !10, i64 116, !7, i64 120, !7, i64 128, !10, i64 136, !11, i64 144, !11, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !10, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !10, i64 224, !10, i64 228, !7, i64 232, !11, i64 240, !11, i64 248, !10, i64 256, !10, i64 260, !7, i64 264, !7, i64 272, !10, i64 280, !7, i64 288}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !10, i64 224}
!13 = !{!14, !11, i64 96}
!14 = !{!"", !7, i64 0, !7, i64 8, !11, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 48, !10, i64 56, !7, i64 64, !7, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !11, i64 120}
!15 = !{!14, !11, i64 16}
!16 = !{!14, !7, i64 64}


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