; LLVM IR from google/latency-benchmark :: src/x11 (screenscraper)

; 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.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 }
%struct._XImage = type { i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, ptr, %struct.funcs }
%struct.funcs = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.screenshot = type { i32, i32, i32, ptr, i64, ptr }

@display = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__.take_screenshot = external hidden unnamed_addr constant [68 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @take_screenshot(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  %22 = load ptr, ptr @display, align 8, !tbaa !9
  %23 = icmp ne ptr %22, null
  br i1 %23, label %30, label %24

24:                                               ; preds = %4
  %25 = call ptr @XOpenDisplay(ptr noundef null)
  store ptr %25, ptr @display, align 8, !tbaa !9
  %26 = load ptr, ptr @display, align 8, !tbaa !9
  %27 = icmp ne ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store ptr null, ptr %5, align 8
  br label %183

29:                                               ; preds = %24
  br label %30

30:                                               ; preds = %29, %4
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = icmp ult i32 %31, 2147483647
  br i1 %32, label %33, label %35

33:                                               ; preds = %30
  %34 = load i32, ptr %8, align 4, !tbaa !5
  br label %36

35:                                               ; preds = %30
  br label %36

36:                                               ; preds = %35, %33
  %37 = phi i32 [ %34, %33 ], [ 2147483647, %35 ]
  store i32 %37, ptr %8, align 4, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = icmp ult i32 %38, 2147483647
  br i1 %39, label %40, label %42

40:                                               ; preds = %36
  %41 = load i32, ptr %9, align 4, !tbaa !5
  br label %43

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42, %40
  %44 = phi i32 [ %41, %40 ], [ 2147483647, %42 ]
  store i32 %44, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %45 = load ptr, ptr @display, align 8, !tbaa !9
  %46 = load ptr, ptr @display, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.anon, ptr %46, i32 0, i32 35
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.Screen, ptr %48, i64 0
  %50 = getelementptr inbounds %struct.Screen, ptr %49, i32 0, i32 2
  %51 = load i64, ptr %50, align 8, !tbaa !14
  %52 = call i32 @XGetGeometry(ptr noundef %45, i64 noundef %51, ptr noundef %16, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef %14, ptr noundef %15)
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %43
  br label %57

56:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 70, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

57:                                               ; preds = %55
  %58 = load i32, ptr %11, align 4, !tbaa !5
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %57
  br label %62

61:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 71, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

62:                                               ; preds = %60
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = load i32, ptr %12, align 4, !tbaa !5
  %65 = call i32 @clamp(i32 noundef %63, i32 noundef 0, i32 noundef %64)
  store i32 %65, ptr %6, align 4, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !5
  %68 = call i32 @clamp(i32 noundef %66, i32 noundef 0, i32 noundef %67)
  store i32 %68, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = load i32, ptr %12, align 4, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = sub i32 %70, %71
  %73 = call i32 @clamp(i32 noundef %69, i32 noundef 0, i32 noundef %72)
  store i32 %73, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %74 = load i32, ptr %9, align 4, !tbaa !5
  %75 = load i32, ptr %13, align 4, !tbaa !5
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = sub i32 %75, %76
  %78 = call i32 @clamp(i32 noundef %74, i32 noundef 0, i32 noundef %77)
  store i32 %78, ptr %18, align 4, !tbaa !5
  %79 = load i32, ptr %17, align 4, !tbaa !5
  %80 = icmp eq i32 %79, 0
  br i1 %80, label %84, label %81

81:                                               ; preds = %62
  %82 = load i32, ptr %18, align 4, !tbaa !5
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %81, %62
  call void (ptr, ...) @debug_log(ptr noundef @.str.3)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %182

85:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %86 = load ptr, ptr @display, align 8, !tbaa !9
  %87 = load ptr, ptr @display, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.anon, ptr %87, i32 0, i32 35
  %89 = load ptr, ptr %88, align 8, !tbaa !11
  %90 = getelementptr inbounds %struct.Screen, ptr %89, i64 0
  %91 = getelementptr inbounds %struct.Screen, ptr %90, i32 0, i32 2
  %92 = load i64, ptr %91, align 8, !tbaa !14
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = load i32, ptr %17, align 4, !tbaa !5
  %96 = load i32, ptr %18, align 4, !tbaa !5
  %97 = call ptr @XGetImage(ptr noundef %86, i64 noundef %92, i32 noundef %93, i32 noundef %94, i32 noundef %95, i32 noundef %96, i64 noundef -1, i32 noundef 2)
  store ptr %97, ptr %20, align 8, !tbaa !9
  %98 = load ptr, ptr %20, align 8, !tbaa !9
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %101

100:                                              ; preds = %85
  br label %102

101:                                              ; preds = %85
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 82, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

102:                                              ; preds = %100
  %103 = load ptr, ptr %20, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct._XImage, ptr %103, i32 0, i32 0
  %105 = load i32, ptr %104, align 8, !tbaa !16
  %106 = load i32, ptr %17, align 4, !tbaa !5
  %107 = icmp eq i32 %105, %106
  br i1 %107, label %108, label %109

108:                                              ; preds = %102
  br label %110

109:                                              ; preds = %102
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 83, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

110:                                              ; preds = %108
  %111 = load ptr, ptr %20, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct._XImage, ptr %111, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !19
  %114 = load i32, ptr %18, align 4, !tbaa !5
  %115 = icmp eq i32 %113, %114
  br i1 %115, label %116, label %117

116:                                              ; preds = %110
  br label %118

117:                                              ; preds = %110
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 84, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

118:                                              ; preds = %116
  %119 = load ptr, ptr %20, align 8, !tbaa !9
  %120 = getelementptr inbounds %struct._XImage, ptr %119, i32 0, i32 5
  %121 = load i32, ptr %120, align 8, !tbaa !20
  %122 = icmp eq i32 %121, 0
  br i1 %122, label %123, label %124

123:                                              ; preds = %118
  br label %125

124:                                              ; preds = %118
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 85, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

125:                                              ; preds = %123
  %126 = load ptr, ptr %20, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct._XImage, ptr %126, i32 0, i32 11
  %128 = load i32, ptr %127, align 8, !tbaa !21
  %129 = icmp eq i32 %128, 32
  br i1 %129, label %130, label %131

130:                                              ; preds = %125
  br label %132

131:                                              ; preds = %125
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 86, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

132:                                              ; preds = %130
  %133 = load ptr, ptr %20, align 8, !tbaa !9
  %134 = getelementptr inbounds %struct._XImage, ptr %133, i32 0, i32 12
  %135 = load i64, ptr %134, align 8, !tbaa !22
  %136 = icmp eq i64 %135, 16711680
  br i1 %136, label %137, label %138

137:                                              ; preds = %132
  br label %139

138:                                              ; preds = %132
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 87, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

139:                                              ; preds = %137
  %140 = load ptr, ptr %20, align 8, !tbaa !9
  %141 = getelementptr inbounds %struct._XImage, ptr %140, i32 0, i32 13
  %142 = load i64, ptr %141, align 8, !tbaa !23
  %143 = icmp eq i64 %142, 65280
  br i1 %143, label %144, label %145

144:                                              ; preds = %139
  br label %146

145:                                              ; preds = %139
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 88, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

146:                                              ; preds = %144
  %147 = load ptr, ptr %20, align 8, !tbaa !9
  %148 = getelementptr inbounds %struct._XImage, ptr %147, i32 0, i32 14
  %149 = load i64, ptr %148, align 8, !tbaa !24
  %150 = icmp eq i64 %149, 255
  br i1 %150, label %151, label %152

151:                                              ; preds = %146
  br label %153

152:                                              ; preds = %146
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 89, ptr noundef @__PRETTY_FUNCTION__.take_screenshot) #6
  unreachable

153:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %154 = call noalias ptr @malloc(i64 noundef 40) #7
  store ptr %154, ptr %21, align 8, !tbaa !9
  %155 = load ptr, ptr %20, align 8, !tbaa !9
  %156 = getelementptr inbounds %struct._XImage, ptr %155, i32 0, i32 0
  %157 = load i32, ptr %156, align 8, !tbaa !16
  %158 = load ptr, ptr %21, align 8, !tbaa !9
  %159 = getelementptr inbounds %struct.screenshot, ptr %158, i32 0, i32 0
  store i32 %157, ptr %159, align 8, !tbaa !25
  %160 = load ptr, ptr %20, align 8, !tbaa !9
  %161 = getelementptr inbounds %struct._XImage, ptr %160, i32 0, i32 1
  %162 = load i32, ptr %161, align 4, !tbaa !19
  %163 = load ptr, ptr %21, align 8, !tbaa !9
  %164 = getelementptr inbounds %struct.screenshot, ptr %163, i32 0, i32 1
  store i32 %162, ptr %164, align 4, !tbaa !27
  %165 = load ptr, ptr %20, align 8, !tbaa !9
  %166 = getelementptr inbounds %struct._XImage, ptr %165, i32 0, i32 10
  %167 = load i32, ptr %166, align 4, !tbaa !28
  %168 = load ptr, ptr %21, align 8, !tbaa !9
  %169 = getelementptr inbounds %struct.screenshot, ptr %168, i32 0, i32 2
  store i32 %167, ptr %169, align 8, !tbaa !29
  %170 = load ptr, ptr %20, align 8, !tbaa !9
  %171 = getelementptr inbounds %struct._XImage, ptr %170, i32 0, i32 4
  %172 = load ptr, ptr %171, align 8, !tbaa !30
  %173 = load ptr, ptr %21, align 8, !tbaa !9
  %174 = getelementptr inbounds %struct.screenshot, ptr %173, i32 0, i32 3
  store ptr %172, ptr %174, align 8, !tbaa !31
  %175 = call i64 @get_nanoseconds()
  %176 = load ptr, ptr %21, align 8, !tbaa !9
  %177 = getelementptr inbounds %struct.screenshot, ptr %176, i32 0, i32 4
  store i64 %175, ptr %177, align 8, !tbaa !32
  %178 = load ptr, ptr %20, align 8, !tbaa !9
  %179 = load ptr, ptr %21, align 8, !tbaa !9
  %180 = getelementptr inbounds %struct.screenshot, ptr %179, i32 0, i32 5
  store ptr %178, ptr %180, align 8, !tbaa !33
  %181 = load ptr, ptr %21, align 8, !tbaa !9
  store ptr %181, ptr %5, align 8
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  br label %182

182:                                              ; preds = %153, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %183

183:                                              ; preds = %182, %28
  %184 = load ptr, ptr %5, align 8
  ret ptr %184
}

declare ptr @XOpenDisplay(ptr noundef) #1

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

declare i32 @XGetGeometry(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @clamp(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @debug_log(ptr noundef, ...) #0

declare ptr @XGetImage(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @get_nanoseconds() #0

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 = { "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 = { 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 #4 = { nounwind allocsize(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 #5 = { nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!15, !13, i64 16}
!15 = !{!"", !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}
!16 = !{!17, !6, i64 0}
!17 = !{!"_XImage", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !10, i64 80, !18, i64 88}
!18 = !{!"funcs", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!19 = !{!17, !6, i64 4}
!20 = !{!17, !6, i64 24}
!21 = !{!17, !6, i64 48}
!22 = !{!17, !13, i64 56}
!23 = !{!17, !13, i64 64}
!24 = !{!17, !13, i64 72}
!25 = !{!26, !6, i64 0}
!26 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !10, i64 16, !13, i64 24, !10, i64 32}
!27 = !{!26, !6, i64 4}
!28 = !{!17, !6, i64 44}
!29 = !{!26, !6, i64 8}
!30 = !{!17, !10, i64 16}
!31 = !{!26, !10, i64 16}
!32 = !{!26, !13, i64 24}
!33 = !{!26, !10, i64 32}


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

@display = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__.take_screenshot = external hidden unnamed_addr constant [68 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @take_screenshot(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = load ptr, ptr @display, align 8, !tbaa !5
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %15

13:                                               ; preds = %4
  %14 = tail call ptr @XOpenDisplay(ptr noundef null) #6
  store ptr %14, ptr @display, align 8, !tbaa !5
  %.not42 = icmp eq ptr %14, null
  br i1 %.not42, label %100, label %15

15:                                               ; preds = %13, %4
  %16 = phi ptr [ %14, %13 ], [ %12, %4 ]
  %17 = tail call i32 @llvm.umin.i32(i32 %2, i32 2147483647)
  %18 = tail call i32 @llvm.umin.i32(i32 %3, i32 2147483647)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #6
  %19 = getelementptr inbounds i8, ptr %16, i64 232
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = call i32 @XGetGeometry(ptr noundef nonnull %16, i64 noundef %22, ptr noundef nonnull %11, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %10) #6
  %24 = load i32, ptr %5, align 4, !tbaa !15
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %15
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 70, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

27:                                               ; preds = %15
  %28 = load i32, ptr %6, align 4, !tbaa !15
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 71, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

31:                                               ; preds = %27
  %32 = load i32, ptr %7, align 4, !tbaa !15
  %33 = call i32 @clamp(i32 noundef %0, i32 noundef 0, i32 noundef %32)
  %34 = load i32, ptr %7, align 4, !tbaa !15
  %35 = call i32 @clamp(i32 noundef %1, i32 noundef 0, i32 noundef %34)
  %36 = load i32, ptr %7, align 4, !tbaa !15
  %37 = sub i32 %36, %33
  %38 = call i32 @clamp(i32 noundef %17, i32 noundef 0, i32 noundef %37)
  %39 = load i32, ptr %8, align 4, !tbaa !15
  %40 = sub i32 %39, %35
  %41 = call i32 @clamp(i32 noundef %18, i32 noundef 0, i32 noundef %40)
  %42 = icmp eq i32 %38, 0
  %43 = icmp eq i32 %41, 0
  %or.cond = select i1 %42, i1 true, i1 %43
  br i1 %or.cond, label %44, label %45

44:                                               ; preds = %31
  call void (ptr, ...) @debug_log(ptr noundef nonnull @.str.3)
  br label %99

45:                                               ; preds = %31
  %46 = load ptr, ptr @display, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 232
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds i8, ptr %48, i64 16
  %50 = load i64, ptr %49, align 8, !tbaa !13
  %51 = call ptr @XGetImage(ptr noundef %46, i64 noundef %50, i32 noundef %33, i32 noundef %35, i32 noundef %38, i32 noundef %41, i64 noundef -1, i32 noundef 2) #6
  %.not43 = icmp eq ptr %51, null
  br i1 %.not43, label %52, label %53

52:                                               ; preds = %45
  call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 82, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

53:                                               ; preds = %45
  %54 = load i32, ptr %51, align 8, !tbaa !16
  %55 = icmp eq i32 %54, %38
  br i1 %55, label %57, label %56

56:                                               ; preds = %53
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 83, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

57:                                               ; preds = %53
  %58 = getelementptr inbounds i8, ptr %51, i64 4
  %59 = load i32, ptr %58, align 4, !tbaa !19
  %60 = icmp eq i32 %59, %41
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 84, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

62:                                               ; preds = %57
  %63 = getelementptr inbounds i8, ptr %51, i64 24
  %64 = load i32, ptr %63, align 8, !tbaa !20
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 85, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

67:                                               ; preds = %62
  %68 = getelementptr inbounds i8, ptr %51, i64 48
  %69 = load i32, ptr %68, align 8, !tbaa !21
  %70 = icmp eq i32 %69, 32
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 86, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

72:                                               ; preds = %67
  %73 = getelementptr inbounds i8, ptr %51, i64 56
  %74 = load i64, ptr %73, align 8, !tbaa !22
  %75 = icmp eq i64 %74, 16711680
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 87, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

77:                                               ; preds = %72
  %78 = getelementptr inbounds i8, ptr %51, i64 64
  %79 = load i64, ptr %78, align 8, !tbaa !23
  %80 = icmp eq i64 %79, 65280
  br i1 %80, label %82, label %81

81:                                               ; preds = %77
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 88, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

82:                                               ; preds = %77
  %83 = getelementptr inbounds i8, ptr %51, i64 72
  %84 = load i64, ptr %83, align 8, !tbaa !24
  %85 = icmp eq i64 %84, 255
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 89, ptr noundef nonnull @__PRETTY_FUNCTION__.take_screenshot) #7
  unreachable

87:                                               ; preds = %82
  %88 = call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #8
  store i32 %38, ptr %88, align 8, !tbaa !25
  %89 = getelementptr inbounds i8, ptr %88, i64 4
  store i32 %41, ptr %89, align 4, !tbaa !27
  %90 = getelementptr inbounds i8, ptr %51, i64 44
  %91 = load i32, ptr %90, align 4, !tbaa !28
  %92 = getelementptr inbounds i8, ptr %88, i64 8
  store i32 %91, ptr %92, align 8, !tbaa !29
  %93 = getelementptr inbounds i8, ptr %51, i64 16
  %94 = load ptr, ptr %93, align 8, !tbaa !30
  %95 = getelementptr inbounds i8, ptr %88, i64 16
  store ptr %94, ptr %95, align 8, !tbaa !31
  %96 = call i64 @get_nanoseconds()
  %97 = getelementptr inbounds i8, ptr %88, i64 24
  store i64 %96, ptr %97, align 8, !tbaa !32
  %98 = getelementptr inbounds i8, ptr %88, i64 32
  store ptr %51, ptr %98, align 8, !tbaa !33
  br label %99

99:                                               ; preds = %87, %44
  %.0 = phi ptr [ null, %44 ], [ %88, %87 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  br label %100

100:                                              ; preds = %13, %99
  %.1 = phi ptr [ %.0, %99 ], [ null, %13 ]
  ret ptr %.1
}

declare ptr @XOpenDisplay(ptr noundef) local_unnamed_addr #1

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

declare i32 @XGetGeometry(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @clamp(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @debug_log(ptr noundef, ...) local_unnamed_addr #0

declare ptr @XGetImage(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @get_nanoseconds() local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #5

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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind allocsize(0) }

!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, !6, i64 232}
!10 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !6, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !11, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !6, i64 104, !11, i64 112, !11, i64 116, !6, i64 120, !6, i64 128, !11, i64 136, !12, i64 144, !12, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !11, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !11, i64 224, !11, i64 228, !6, i64 232, !12, i64 240, !12, i64 248, !11, i64 256, !11, i64 260, !6, i64 264, !6, i64 272, !11, i64 280, !6, i64 288}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"", !6, i64 0, !6, i64 8, !12, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !6, i64 48, !11, i64 56, !6, i64 64, !6, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !12, i64 120}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !11, i64 0}
!17 = !{!"_XImage", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !6, i64 80, !18, i64 88}
!18 = !{!"funcs", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!17, !11, i64 4}
!20 = !{!17, !11, i64 24}
!21 = !{!17, !11, i64 48}
!22 = !{!17, !12, i64 56}
!23 = !{!17, !12, i64 64}
!24 = !{!17, !12, i64 72}
!25 = !{!26, !11, i64 0}
!26 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !12, i64 24, !6, i64 32}
!27 = !{!26, !11, i64 4}
!28 = !{!17, !11, i64 44}
!29 = !{!26, !11, i64 8}
!30 = !{!17, !6, i64 16}
!31 = !{!26, !6, i64 16}
!32 = !{!26, !12, i64 24}
!33 = !{!26, !6, i64 32}


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