; 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.basic_block = type { %struct.insn_list_t, %struct.ph2_ir_list_t, [128 x %struct.bb_connection_t], ptr, ptr, ptr, ptr, ptr, ptr, ptr, [800 x ptr], i32, [800 x ptr], i32, [800 x ptr], i32, [800 x ptr], i32, i32, i32, [64 x ptr], [64 x ptr], i32, i32, i32, i8, [64 x ptr], ptr, [256 x ptr], ptr, ptr, ptr, %struct.symbol_list_t, i32 }
%struct.insn_list_t = type { ptr, ptr }
%struct.ph2_ir_list_t = type { ptr, ptr }
%struct.bb_connection_t = type { ptr, i32 }
%struct.symbol_list_t = type { ptr, ptr }
%struct.insn = type { ptr, ptr, i32, i32, ptr, ptr, ptr, i32, i8, ptr, ptr, [64 x i8] }

; 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 uwtable
declare dso_local zeroext i1 @var_check_killed(ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @bb_solve_globals(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.basic_block, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds %struct.insn_list_t, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %10, ptr %5, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %68, %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %72

15:                                               ; preds = %11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.insn, ptr %16, i32 0, i32 5
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %34

20:                                               ; preds = %15
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.insn, ptr %21, i32 0, i32 5
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call zeroext i1 @var_check_killed(ptr noundef %23, ptr noundef %24)
  br i1 %25, label %33, label %26

26:                                               ; preds = %20
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.basic_block, ptr %27, i32 0, i32 30
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.insn, ptr %30, i32 0, i32 5
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  call void @fn_add_global(ptr noundef %29, ptr noundef %32)
  br label %33

33:                                               ; preds = %26, %20
  br label %34

34:                                               ; preds = %33, %15
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.insn, ptr %35, i32 0, i32 6
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %53

39:                                               ; preds = %34
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.insn, ptr %40, i32 0, i32 6
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call zeroext i1 @var_check_killed(ptr noundef %42, ptr noundef %43)
  br i1 %44, label %52, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.basic_block, ptr %46, i32 0, i32 30
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.insn, ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  call void @fn_add_global(ptr noundef %48, ptr noundef %51)
  br label %52

52:                                               ; preds = %45, %39
  br label %53

53:                                               ; preds = %52, %34
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.insn, ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %67

58:                                               ; preds = %53
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.insn, ptr %60, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !18
  call void @bb_add_killed_var(ptr noundef %59, ptr noundef %62)
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.insn, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !18
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  call void @var_add_killed_bb(ptr noundef %65, ptr noundef %66)
  br label %67

67:                                               ; preds = %58, %53
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.insn, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  store ptr %71, ptr %5, align 8, !tbaa !5
  br label %11, !llvm.loop !20

72:                                               ; preds = %14
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 0}
!10 = !{!"basic_block", !11, i64 0, !11, i64 16, !7, i64 32, !6, i64 2080, !6, i64 2088, !6, i64 2096, !6, i64 2104, !6, i64 2112, !6, i64 2120, !6, i64 2128, !7, i64 2136, !12, i64 8536, !7, i64 8544, !12, i64 14944, !7, i64 14952, !12, i64 21352, !7, i64 21360, !12, i64 27760, !12, i64 27764, !12, i64 27768, !7, i64 27776, !7, i64 28288, !12, i64 28800, !12, i64 28804, !12, i64 28808, !13, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !11, i64 31408, !12, i64 31424}
!11 = !{!"", !6, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!15, !6, i64 32}
!15 = !{!"insn", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !13, i64 52, !6, i64 56, !6, i64 64, !7, i64 72}
!16 = !{!10, !6, i64 31392}
!17 = !{!15, !6, i64 40}
!18 = !{!15, !6, i64 24}
!19 = !{!15, !6, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @var_check_killed(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @bb_solve_globals(ptr nocapture noundef readnone %0, ptr noundef %1) local_unnamed_addr #0 {
  %.025 = load ptr, ptr %1, align 8, !tbaa !5
  %.not26 = icmp eq ptr %.025, null
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %3 = getelementptr inbounds i8, ptr %1, i64 31392
  br label %4

._crit_edge:                                      ; preds = %25, %2
  ret void

4:                                                ; preds = %.lr.ph, %25
  %.027 = phi ptr [ %.025, %.lr.ph ], [ %.0, %25 ]
  %5 = getelementptr inbounds i8, ptr %.027, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %.not22 = icmp eq ptr %6, null
  br i1 %.not22, label %12, label %7

7:                                                ; preds = %4
  %8 = tail call zeroext i1 @var_check_killed(ptr noundef nonnull %6, ptr noundef nonnull %1)
  br i1 %8, label %12, label %9

9:                                                ; preds = %7
  %10 = load ptr, ptr %3, align 8, !tbaa !13
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  tail call void @fn_add_global(ptr noundef %10, ptr noundef %11)
  br label %12

12:                                               ; preds = %7, %9, %4
  %13 = getelementptr inbounds i8, ptr %.027, i64 40
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %.not23 = icmp eq ptr %14, null
  br i1 %.not23, label %20, label %15

15:                                               ; preds = %12
  %16 = tail call zeroext i1 @var_check_killed(ptr noundef nonnull %14, ptr noundef nonnull %1)
  br i1 %16, label %20, label %17

17:                                               ; preds = %15
  %18 = load ptr, ptr %3, align 8, !tbaa !13
  %19 = load ptr, ptr %13, align 8, !tbaa !16
  tail call void @fn_add_global(ptr noundef %18, ptr noundef %19)
  br label %20

20:                                               ; preds = %15, %17, %12
  %21 = getelementptr inbounds i8, ptr %.027, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %.not24 = icmp eq ptr %22, null
  br i1 %.not24, label %25, label %23

23:                                               ; preds = %20
  tail call void @bb_add_killed_var(ptr noundef nonnull %1, ptr noundef nonnull %22)
  %24 = load ptr, ptr %21, align 8, !tbaa !17
  tail call void @var_add_killed_bb(ptr noundef %24, ptr noundef nonnull %1)
  br label %25

25:                                               ; preds = %20, %23
  %.0 = load ptr, ptr %.027, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %4, !llvm.loop !18
}

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

!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 32}
!10 = !{!"insn", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !7, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 31392}
!14 = !{!"basic_block", !15, i64 0, !15, i64 16, !7, i64 32, !6, i64 2080, !6, i64 2088, !6, i64 2096, !6, i64 2104, !6, i64 2112, !6, i64 2120, !6, i64 2128, !7, i64 2136, !11, i64 8536, !7, i64 8544, !11, i64 14944, !7, i64 14952, !11, i64 21352, !7, i64 21360, !11, i64 27760, !11, i64 27764, !11, i64 27768, !7, i64 27776, !7, i64 28288, !11, i64 28800, !11, i64 28804, !11, i64 28808, !12, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !15, i64 31408, !11, i64 31424}
!15 = !{!"", !6, i64 0, !6, i64 8}
!16 = !{!10, !6, i64 40}
!17 = !{!10, !6, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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