; LLVM IR from sysprog21/shecc :: src (ssa)

; 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.func_list_t = type { ptr, ptr }
%struct.func = type { %struct.var, [8 x %struct.var], i32, i32, i32, ptr, ptr, %struct.symbol_list_t, i32, i32, ptr }
%struct.var = type { [32 x i8], [32 x i8], i32, i8, i8, i32, i32, i32, i32, i32, ptr, i32, [64 x ptr], i32, %struct.rename_t, %struct.ref_block_list, ptr, ptr, ptr, i32, i8, i8, i8 }
%struct.rename_t = type { i32, [64 x i32], i32 }
%struct.ref_block_list = type { ptr, ptr }
%struct.symbol_list_t = type { ptr, ptr }

@FUNC_LIST = external dso_local global %struct.func_list_t, align 8
@.str.88 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.118 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.125 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [18 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

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

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

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

declare i32 @fclose(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @dump_dom(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = call noalias ptr @fopen(ptr noundef %5, ptr noundef @.str.119)
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef @.str.125) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef @.str.121) #4
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str.126) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %13 = load ptr, ptr @FUNC_LIST, align 8, !tbaa !9
  store ptr %13, ptr %4, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %31, %1
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %35

18:                                               ; preds = %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.88, ptr noundef %20) #4
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.122, ptr noundef %23) #4
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.func, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  call void @dom_dump(ptr noundef %25, ptr noundef %28)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.118) #4
  br label %31

31:                                               ; preds = %18
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.func, ptr %32, i32 0, i32 10
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  store ptr %34, ptr %4, align 8, !tbaa !5
  br label %14, !llvm.loop !19

35:                                               ; preds = %17
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.118) #4
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call i32 @fclose(ptr noundef %38)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 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 #4 = { 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"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 8}
!11 = !{!12, !6, i64 8512}
!12 = !{!"func", !13, i64 0, !7, i64 944, !14, i64 8496, !14, i64 8500, !14, i64 8504, !6, i64 8512, !6, i64 8520, !10, i64 8528, !14, i64 8544, !14, i64 8548, !6, i64 8552}
!13 = !{!"var", !7, i64 0, !7, i64 32, !14, i64 64, !15, i64 68, !15, i64 69, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !6, i64 96, !14, i64 104, !7, i64 112, !14, i64 624, !16, i64 628, !17, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !14, i64 936, !15, i64 940, !15, i64 941, !15, i64 942}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !14, i64 0, !7, i64 4, !14, i64 260}
!17 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!18 = !{!12, !6, i64 8552}
!19 = distinct !{!19, !20}
!20 = !{!"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.func_list_t = type { ptr, ptr }

@FUNC_LIST = external dso_local local_unnamed_addr global %struct.func_list_t, align 8
@.str.88 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.118 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.125 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [18 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @dom_dump(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @dump_dom(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.119)
  %3 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.125) #2
  %4 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.121) #2
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.126) #2
  %.015 = load ptr, ptr @FUNC_LIST, align 8, !tbaa !5
  %.not16 = icmp eq ptr %.015, null
  br i1 %.not16, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.118) #2
  %7 = tail call i32 @fclose(ptr noundef %2)
  ret void

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.017 = phi ptr [ %.0, %.lr.ph ], [ %.015, %1 ]
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.88, ptr noundef nonnull %.017) #2
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.122, ptr noundef nonnull %.017) #2
  %10 = getelementptr inbounds i8, ptr %.017, i64 8512
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  tail call void @dom_dump(ptr noundef %2, ptr noundef %11)
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.118) #2
  %13 = getelementptr inbounds i8, ptr %.017, i64 8552
  %.0 = load ptr, ptr %13, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17
}

attributes #0 = { 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 #1 = { 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 #2 = { 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"}
!9 = !{!10, !6, i64 8512}
!10 = !{!"func", !11, i64 0, !7, i64 944, !12, i64 8496, !12, i64 8500, !12, i64 8504, !6, i64 8512, !6, i64 8520, !16, i64 8528, !12, i64 8544, !12, i64 8548, !6, i64 8552}
!11 = !{!"var", !7, i64 0, !7, i64 32, !12, i64 64, !13, i64 68, !13, i64 69, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !6, i64 96, !12, i64 104, !7, i64 112, !12, i64 624, !14, i64 628, !15, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !12, i64 936, !13, i64 940, !13, i64 941, !13, i64 942}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"", !12, i64 0, !7, i64 4, !12, i64 260}
!15 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!16 = !{!"", !6, i64 0, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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