; LLVM IR from solettaproject/soletta-machine-learning :: examples (example_doc)

; 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 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = call ptr @sml_fuzzy_new()
  store ptr %10, ptr %6, align 8, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !9
  %12 = call ptr @sml_new_input(ptr noundef %11, ptr noundef @.str)
  store ptr %12, ptr %7, align 8, !tbaa !9
  %13 = load ptr, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr %7, align 8, !tbaa !9
  %15 = call zeroext i1 @sml_variable_set_range(ptr noundef %13, ptr noundef %14, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %16 = load ptr, ptr %6, align 8, !tbaa !9
  %17 = load ptr, ptr %7, align 8, !tbaa !9
  %18 = call zeroext i1 @sml_fuzzy_variable_set_default_term_width(ptr noundef %16, ptr noundef %17, float noundef 5.000000e-01)
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = call ptr @sml_new_output(ptr noundef %19, ptr noundef @.str.1)
  store ptr %20, ptr %8, align 8, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !9
  %23 = call zeroext i1 @sml_variable_set_range(ptr noundef %21, ptr noundef %22, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  %26 = call zeroext i1 @sml_fuzzy_variable_set_default_term_width(ptr noundef %24, ptr noundef %25, float noundef 5.000000e-01)
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = call zeroext i1 @sml_set_read_state_callback(ptr noundef %27, ptr noundef @read_state_cb, ptr noundef null)
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = call zeroext i1 @sml_set_output_state_changed_callback(ptr noundef %29, ptr noundef @output_state_changed_cb, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %42, %2
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 150
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %45

35:                                               ; preds = %31
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = call i32 @sml_process(ptr noundef %36)
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %41

41:                                               ; preds = %39, %35
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %9, align 4, !tbaa !5
  br label %31, !llvm.loop !11

45:                                               ; preds = %34
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  call void @sml_free(ptr noundef %46)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  ret i32 0
}

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

declare ptr @sml_fuzzy_new() #2

declare ptr @sml_new_input(ptr noundef, ptr noundef) #2

declare zeroext i1 @sml_variable_set_range(ptr noundef, ptr noundef, float noundef, float noundef) #2

declare zeroext i1 @sml_fuzzy_variable_set_default_term_width(ptr noundef, ptr noundef, float noundef) #2

declare ptr @sml_new_output(ptr noundef, ptr noundef) #2

declare zeroext i1 @sml_set_read_state_callback(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @read_state_cb(ptr noundef, ptr noundef) #0

declare zeroext i1 @sml_set_output_state_changed_callback(ptr noundef, ptr noundef, ptr noundef) #2

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

declare i32 @sml_process(ptr noundef) #2

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

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

declare void @sml_free(ptr noundef) #2

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 = { "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 }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call ptr @sml_fuzzy_new() #3
  %4 = tail call ptr @sml_new_input(ptr noundef %3, ptr noundef nonnull @.str) #3
  %5 = tail call zeroext i1 @sml_variable_set_range(ptr noundef %3, ptr noundef %4, float noundef 0.000000e+00, float noundef 1.000000e+00) #3
  %6 = tail call zeroext i1 @sml_fuzzy_variable_set_default_term_width(ptr noundef %3, ptr noundef %4, float noundef 5.000000e-01) #3
  %7 = tail call ptr @sml_new_output(ptr noundef %3, ptr noundef nonnull @.str.1) #3
  %8 = tail call zeroext i1 @sml_variable_set_range(ptr noundef %3, ptr noundef %7, float noundef 0.000000e+00, float noundef 1.000000e+00) #3
  %9 = tail call zeroext i1 @sml_fuzzy_variable_set_default_term_width(ptr noundef %3, ptr noundef %7, float noundef 5.000000e-01) #3
  %10 = tail call zeroext i1 @sml_set_read_state_callback(ptr noundef %3, ptr noundef nonnull @read_state_cb, ptr noundef null) #3
  %11 = tail call zeroext i1 @sml_set_output_state_changed_callback(ptr noundef %3, ptr noundef nonnull @output_state_changed_cb, ptr noundef null) #3
  br label %13

12:                                               ; preds = %18
  tail call void @sml_free(ptr noundef %3) #3
  ret i32 0

13:                                               ; preds = %2, %18
  %.015 = phi i32 [ 0, %2 ], [ %19, %18 ]
  %14 = tail call i32 @sml_process(ptr noundef %3) #3
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %18

18:                                               ; preds = %13, %16
  %19 = add nuw nsw i32 %.015, 1
  %exitcond.not = icmp eq i32 %19, 150
  br i1 %exitcond.not, label %12, label %13, !llvm.loop !5
}

declare ptr @sml_fuzzy_new() local_unnamed_addr #1

declare ptr @sml_new_input(ptr noundef, ptr noundef) local_unnamed_addr #1

declare zeroext i1 @sml_variable_set_range(ptr noundef, ptr noundef, float noundef, float noundef) local_unnamed_addr #1

declare zeroext i1 @sml_fuzzy_variable_set_default_term_width(ptr noundef, ptr noundef, float noundef) local_unnamed_addr #1

declare ptr @sml_new_output(ptr noundef, ptr noundef) local_unnamed_addr #1

declare zeroext i1 @sml_set_read_state_callback(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @read_state_cb(ptr noundef, ptr noundef) #0

declare zeroext i1 @sml_set_output_state_changed_callback(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare i32 @sml_process(ptr noundef) local_unnamed_addr #1

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

declare void @sml_free(ptr noundef) local_unnamed_addr #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 = { "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 = { 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 #3 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass