; LLVM IR from dloebl/cgif :: src (cgif)

; 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.CGIFRaw_Config = type { ptr, ptr, ptr, i32, i16, i16, i16, i16 }
%struct.st_gifconfig = type { ptr, ptr, i32, i32, i16, i16, i16, i16, ptr, ptr }
%struct.st_gif = type { [3 x ptr], %struct.st_gifconfig, ptr, ptr, i32, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local ptr @cgif_newgif(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.CGIFRaw_Config, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #6
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 40, i1 false)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.st_gifconfig, ptr %9, i32 0, i32 4
  %11 = load i16, ptr %10, align 8, !tbaa !9
  %12 = icmp ne i16 %11, 0
  br i1 %12, label %13, label %18

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.st_gifconfig, ptr %14, i32 0, i32 5
  %16 = load i16, ptr %15, align 2, !tbaa !13
  %17 = icmp ne i16 %16, 0
  br i1 %17, label %19, label %18

18:                                               ; preds = %13, %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %161

19:                                               ; preds = %13
  store ptr null, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.st_gifconfig, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %33

24:                                               ; preds = %19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.st_gifconfig, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = call noalias ptr @fopen(ptr noundef %27, ptr noundef @.str)
  store ptr %28, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %24
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %161

32:                                               ; preds = %24
  br label %33

33:                                               ; preds = %32, %19
  %34 = call noalias ptr @malloc(i64 noundef 96) #7
  store ptr %34, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %44

37:                                               ; preds = %33
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call i32 @fclose(ptr noundef %41)
  br label %43

43:                                               ; preds = %40, %37
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %161

44:                                               ; preds = %33
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %45, i8 0, i64 96, i1 false)
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.st_gif, ptr %47, i32 0, i32 3
  store ptr %46, ptr %48, align 8, !tbaa !15
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.st_gif, ptr %49, i32 0, i32 5
  store i32 1, ptr %50, align 4, !tbaa !17
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.st_gif, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %52, ptr align 8 %53, i64 48, i1 false)
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.st_gifconfig, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !18
  %57 = zext i32 %56 to i64
  %58 = and i64 %57, 4
  %59 = icmp eq i64 %58, 0
  br i1 %59, label %60, label %84

60:                                               ; preds = %44
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.st_gifconfig, ptr %61, i32 0, i32 6
  %63 = load i16, ptr %62, align 4, !tbaa !19
  %64 = zext i16 %63 to i32
  %65 = mul nsw i32 %64, 3
  %66 = sext i32 %65 to i64
  %67 = call noalias ptr @malloc(i64 noundef %66) #7
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.st_gif, ptr %68, i32 0, i32 1
  %70 = getelementptr inbounds %struct.st_gifconfig, ptr %69, i32 0, i32 0
  store ptr %67, ptr %70, align 8, !tbaa !20
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.st_gif, ptr %71, i32 0, i32 1
  %73 = getelementptr inbounds %struct.st_gifconfig, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !20
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.st_gifconfig, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.st_gifconfig, ptr %78, i32 0, i32 6
  %80 = load i16, ptr %79, align 4, !tbaa !19
  %81 = zext i16 %80 to i32
  %82 = mul nsw i32 %81, 3
  %83 = sext i32 %82 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %74, ptr align 1 %77, i64 %83, i1 false)
  br label %84

84:                                               ; preds = %60, %44
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.st_gifconfig, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !21
  %88 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 2
  store ptr %87, ptr %88, align 8, !tbaa !22
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.st_gifconfig, ptr %89, i32 0, i32 2
  %91 = load i32, ptr %90, align 8, !tbaa !18
  %92 = zext i32 %91 to i64
  %93 = and i64 %92, 4
  %94 = icmp ne i64 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %84
  br label %101

96:                                               ; preds = %84
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.st_gifconfig, ptr %97, i32 0, i32 6
  %99 = load i16, ptr %98, align 4, !tbaa !19
  %100 = zext i16 %99 to i32
  br label %101

101:                                              ; preds = %96, %95
  %102 = phi i32 [ 0, %95 ], [ %100, %96 ]
  %103 = trunc i32 %102 to i16
  %104 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 6
  store i16 %103, ptr %104, align 8, !tbaa !24
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.st_gifconfig, ptr %105, i32 0, i32 2
  %107 = load i32, ptr %106, align 8, !tbaa !18
  %108 = zext i32 %107 to i64
  %109 = and i64 %108, 2
  %110 = icmp ne i64 %109, 0
  %111 = zext i1 %110 to i64
  %112 = select i1 %110, i64 1, i64 0
  %113 = trunc i64 %112 to i32
  %114 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 3
  store i32 %113, ptr %114, align 8, !tbaa !25
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.st_gifconfig, ptr %115, i32 0, i32 2
  %117 = load i32, ptr %116, align 8, !tbaa !18
  %118 = zext i32 %117 to i64
  %119 = and i64 %118, 16
  %120 = icmp ne i64 %119, 0
  %121 = zext i1 %120 to i64
  %122 = select i1 %120, i64 2, i64 0
  %123 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 3
  %124 = load i32, ptr %123, align 8, !tbaa !25
  %125 = zext i32 %124 to i64
  %126 = or i64 %125, %122
  %127 = trunc i64 %126 to i32
  store i32 %127, ptr %123, align 8, !tbaa !25
  %128 = load ptr, ptr %3, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.st_gifconfig, ptr %128, i32 0, i32 4
  %130 = load i16, ptr %129, align 8, !tbaa !9
  %131 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 4
  store i16 %130, ptr %131, align 4, !tbaa !26
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.st_gifconfig, ptr %132, i32 0, i32 5
  %134 = load i16, ptr %133, align 2, !tbaa !13
  %135 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 5
  store i16 %134, ptr %135, align 2, !tbaa !27
  %136 = load ptr, ptr %3, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.st_gifconfig, ptr %136, i32 0, i32 7
  %138 = load i16, ptr %137, align 2, !tbaa !28
  %139 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 7
  store i16 %138, ptr %139, align 2, !tbaa !29
  %140 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 0
  store ptr @writecb, ptr %140, align 8, !tbaa !30
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.CGIFRaw_Config, ptr %7, i32 0, i32 1
  store ptr %141, ptr %142, align 8, !tbaa !31
  %143 = call ptr @cgif_raw_newgif(ptr noundef %7)
  store ptr %143, ptr %6, align 8, !tbaa !5
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = icmp eq ptr %144, null
  br i1 %145, label %146, label %154

146:                                              ; preds = %101
  %147 = load ptr, ptr %4, align 8, !tbaa !5
  %148 = icmp ne ptr %147, null
  br i1 %148, label %149, label %152

149:                                              ; preds = %146
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  %151 = call i32 @fclose(ptr noundef %150)
  br label %152

152:                                              ; preds = %149, %146
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  call void @freeCGIF(ptr noundef %153)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %161

154:                                              ; preds = %101
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.st_gif, ptr %156, i32 0, i32 2
  store ptr %155, ptr %157, align 8, !tbaa !32
  %158 = load ptr, ptr %5, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.st_gif, ptr %158, i32 0, i32 4
  store i32 6, ptr %159, align 8, !tbaa !33
  %160 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %160, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %161

161:                                              ; preds = %154, %152, %43, %31, %18
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %162 = load ptr, ptr %2, align 8
  ret ptr %162
}

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

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

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

declare i32 @fclose(ptr noundef) #3

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

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

declare ptr @cgif_raw_newgif(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @freeCGIF(ptr noundef) #0

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 24}
!10 = !{!"st_gifconfig", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 26, !12, i64 28, !12, i64 30, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!10, !12, i64 26}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !6, i64 80}
!16 = !{!"st_gif", !7, i64 0, !10, i64 24, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92}
!17 = !{!16, !11, i64 92}
!18 = !{!10, !11, i64 16}
!19 = !{!10, !12, i64 28}
!20 = !{!16, !6, i64 24}
!21 = !{!10, !6, i64 0}
!22 = !{!23, !6, i64 16}
!23 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 28, !12, i64 30, !12, i64 32, !12, i64 34}
!24 = !{!23, !12, i64 32}
!25 = !{!23, !11, i64 24}
!26 = !{!23, !12, i64 28}
!27 = !{!23, !12, i64 30}
!28 = !{!10, !12, i64 30}
!29 = !{!23, !12, i64 34}
!30 = !{!23, !6, i64 0}
!31 = !{!23, !6, i64 8}
!32 = !{!16, !6, i64 72}
!33 = !{!16, !11, 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.CGIFRaw_Config = type { ptr, ptr, ptr, i32, i16, i16, i16, i16 }

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @cgif_newgif(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = alloca %struct.CGIFRaw_Config, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #7
  %3 = getelementptr inbounds i8, ptr %2, i64 32
  store i64 0, ptr %3, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i16, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i16 %5, 0
  br i1 %.not, label %.thread53, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 26
  %8 = load i16, ptr %7, align 2, !tbaa !12
  %.not43 = icmp eq i16 %8, 0
  br i1 %.not43, label %.thread53, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %.not44 = icmp eq ptr %11, null
  br i1 %.not44, label %.thread, label %12

12:                                               ; preds = %9
  %13 = tail call noalias ptr @fopen(ptr noundef nonnull %11, ptr noundef nonnull @.str)
  %14 = icmp eq ptr %13, null
  br i1 %14, label %.thread53, label %15

15:                                               ; preds = %12
  %16 = tail call noalias dereferenceable_or_null(96) ptr @malloc(i64 noundef 96) #8
  %17 = icmp eq ptr %16, null
  br i1 %17, label %20, label %22

.thread:                                          ; preds = %9
  %18 = tail call noalias dereferenceable_or_null(96) ptr @malloc(i64 noundef 96) #8
  %19 = icmp eq ptr %18, null
  br i1 %19, label %.thread53, label %22

20:                                               ; preds = %15
  %21 = tail call i32 @fclose(ptr noundef nonnull %13)
  br label %.thread53

22:                                               ; preds = %.thread, %15
  %23 = phi ptr [ %18, %.thread ], [ %16, %15 ]
  %.03852 = phi ptr [ null, %.thread ], [ %13, %15 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %23, i8 0, i64 96, i1 false)
  %24 = getelementptr inbounds i8, ptr %23, i64 80
  store ptr %.03852, ptr %24, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %23, i64 92
  store i32 1, ptr %25, align 4, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %23, i64 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %26, ptr noundef nonnull align 8 dereferenceable(48) %0, i64 48, i1 false)
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  %28 = load i32, ptr %27, align 8, !tbaa !17
  %29 = and i32 %28, 4
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %33, label %31

31:                                               ; preds = %22
  %32 = load ptr, ptr %0, align 8, !tbaa !18
  br label %40

33:                                               ; preds = %22
  %34 = getelementptr inbounds i8, ptr %0, i64 28
  %35 = load i16, ptr %34, align 4, !tbaa !19
  %36 = zext i16 %35 to i64
  %37 = mul nuw nsw i64 %36, 3
  %38 = tail call noalias ptr @malloc(i64 noundef %37) #8
  store ptr %38, ptr %26, align 8, !tbaa !20
  %39 = load ptr, ptr %0, align 8, !tbaa !18
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %38, ptr align 1 %39, i64 %37, i1 false)
  br label %40

40:                                               ; preds = %31, %33
  %.sink = phi ptr [ %39, %33 ], [ %32, %31 ]
  %41 = phi i16 [ %35, %33 ], [ 0, %31 ]
  %42 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %.sink, ptr %42, align 8
  %43 = getelementptr inbounds i8, ptr %2, i64 32
  store i16 %41, ptr %43, align 8, !tbaa !21
  %44 = lshr i32 %28, 1
  %.lobit = and i32 %44, 1
  %45 = getelementptr inbounds i8, ptr %2, i64 24
  %46 = lshr i32 %28, 3
  %47 = and i32 %46, 2
  %48 = or disjoint i32 %.lobit, %47
  store i32 %48, ptr %45, align 8, !tbaa !23
  %49 = getelementptr inbounds i8, ptr %2, i64 28
  %50 = load <2 x i16>, ptr %4, align 8, !tbaa !24
  store <2 x i16> %50, ptr %49, align 4, !tbaa !24
  %51 = getelementptr inbounds i8, ptr %0, i64 30
  %52 = load i16, ptr %51, align 2, !tbaa !25
  %53 = getelementptr inbounds i8, ptr %2, i64 34
  store i16 %52, ptr %53, align 2, !tbaa !26
  store ptr @writecb, ptr %2, align 8, !tbaa !27
  %54 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %23, ptr %54, align 8, !tbaa !28
  %55 = call ptr @cgif_raw_newgif(ptr noundef nonnull %2) #7
  %56 = icmp eq ptr %55, null
  br i1 %56, label %57, label %61

57:                                               ; preds = %40
  %.not48 = icmp eq ptr %.03852, null
  br i1 %.not48, label %60, label %58

58:                                               ; preds = %57
  %59 = call i32 @fclose(ptr noundef nonnull %.03852)
  br label %60

60:                                               ; preds = %58, %57
  call void @freeCGIF(ptr noundef nonnull %23)
  br label %.thread53

61:                                               ; preds = %40
  %62 = getelementptr inbounds i8, ptr %23, i64 72
  store ptr %55, ptr %62, align 8, !tbaa !29
  %63 = getelementptr inbounds i8, ptr %23, i64 88
  store i32 6, ptr %63, align 8, !tbaa !30
  br label %.thread53

.thread53:                                        ; preds = %.thread, %20, %12, %1, %6, %61, %60
  %.0 = phi ptr [ null, %60 ], [ %23, %61 ], [ null, %6 ], [ null, %1 ], [ null, %12 ], [ null, %20 ], [ null, %.thread ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #7
  ret ptr %.0
}

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

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

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

; 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: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

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

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

declare ptr @cgif_raw_newgif(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare hidden void @freeCGIF(ptr noundef) local_unnamed_addr #0

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nofree 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { "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 #7 = { 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, !11, i64 24}
!6 = !{!"st_gifconfig", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 26, !11, i64 28, !11, i64 30, !7, i64 32, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!6, !11, i64 26}
!13 = !{!6, !7, i64 8}
!14 = !{!15, !7, i64 80}
!15 = !{!"st_gif", !8, i64 0, !6, i64 24, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 92}
!16 = !{!15, !10, i64 92}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !11, i64 28}
!20 = !{!15, !7, i64 24}
!21 = !{!22, !11, i64 32}
!22 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 28, !11, i64 30, !11, i64 32, !11, i64 34}
!23 = !{!22, !10, i64 24}
!24 = !{!11, !11, i64 0}
!25 = !{!6, !11, i64 30}
!26 = !{!22, !11, i64 34}
!27 = !{!22, !7, i64 0}
!28 = !{!22, !7, i64 8}
!29 = !{!15, !7, i64 72}
!30 = !{!15, !10, i64 88}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass