; LLVM IR from BurntSushi/clibs :: libopt/examples (contrived)

; 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.anon = type { i8, i32, i32, double, ptr }
%struct.opt_args = type { i32, ptr }

@flags = external dso_local global %struct.anon, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [12 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 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 4, ptr %8) #3
  %9 = call ptr (...) @opt_config_init()
  store ptr %9, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !9
  call void @opt_flag_bool(ptr noundef %10, ptr noundef @flags, ptr noundef @.str, ptr noundef @.str.1)
  %11 = load ptr, ptr %6, align 8, !tbaa !9
  call void @opt_flag_int(ptr noundef %11, ptr noundef getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 1), ptr noundef @.str.2, i32 noundef 1, ptr noundef @.str.3)
  %12 = load ptr, ptr %6, align 8, !tbaa !9
  call void @opt_flag_int(ptr noundef %12, ptr noundef getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 2), ptr noundef @.str.4, i32 noundef 2, ptr noundef @.str.5)
  %13 = load ptr, ptr %6, align 8, !tbaa !9
  call void @opt_flag_double(ptr noundef %13, ptr noundef getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 3), ptr noundef @.str.6, double noundef 1.500000e+00, ptr noundef @.str.7)
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  call void @opt_flag_string(ptr noundef %14, ptr noundef getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 4), ptr noundef @.str.8, ptr noundef @.str.9, ptr noundef @.str.10)
  %15 = load ptr, ptr %6, align 8, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = call ptr @opt_config_parse(ptr noundef %15, i32 noundef %16, ptr noundef %17)
  store ptr %18, ptr %7, align 8, !tbaa !9
  %19 = load i8, ptr @flags, align 8, !tbaa !11, !range !15, !noundef !16
  %20 = trunc i8 %19 to i1
  %21 = zext i1 %20 to i32
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %21)
  %23 = load i32, ptr getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 1), align 4, !tbaa !17
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %23)
  %25 = load i32, ptr getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 2), align 8, !tbaa !18
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %25)
  %27 = load double, ptr getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 3), align 8, !tbaa !19
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, double noundef %27)
  %29 = load ptr, ptr getelementptr inbounds (%struct.anon, ptr @flags, i32 0, i32 4), align 8, !tbaa !20
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, ptr noundef %29)
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.opt_args, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !21
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, i32 noundef %34)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %52, %2
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.opt_args, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !21
  %41 = icmp slt i32 %37, %40
  br i1 %41, label %42, label %55

42:                                               ; preds = %36
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.opt_args, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !23
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds ptr, ptr %46, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, i32 noundef %43, ptr noundef %50)
  br label %52

52:                                               ; preds = %42
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %8, align 4, !tbaa !5
  br label %36, !llvm.loop !24

55:                                               ; preds = %36
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  call void @opt_config_free(ptr noundef %56)
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  call void @opt_args_free(ptr noundef %57)
  call void @llvm.lifetime.end.p0(i64 4, 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 @opt_config_init(...) #2

declare void @opt_flag_bool(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @opt_flag_int(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare void @opt_flag_double(ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef) #2

declare void @opt_flag_string(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @opt_config_parse(ptr noundef, i32 noundef, ptr noundef) #2

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

declare void @opt_config_free(ptr noundef) #2

declare void @opt_args_free(ptr noundef) #2

; 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 = { "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 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !6, i64 4, !6, i64 8, !14, i64 16, !10, i64 24}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !6, i64 4}
!18 = !{!12, !6, i64 8}
!19 = !{!12, !14, i64 16}
!20 = !{!12, !10, i64 24}
!21 = !{!22, !6, i64 0}
!22 = !{!"opt_args", !6, i64 0, !10, i64 8}
!23 = !{!22, !10, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"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"

%struct.anon = type { i8, i32, i32, double, ptr }

@flags = external dso_local global %struct.anon, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr (...) @opt_config_init() #3
  tail call void @opt_flag_bool(ptr noundef %3, ptr noundef nonnull @flags, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #3
  tail call void @opt_flag_int(ptr noundef %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @flags, i64 4), ptr noundef nonnull @.str.2, i32 noundef 1, ptr noundef nonnull @.str.3) #3
  tail call void @opt_flag_int(ptr noundef %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @flags, i64 8), ptr noundef nonnull @.str.4, i32 noundef 2, ptr noundef nonnull @.str.5) #3
  tail call void @opt_flag_double(ptr noundef %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @flags, i64 16), ptr noundef nonnull @.str.6, double noundef 1.500000e+00, ptr noundef nonnull @.str.7) #3
  tail call void @opt_flag_string(ptr noundef %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @flags, i64 24), ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.10) #3
  %4 = tail call ptr @opt_config_parse(ptr noundef %3, i32 noundef %0, ptr noundef %1) #3
  %5 = load i8, ptr @flags, align 8, !tbaa !5, !range !13, !noundef !14
  %6 = zext nneg i8 %5 to i32
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %6)
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @flags, i64 4), align 4, !tbaa !15
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %8)
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @flags, i64 8), align 8, !tbaa !16
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %10)
  %12 = load double, ptr getelementptr inbounds (i8, ptr @flags, i64 16), align 8, !tbaa !17
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, double noundef %12)
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @flags, i64 24), align 8, !tbaa !18
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef %14)
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %17 = load i32, ptr %4, align 8, !tbaa !19
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, i32 noundef %17)
  %19 = load i32, ptr %4, align 8, !tbaa !19
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %21 = getelementptr inbounds i8, ptr %4, i64 8
  br label %22

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %23 = load ptr, ptr %21, align 8, !tbaa !21
  %24 = getelementptr inbounds ptr, ptr %23, i64 %indvars.iv
  %25 = load ptr, ptr %24, align 8, !tbaa !22
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18, i32 noundef %26, ptr noundef %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %4, align 8, !tbaa !19
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next, %29
  br i1 %30, label %22, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %22, %2
  tail call void @opt_config_free(ptr noundef %3) #3
  tail call void @opt_args_free(ptr noundef nonnull %4) #3
  ret i32 0
}

declare ptr @opt_config_init(...) local_unnamed_addr #1

declare void @opt_flag_bool(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @opt_flag_int(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @opt_flag_double(ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

declare void @opt_flag_string(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

declare void @opt_config_free(ptr noundef) local_unnamed_addr #1

declare void @opt_args_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 = !{!6, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 4, !10, i64 8, !11, i64 16, !12, i64 24}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !10, i64 4}
!16 = !{!6, !10, i64 8}
!17 = !{!6, !11, i64 16}
!18 = !{!6, !12, i64 24}
!19 = !{!20, !10, i64 0}
!20 = !{!"opt_args", !10, i64 0, !12, i64 8}
!21 = !{!20, !12, i64 8}
!22 = !{!12, !12, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass