; LLVM IR from aagdev/mlimgsynth :: src (demo_mlimgsynth)

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

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [4 x i8], align 1

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

declare i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @demo_txt2img(ptr noundef) #2

declare i32 @mlis_option_set(ptr noundef, i32 noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @demo_img2img(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @demo_inpaint(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @error_handler(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp ne i32 %7, 2
  br i1 %8, label %9, label %18

9:                                                ; preds = %2
  br label %10

10:                                               ; preds = %9
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds ptr, ptr %12, i64 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, ptr noundef %14)
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @exit(i32 noundef 1) #4
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %2
  br label %19

19:                                               ; preds = %18
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.20)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %23 = call ptr @mlis_ctx_create_i(i32 noundef 1025)
  store ptr %23, ptr %6, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %24, i32 noundef 31, ptr noundef @error_handler, ptr noundef null)
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %26, i32 noundef 30, ptr noundef @progress_callback, ptr noundef null)
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i64 1
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %28, i32 noundef 2, ptr noundef %31)
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %33, i32 noundef 9, i32 noundef 768, i32 noundef 512)
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %35, i32 noundef 24, i32 noundef 42)
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  %38 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %37, i32 noundef 13, i32 noundef 1)
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %39, i32 noundef 14, i32 noundef 1)
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %41, i32 noundef 15, i32 noundef 20)
  %43 = load ptr, ptr %6, align 8, !tbaa !9
  %44 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %43, i32 noundef 12, double noundef 7.000000e+00)
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  %46 = call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %45, i32 noundef 19, double noundef 1.000000e+00)
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = call i32 @mlis_option_set_str(ptr noundef %47, ptr noundef @.str.21, ptr noundef @.str.22)
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = call i32 @mlis_setup(ptr noundef %49)
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  call void @demo_txt2img(ptr noundef %51)
  %52 = load ptr, ptr %6, align 8, !tbaa !9
  call void @demo_img2img(ptr noundef %52)
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  call void @demo_inpaint(ptr noundef %53)
  br label %54

54:                                               ; preds = %22
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.23)
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %57

57:                                               ; preds = %54
  br label %58

58:                                               ; preds = %57
  call void @mlis_ctx_destroy(ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret i32 0
}

declare ptr @mlis_ctx_create_i(i32 noundef) #1

declare i32 @mlis_option_set_str(ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @mlis_setup(ptr noundef) #1

declare void @mlis_ctx_destroy(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { noreturn nounwind }
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, !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}


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

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @demo_txt2img(ptr noundef) local_unnamed_addr #2

declare i32 @mlis_option_set(ptr noundef, i32 noundef, ...) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @demo_img2img(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @demo_inpaint(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @error_handler(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %9, label %4

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, ptr noundef %6)
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  tail call void @exit(i32 noundef 1) #5
  unreachable

9:                                                ; preds = %2
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %12 = tail call ptr @mlis_ctx_create_i(i32 noundef 1025) #6
  store ptr %12, ptr %3, align 8, !tbaa !5
  %13 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 31, ptr noundef nonnull @error_handler, ptr noundef null) #6
  %14 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 30, ptr noundef nonnull @progress_callback, ptr noundef null) #6
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 2, ptr noundef %16) #6
  %18 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 9, i32 noundef 768, i32 noundef 512) #6
  %19 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 24, i32 noundef 42) #6
  %20 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 13, i32 noundef 1) #6
  %21 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 14, i32 noundef 1) #6
  %22 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 15, i32 noundef 20) #6
  %23 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 12, double noundef 7.000000e+00) #6
  %24 = tail call i32 (ptr, i32, ...) @mlis_option_set(ptr noundef %12, i32 noundef 19, double noundef 1.000000e+00) #6
  %25 = tail call i32 @mlis_option_set_str(ptr noundef %12, ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.22) #6
  %26 = tail call i32 @mlis_setup(ptr noundef %12) #6
  tail call void @demo_txt2img(ptr noundef %12)
  tail call void @demo_img2img(ptr noundef %12)
  tail call void @demo_inpaint(ptr noundef %12)
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.23)
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  call void @mlis_ctx_destroy(ptr noundef nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 0
}

declare ptr @mlis_ctx_create_i(i32 noundef) local_unnamed_addr #3

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

declare i32 @mlis_setup(ptr noundef) local_unnamed_addr #3

declare void @mlis_ctx_destroy(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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