; LLVM IR from dloebl/cgif :: tests (local_transp)

; 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.st_gifconfig = type { ptr, ptr, i32, i32, i16, i16, i16, i16, ptr, ptr }
%struct.st_frameconfig = type { ptr, ptr, i32, i32, i16, i16, i8 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca %struct.st_gifconfig, align 8
  %4 = alloca %struct.st_frameconfig, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [768 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca i16, align 2
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 768, ptr %6) #6
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 768, i1 false)
  %10 = getelementptr inbounds <{ i8, i8, i8, i8, i8, i8, [762 x i8] }>, ptr %6, i32 0, i32 3
  store i8 -1, ptr %10, align 1
  %11 = getelementptr inbounds <{ i8, i8, i8, i8, i8, i8, [762 x i8] }>, ptr %6, i32 0, i32 4
  store i8 -1, ptr %11, align 4
  %12 = getelementptr inbounds <{ i8, i8, i8, i8, i8, i8, [762 x i8] }>, ptr %6, i32 0, i32 5
  store i8 -1, ptr %12, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #6
  store i16 256, ptr %8, align 2, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %3, i8 0, i64 48, i1 false)
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 32, i1 false)
  %13 = getelementptr inbounds %struct.st_gifconfig, ptr %3, i32 0, i32 2
  store i32 6, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.st_gifconfig, ptr %3, i32 0, i32 3
  store i32 1, ptr %14, align 4, !tbaa !13
  %15 = getelementptr inbounds %struct.st_gifconfig, ptr %3, i32 0, i32 4
  store i16 103, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds %struct.st_gifconfig, ptr %3, i32 0, i32 5
  store i16 104, ptr %16, align 2, !tbaa !15
  %17 = getelementptr inbounds %struct.st_gifconfig, ptr %3, i32 0, i32 1
  store ptr @.str, ptr %17, align 8, !tbaa !16
  %18 = call ptr @cgif_newgif(ptr noundef %3)
  store ptr %18, ptr %2, align 8, !tbaa !17
  %19 = load ptr, ptr %2, align 8, !tbaa !17
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %0
  %22 = load ptr, ptr @stderr, align 8, !tbaa !17
  %23 = call i32 @fputs(ptr noundef @.str.1, ptr noundef %22)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %51

24:                                               ; preds = %0
  %25 = call noalias ptr @malloc(i64 noundef 10712) #7
  store ptr %25, ptr %5, align 8, !tbaa !17
  %26 = load ptr, ptr %5, align 8, !tbaa !17
  call void @llvm.memset.p0.i64(ptr align 1 %26, i8 1, i64 10712, i1 false)
  %27 = load ptr, ptr %5, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %27, i64 206
  call void @llvm.memset.p0.i64(ptr align 1 %28, i8 0, i64 309, i1 false)
  %29 = load ptr, ptr %5, align 8, !tbaa !17
  %30 = getelementptr inbounds %struct.st_frameconfig, ptr %4, i32 0, i32 1
  store ptr %29, ptr %30, align 8, !tbaa !18
  %31 = getelementptr inbounds [768 x i8], ptr %6, i64 0, i64 0
  %32 = getelementptr inbounds %struct.st_frameconfig, ptr %4, i32 0, i32 0
  store ptr %31, ptr %32, align 8, !tbaa !20
  %33 = load i16, ptr %8, align 2, !tbaa !5
  %34 = getelementptr inbounds %struct.st_frameconfig, ptr %4, i32 0, i32 5
  store i16 %33, ptr %34, align 2, !tbaa !21
  %35 = getelementptr inbounds %struct.st_frameconfig, ptr %4, i32 0, i32 2
  store i32 1, ptr %35, align 8, !tbaa !22
  %36 = getelementptr inbounds %struct.st_frameconfig, ptr %4, i32 0, i32 3
  store i32 1, ptr %36, align 4, !tbaa !23
  %37 = load ptr, ptr %2, align 8, !tbaa !17
  %38 = call i32 @cgif_addframe(ptr noundef %37, ptr noundef %4)
  store i32 %38, ptr %7, align 4, !tbaa !24
  %39 = load ptr, ptr %2, align 8, !tbaa !17
  %40 = call i32 @cgif_addframe(ptr noundef %39, ptr noundef %4)
  store i32 %40, ptr %7, align 4, !tbaa !24
  %41 = load ptr, ptr %5, align 8, !tbaa !17
  call void @free(ptr noundef %41) #6
  %42 = load ptr, ptr %2, align 8, !tbaa !17
  %43 = call i32 @cgif_close(ptr noundef %42)
  store i32 %43, ptr %7, align 4, !tbaa !24
  %44 = load i32, ptr %7, align 4, !tbaa !24
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %50

46:                                               ; preds = %24
  %47 = load ptr, ptr @stderr, align 8, !tbaa !17
  %48 = load i32, ptr %7, align 4, !tbaa !24
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.2, i32 noundef %48) #6
  store i32 2, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %51

50:                                               ; preds = %24
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %51

51:                                               ; preds = %50, %46, %21
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 768, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %52 = load i32, ptr %1, align 4
  ret i32 %52
}

; 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 ptr @cgif_newgif(ptr noundef) #3

declare i32 @fputs(ptr noundef, ptr noundef) #3

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

declare i32 @cgif_addframe(ptr noundef, ptr noundef) #3

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

declare i32 @cgif_close(ptr noundef) #3

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

; 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 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"st_gifconfig", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 26, !6, i64 28, !6, i64 30, !11, i64 32, !11, i64 40}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 20}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !6, i64 26}
!16 = !{!10, !11, i64 8}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !11, i64 8}
!19 = !{!"st_frameconfig", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 26, !7, i64 28}
!20 = !{!19, !11, i64 0}
!21 = !{!19, !6, i64 26}
!22 = !{!19, !12, i64 16}
!23 = !{!19, !12, i64 20}
!24 = !{!12, !12, i64 0}


; 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.st_gifconfig = type { ptr, ptr, i32, i32, i16, i16, i16, i16, ptr, ptr }
%struct.st_frameconfig = type { ptr, ptr, i32, i32, i16, i16, i8 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.st_gifconfig, align 8
  %2 = alloca %struct.st_frameconfig, align 8
  %3 = alloca [768 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 768, ptr nonnull %3) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(768) %3, i8 0, i64 768, i1 false)
  %4 = getelementptr inbounds i8, ptr %3, i64 3
  store i8 -1, ptr %4, align 1
  %5 = getelementptr inbounds i8, ptr %3, i64 4
  store i8 -1, ptr %5, align 4
  %6 = getelementptr inbounds i8, ptr %3, i64 5
  store i8 -1, ptr %6, align 1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %1, i8 0, i64 48, i1 false)
  %7 = getelementptr inbounds i8, ptr %2, i64 24
  store i64 0, ptr %7, align 8
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 6, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 1, ptr %9, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  store i16 103, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %1, i64 26
  store i16 104, ptr %11, align 2, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr @.str, ptr %12, align 8, !tbaa !15
  %13 = call ptr @cgif_newgif(ptr noundef nonnull %1) #7
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %0
  %16 = load ptr, ptr @stderr, align 8, !tbaa !16
  %17 = call i32 @fputs(ptr noundef nonnull @.str.1, ptr noundef %16) #8
  br label %31

18:                                               ; preds = %0
  %19 = call noalias dereferenceable_or_null(10712) ptr @malloc(i64 noundef 10712) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(10712) %19, i8 1, i64 10712, i1 false)
  %20 = getelementptr inbounds i8, ptr %19, i64 206
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(309) %20, i8 0, i64 309, i1 false)
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %19, ptr %21, align 8, !tbaa !17
  store ptr %3, ptr %2, align 8, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %2, i64 26
  store i16 256, ptr %22, align 2, !tbaa !20
  %23 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 1, ptr %23, align 8, !tbaa !21
  %24 = getelementptr inbounds i8, ptr %2, i64 20
  store i32 1, ptr %24, align 4, !tbaa !22
  %25 = call i32 @cgif_addframe(ptr noundef nonnull %13, ptr noundef nonnull %2) #7
  %26 = call i32 @cgif_addframe(ptr noundef nonnull %13, ptr noundef nonnull %2) #7
  call void @free(ptr noundef %19) #7
  %27 = call i32 @cgif_close(ptr noundef nonnull %13) #7
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %31, label %28

28:                                               ; preds = %18
  %29 = load ptr, ptr @stderr, align 8, !tbaa !16
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.2, i32 noundef %27) #10
  br label %31

31:                                               ; preds = %18, %28, %15
  %.0 = phi i32 [ 1, %15 ], [ 2, %28 ], [ 0, %18 ]
  call void @llvm.lifetime.end.p0(i64 768, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #7
  ret i32 %.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

declare ptr @cgif_newgif(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fputs(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #4

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

declare i32 @cgif_addframe(ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare i32 @cgif_close(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) 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) #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 = { "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 "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 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { cold }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { cold nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !10, i64 16}
!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, !10, i64 20}
!13 = !{!6, !11, i64 24}
!14 = !{!6, !11, i64 26}
!15 = !{!6, !7, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !7, i64 8}
!18 = !{!"st_frameconfig", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 26, !8, i64 28}
!19 = !{!18, !7, i64 0}
!20 = !{!18, !11, i64 26}
!21 = !{!18, !10, i64 16}
!22 = !{!18, !10, i64 20}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass