; LLVM IR from yettabaa/cub3D :: mlx-linux (mlx_new_image)

; 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.s_img = type { ptr, i64, ptr, i32, i32, i32, i32, i32, i32, ptr, %struct.XShmSegmentInfo }
%struct.XShmSegmentInfo = type { i64, i32, ptr, i32 }
%struct.s_xvar = type { ptr, i64, i32, i32, ptr, i64, i32, ptr, ptr, ptr, i32, i32, i32, [6 x i32], i64, i64, i32 }
%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 }

@mlx_X_error = external dso_local global i32, align 4

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

; Function Attrs: nounwind uwtable
define dso_local ptr @mlx_int_new_xshm_image(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %13 = call noalias ptr @malloc(i64 noundef 88) #7
  store ptr %13, ptr %10, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %243

16:                                               ; preds = %4
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %17, i8 0, i64 88, i1 false)
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_img, ptr %18, i32 0, i32 9
  store ptr null, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.s_xvar, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.s_xvar, ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.s_xvar, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !18
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.s_img, ptr %30, i32 0, i32 9
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.s_img, ptr %33, i32 0, i32 10
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = call ptr @XShmCreateImage(ptr noundef %22, ptr noundef %25, i32 noundef %28, i32 noundef %29, ptr noundef %32, ptr noundef %34, i32 noundef %35, i32 noundef %36)
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.s_img, ptr %38, i32 0, i32 0
  store ptr %37, ptr %39, align 8, !tbaa !19
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s_img, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !19
  %43 = icmp ne ptr %42, null
  br i1 %43, label %46, label %44

44:                                               ; preds = %16
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %45) #6
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %243

46:                                               ; preds = %16
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.s_img, ptr %48, i32 0, i32 5
  store i32 %47, ptr %49, align 8, !tbaa !20
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.s_img, ptr %51, i32 0, i32 6
  store i32 %50, ptr %52, align 4, !tbaa !21
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.s_img, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  %56 = getelementptr inbounds %struct._XImage, ptr %55, i32 0, i32 10
  %57 = load i32, ptr %56, align 4, !tbaa !22
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.s_img, ptr %58, i32 0, i32 3
  store i32 %57, ptr %59, align 8, !tbaa !25
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.s_img, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  %63 = getelementptr inbounds %struct._XImage, ptr %62, i32 0, i32 11
  %64 = load i32, ptr %63, align 8, !tbaa !26
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.s_img, ptr %65, i32 0, i32 4
  store i32 %64, ptr %66, align 4, !tbaa !27
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.s_img, ptr %68, i32 0, i32 8
  store i32 %67, ptr %69, align 4, !tbaa !28
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = add nsw i32 %70, 32
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = mul nsw i32 %71, %72
  %74 = mul nsw i32 %73, 4
  %75 = sext i32 %74 to i64
  %76 = call i32 @shmget(i32 noundef 0, i64 noundef %75, i32 noundef 1023) #6
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.s_img, ptr %77, i32 0, i32 10
  %79 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %78, i32 0, i32 1
  store i32 %76, ptr %79, align 8, !tbaa !29
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.s_img, ptr %80, i32 0, i32 10
  %82 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 8, !tbaa !29
  %84 = icmp eq i32 %83, -1
  br i1 %84, label %85, label %97

85:                                               ; preds = %46
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.s_img, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !19
  %89 = getelementptr inbounds %struct._XImage, ptr %88, i32 0, i32 16
  %90 = getelementptr inbounds %struct.funcs, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !30
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.s_img, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !19
  %95 = call i32 %91(ptr noundef %94)
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %96) #6
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %243

97:                                               ; preds = %46
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.s_img, ptr %98, i32 0, i32 10
  %100 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 8, !tbaa !29
  %102 = call ptr @shmat(i32 noundef %101, ptr noundef null, i32 noundef 0) #6
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.s_img, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !19
  %106 = getelementptr inbounds %struct._XImage, ptr %105, i32 0, i32 4
  store ptr %102, ptr %106, align 8, !tbaa !31
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.s_img, ptr %107, i32 0, i32 10
  %109 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %108, i32 0, i32 2
  store ptr %102, ptr %109, align 8, !tbaa !32
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.s_img, ptr %110, i32 0, i32 9
  store ptr %102, ptr %111, align 8, !tbaa !11
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.s_img, ptr %112, i32 0, i32 9
  %114 = load ptr, ptr %113, align 8, !tbaa !11
  %115 = icmp eq ptr %114, inttoptr (i64 -1 to ptr)
  br i1 %115, label %116, label %133

116:                                              ; preds = %97
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.s_img, ptr %117, i32 0, i32 10
  %119 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %118, i32 0, i32 1
  %120 = load i32, ptr %119, align 8, !tbaa !29
  %121 = call i32 @shmctl(i32 noundef %120, i32 noundef 0, ptr noundef null) #6
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.s_img, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !19
  %125 = getelementptr inbounds %struct._XImage, ptr %124, i32 0, i32 16
  %126 = getelementptr inbounds %struct.funcs, ptr %125, i32 0, i32 1
  %127 = load ptr, ptr %126, align 8, !tbaa !30
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.s_img, ptr %128, i32 0, i32 0
  %130 = load ptr, ptr %129, align 8, !tbaa !19
  %131 = call i32 %127(ptr noundef %130)
  %132 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %132) #6
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %243

133:                                              ; preds = %97
  %134 = load ptr, ptr %10, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.s_img, ptr %134, i32 0, i32 10
  %136 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %135, i32 0, i32 3
  store i32 0, ptr %136, align 8, !tbaa !33
  store i32 0, ptr @mlx_X_error, align 4, !tbaa !9
  %137 = call ptr @XSetErrorHandler(ptr noundef @shm_att_pb)
  store ptr %137, ptr %11, align 8, !tbaa !5
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.s_xvar, ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !15
  %141 = load ptr, ptr %10, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.s_img, ptr %141, i32 0, i32 10
  %143 = call i32 @XShmAttach(ptr noundef %140, ptr noundef %142)
  %144 = icmp ne i32 %143, 0
  br i1 %144, label %145, label %155

145:                                              ; preds = %133
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.s_xvar, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %147, align 8, !tbaa !15
  %149 = call i32 @XSync(ptr noundef %148, i32 noundef 0)
  %150 = and i32 0, %149
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %155, label %152

152:                                              ; preds = %145
  %153 = load i32, ptr @mlx_X_error, align 4, !tbaa !9
  %154 = icmp ne i32 %153, 0
  br i1 %154, label %155, label %178

155:                                              ; preds = %152, %145, %133
  %156 = load ptr, ptr %11, align 8, !tbaa !5
  %157 = call ptr @XSetErrorHandler(ptr noundef %156)
  %158 = load ptr, ptr %10, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.s_img, ptr %158, i32 0, i32 9
  %160 = load ptr, ptr %159, align 8, !tbaa !11
  %161 = call i32 @shmdt(ptr noundef %160) #6
  %162 = load ptr, ptr %10, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.s_img, ptr %162, i32 0, i32 10
  %164 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %163, i32 0, i32 1
  %165 = load i32, ptr %164, align 8, !tbaa !29
  %166 = call i32 @shmctl(i32 noundef %165, i32 noundef 0, ptr noundef null) #6
  %167 = load ptr, ptr %10, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.s_img, ptr %167, i32 0, i32 0
  %169 = load ptr, ptr %168, align 8, !tbaa !19
  %170 = getelementptr inbounds %struct._XImage, ptr %169, i32 0, i32 16
  %171 = getelementptr inbounds %struct.funcs, ptr %170, i32 0, i32 1
  %172 = load ptr, ptr %171, align 8, !tbaa !30
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.s_img, ptr %173, i32 0, i32 0
  %175 = load ptr, ptr %174, align 8, !tbaa !19
  %176 = call i32 %172(ptr noundef %175)
  %177 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %177) #6
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %243

178:                                              ; preds = %152
  %179 = load ptr, ptr %11, align 8, !tbaa !5
  %180 = call ptr @XSetErrorHandler(ptr noundef %179)
  %181 = load ptr, ptr %10, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.s_img, ptr %181, i32 0, i32 10
  %183 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %182, i32 0, i32 1
  %184 = load i32, ptr %183, align 8, !tbaa !29
  %185 = call i32 @shmctl(i32 noundef %184, i32 noundef 0, ptr noundef null) #6
  %186 = load ptr, ptr %6, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.s_xvar, ptr %186, i32 0, i32 11
  %188 = load i32, ptr %187, align 4, !tbaa !34
  %189 = load i32, ptr %9, align 4, !tbaa !9
  %190 = icmp eq i32 %188, %189
  br i1 %190, label %191, label %214

191:                                              ; preds = %178
  %192 = load ptr, ptr %6, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.s_xvar, ptr %192, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !15
  %195 = load ptr, ptr %6, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.s_xvar, ptr %195, i32 0, i32 1
  %197 = load i64, ptr %196, align 8, !tbaa !35
  %198 = load ptr, ptr %10, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.s_img, ptr %198, i32 0, i32 10
  %200 = getelementptr inbounds %struct.XShmSegmentInfo, ptr %199, i32 0, i32 2
  %201 = load ptr, ptr %200, align 8, !tbaa !32
  %202 = load ptr, ptr %10, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.s_img, ptr %202, i32 0, i32 10
  %204 = load i32, ptr %7, align 4, !tbaa !9
  %205 = load i32, ptr %8, align 4, !tbaa !9
  %206 = load ptr, ptr %6, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.s_xvar, ptr %206, i32 0, i32 3
  %208 = load i32, ptr %207, align 4, !tbaa !18
  %209 = call i64 @XShmCreatePixmap(ptr noundef %194, i64 noundef %197, ptr noundef %201, ptr noundef %203, i32 noundef %204, i32 noundef %205, i32 noundef %208)
  %210 = load ptr, ptr %10, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.s_img, ptr %210, i32 0, i32 1
  store i64 %209, ptr %211, align 8, !tbaa !36
  %212 = load ptr, ptr %10, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct.s_img, ptr %212, i32 0, i32 7
  store i32 3, ptr %213, align 8, !tbaa !37
  br label %231

214:                                              ; preds = %178
  %215 = load ptr, ptr %6, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.s_xvar, ptr %215, i32 0, i32 0
  %217 = load ptr, ptr %216, align 8, !tbaa !15
  %218 = load ptr, ptr %6, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.s_xvar, ptr %218, i32 0, i32 1
  %220 = load i64, ptr %219, align 8, !tbaa !35
  %221 = load i32, ptr %7, align 4, !tbaa !9
  %222 = load i32, ptr %8, align 4, !tbaa !9
  %223 = load ptr, ptr %6, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct.s_xvar, ptr %223, i32 0, i32 3
  %225 = load i32, ptr %224, align 4, !tbaa !18
  %226 = call i64 @XCreatePixmap(ptr noundef %217, i64 noundef %220, i32 noundef %221, i32 noundef %222, i32 noundef %225)
  %227 = load ptr, ptr %10, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.s_img, ptr %227, i32 0, i32 1
  store i64 %226, ptr %228, align 8, !tbaa !36
  %229 = load ptr, ptr %10, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.s_img, ptr %229, i32 0, i32 7
  store i32 2, ptr %230, align 8, !tbaa !37
  br label %231

231:                                              ; preds = %214, %191
  %232 = load ptr, ptr %6, align 8, !tbaa !5
  %233 = getelementptr inbounds %struct.s_xvar, ptr %232, i32 0, i32 12
  %234 = load i32, ptr %233, align 8, !tbaa !38
  %235 = icmp ne i32 %234, 0
  br i1 %235, label %236, label %241

236:                                              ; preds = %231
  %237 = load ptr, ptr %6, align 8, !tbaa !5
  %238 = getelementptr inbounds %struct.s_xvar, ptr %237, i32 0, i32 0
  %239 = load ptr, ptr %238, align 8, !tbaa !15
  %240 = call i32 @XFlush(ptr noundef %239)
  br label %241

241:                                              ; preds = %236, %231
  %242 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %242, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %243

243:                                              ; preds = %241, %155, %116, %85, %44, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %244 = load ptr, ptr %5, align 8
  ret ptr %244
}

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

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

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

declare ptr @XShmCreateImage(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

; Function Attrs: nounwind
declare i32 @shmget(i32 noundef, i64 noundef, i32 noundef) #5

; Function Attrs: nounwind
declare ptr @shmat(i32 noundef, ptr noundef, i32 noundef) #5

; Function Attrs: nounwind
declare i32 @shmctl(i32 noundef, i32 noundef, ptr noundef) #5

declare ptr @XSetErrorHandler(ptr noundef) #4

declare i32 @XShmAttach(ptr noundef, ptr noundef) #4

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

; Function Attrs: nounwind
declare i32 @shmdt(ptr noundef) #5

declare i64 @XShmCreatePixmap(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4

declare i64 @XCreatePixmap(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) #4

declare i32 @XFlush(ptr noundef) #4

; 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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 "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 #6 = { 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 = !{!"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 48}
!12 = !{!"s_img", !6, i64 0, !13, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !14, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !13, i64 0, !10, i64 8, !6, i64 16, !10, i64 24}
!15 = !{!16, !6, i64 0}
!16 = !{!"s_xvar", !6, i64 0, !13, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !13, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 84, !13, i64 112, !13, i64 120, !10, i64 128}
!17 = !{!16, !6, i64 24}
!18 = !{!16, !10, i64 20}
!19 = !{!12, !6, i64 0}
!20 = !{!12, !10, i64 32}
!21 = !{!12, !10, i64 36}
!22 = !{!23, !10, i64 44}
!23 = !{!"_XImage", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !6, i64 80, !24, i64 88}
!24 = !{!"funcs", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!25 = !{!12, !10, i64 24}
!26 = !{!23, !10, i64 48}
!27 = !{!12, !10, i64 28}
!28 = !{!12, !10, i64 44}
!29 = !{!12, !10, i64 64}
!30 = !{!23, !6, i64 96}
!31 = !{!23, !6, i64 16}
!32 = !{!12, !6, i64 72}
!33 = !{!12, !10, i64 80}
!34 = !{!16, !10, i64 76}
!35 = !{!16, !13, i64 8}
!36 = !{!12, !13, i64 8}
!37 = !{!12, !10, i64 40}
!38 = !{!16, !10, i64 80}


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

@mlx_X_error = external dso_local local_unnamed_addr global i32, align 4

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @mlx_int_new_xshm_image(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %calloc = tail call dereferenceable_or_null(88) ptr @calloc(i64 1, i64 88)
  %.not = icmp eq ptr %calloc, null
  br i1 %.not, label %91, label %5

5:                                                ; preds = %4
  %6 = getelementptr inbounds i8, ptr %calloc, i64 48
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 20
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %calloc, i64 56
  %13 = tail call ptr @XShmCreateImage(ptr noundef %7, ptr noundef %9, i32 noundef %11, i32 noundef %3, ptr noundef null, ptr noundef nonnull %12, i32 noundef %1, i32 noundef %2) #5
  store ptr %13, ptr %calloc, align 8, !tbaa !14
  %.not75 = icmp eq ptr %13, null
  br i1 %.not75, label %14, label %15

14:                                               ; preds = %5
  tail call void @free(ptr noundef nonnull %calloc) #5
  br label %91

15:                                               ; preds = %5
  %16 = getelementptr inbounds i8, ptr %calloc, i64 32
  store i32 %1, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %calloc, i64 36
  store i32 %2, ptr %17, align 4, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %13, i64 44
  %19 = getelementptr inbounds i8, ptr %calloc, i64 24
  %20 = load <2 x i32>, ptr %18, align 4, !tbaa !19
  store <2 x i32> %20, ptr %19, align 8, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %calloc, i64 44
  store i32 %3, ptr %21, align 4, !tbaa !20
  %22 = add nsw i32 %1, 32
  %23 = shl i32 %2, 2
  %24 = mul i32 %23, %22
  %25 = sext i32 %24 to i64
  %26 = tail call i32 @shmget(i32 noundef 0, i64 noundef %25, i32 noundef 1023) #5
  %27 = getelementptr inbounds i8, ptr %calloc, i64 64
  store i32 %26, ptr %27, align 8, !tbaa !21
  %28 = icmp eq i32 %26, -1
  br i1 %28, label %29, label %34

29:                                               ; preds = %15
  %30 = load ptr, ptr %calloc, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %30, i64 96
  %32 = load ptr, ptr %31, align 8, !tbaa !22
  %33 = tail call i32 %32(ptr noundef %30) #5
  tail call void @free(ptr noundef nonnull %calloc) #5
  br label %91

34:                                               ; preds = %15
  %35 = tail call ptr @shmat(i32 noundef %26, ptr noundef null, i32 noundef 0) #5
  %36 = load ptr, ptr %calloc, align 8, !tbaa !14
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  store ptr %35, ptr %37, align 8, !tbaa !25
  %38 = getelementptr inbounds i8, ptr %calloc, i64 72
  store ptr %35, ptr %38, align 8, !tbaa !26
  store ptr %35, ptr %6, align 8, !tbaa !27
  %39 = icmp eq ptr %35, inttoptr (i64 -1 to ptr)
  br i1 %39, label %40, label %47

40:                                               ; preds = %34
  %41 = load i32, ptr %27, align 8, !tbaa !21
  %42 = tail call i32 @shmctl(i32 noundef %41, i32 noundef 0, ptr noundef null) #5
  %43 = load ptr, ptr %calloc, align 8, !tbaa !14
  %44 = getelementptr inbounds i8, ptr %43, i64 96
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  %46 = tail call i32 %45(ptr noundef %43) #5
  tail call void @free(ptr noundef nonnull %calloc) #5
  br label %91

47:                                               ; preds = %34
  %48 = getelementptr inbounds i8, ptr %calloc, i64 80
  store i32 0, ptr %48, align 8, !tbaa !28
  store i32 0, ptr @mlx_X_error, align 4, !tbaa !19
  %49 = tail call ptr @XSetErrorHandler(ptr noundef nonnull @shm_att_pb) #5
  %50 = load ptr, ptr %0, align 8, !tbaa !5
  %51 = tail call i32 @XShmAttach(ptr noundef %50, ptr noundef nonnull %12) #5
  %.not76 = icmp eq i32 %51, 0
  br i1 %.not76, label %56, label %52

52:                                               ; preds = %47
  %53 = load ptr, ptr %0, align 8, !tbaa !5
  %54 = tail call i32 @XSync(ptr noundef %53, i32 noundef 0) #5
  %55 = load i32, ptr @mlx_X_error, align 4
  %.not77 = icmp eq i32 %55, 0
  br i1 %.not77, label %66, label %56

56:                                               ; preds = %52, %47
  %57 = tail call ptr @XSetErrorHandler(ptr noundef %49) #5
  %58 = load ptr, ptr %6, align 8, !tbaa !27
  %59 = tail call i32 @shmdt(ptr noundef %58) #5
  %60 = load i32, ptr %27, align 8, !tbaa !21
  %61 = tail call i32 @shmctl(i32 noundef %60, i32 noundef 0, ptr noundef null) #5
  %62 = load ptr, ptr %calloc, align 8, !tbaa !14
  %63 = getelementptr inbounds i8, ptr %62, i64 96
  %64 = load ptr, ptr %63, align 8, !tbaa !22
  %65 = tail call i32 %64(ptr noundef %62) #5
  tail call void @free(ptr noundef nonnull %calloc) #5
  br label %91

66:                                               ; preds = %52
  %67 = tail call ptr @XSetErrorHandler(ptr noundef %49) #5
  %68 = load i32, ptr %27, align 8, !tbaa !21
  %69 = tail call i32 @shmctl(i32 noundef %68, i32 noundef 0, ptr noundef null) #5
  %70 = getelementptr inbounds i8, ptr %0, i64 76
  %71 = load i32, ptr %70, align 4, !tbaa !29
  %72 = icmp eq i32 %71, %3
  %73 = load ptr, ptr %0, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %0, i64 8
  %75 = load i64, ptr %74, align 8, !tbaa !30
  br i1 %72, label %76, label %80

76:                                               ; preds = %66
  %77 = load ptr, ptr %38, align 8, !tbaa !26
  %78 = load i32, ptr %10, align 4, !tbaa !13
  %79 = tail call i64 @XShmCreatePixmap(ptr noundef %73, i64 noundef %75, ptr noundef %77, ptr noundef nonnull %12, i32 noundef %1, i32 noundef %2, i32 noundef %78) #5
  br label %83

80:                                               ; preds = %66
  %81 = load i32, ptr %10, align 4, !tbaa !13
  %82 = tail call i64 @XCreatePixmap(ptr noundef %73, i64 noundef %75, i32 noundef %1, i32 noundef %2, i32 noundef %81) #5
  br label %83

83:                                               ; preds = %80, %76
  %.sink79 = phi i64 [ %79, %76 ], [ %82, %80 ]
  %.sink = phi i32 [ 3, %76 ], [ 2, %80 ]
  %84 = getelementptr inbounds i8, ptr %calloc, i64 8
  store i64 %.sink79, ptr %84, align 8
  %85 = getelementptr inbounds i8, ptr %calloc, i64 40
  store i32 %.sink, ptr %85, align 8
  %86 = getelementptr inbounds i8, ptr %0, i64 80
  %87 = load i32, ptr %86, align 8, !tbaa !31
  %.not78 = icmp eq i32 %87, 0
  br i1 %.not78, label %91, label %88

88:                                               ; preds = %83
  %89 = load ptr, ptr %0, align 8, !tbaa !5
  %90 = tail call i32 @XFlush(ptr noundef %89) #5
  br label %91

91:                                               ; preds = %83, %88, %4, %56, %40, %29, %14
  %.0 = phi ptr [ null, %29 ], [ null, %40 ], [ null, %56 ], [ null, %14 ], [ null, %4 ], [ %calloc, %88 ], [ %calloc, %83 ]
  ret ptr %.0
}

declare ptr @XShmCreateImage(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @shmget(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

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

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

declare ptr @XSetErrorHandler(ptr noundef) local_unnamed_addr #1

declare i32 @XShmAttach(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind
declare i32 @shmdt(ptr noundef) local_unnamed_addr #3

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

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

declare i32 @XFlush(ptr noundef) local_unnamed_addr #1

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

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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #3 = { 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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, !7, i64 0}
!6 = !{!"s_xvar", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 20, !7, i64 24, !10, i64 32, !11, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !8, i64 84, !10, i64 112, !10, i64 120, !11, i64 128}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !11, i64 20}
!14 = !{!15, !7, i64 0}
!15 = !{!"s_img", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !7, i64 48, !16, i64 56}
!16 = !{!"", !10, i64 0, !11, i64 8, !7, i64 16, !11, i64 24}
!17 = !{!15, !11, i64 32}
!18 = !{!15, !11, i64 36}
!19 = !{!11, !11, i64 0}
!20 = !{!15, !11, i64 44}
!21 = !{!15, !11, i64 64}
!22 = !{!23, !7, i64 96}
!23 = !{!"_XImage", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !7, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !7, i64 80, !24, i64 88}
!24 = !{!"funcs", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!25 = !{!23, !7, i64 16}
!26 = !{!15, !7, i64 72}
!27 = !{!15, !7, i64 48}
!28 = !{!15, !11, i64 80}
!29 = !{!6, !11, i64 76}
!30 = !{!6, !10, i64 8}
!31 = !{!6, !11, i64 80}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass