; 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.insn = type { ptr, ptr, i32, i32, ptr, ptr, ptr, i32, i8, ptr, ptr, [64 x i8] }
%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 }

@INSN_ARENA = external dso_local global ptr, align 8

; 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 ptr @arena_alloc(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @append_unwound_phi_insn(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr @INSN_ARENA, align 8, !tbaa !5
  %10 = call ptr @arena_alloc(ptr noundef %9, i32 noundef 136)
  store ptr %10, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.insn, ptr %11, i32 0, i32 3
  store i32 2, ptr %12, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.insn, ptr %14, i32 0, i32 4
  store ptr %13, ptr %15, align 8, !tbaa !13
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.insn, ptr %17, i32 0, i32 5
  store ptr %16, ptr %18, align 8, !tbaa !14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.insn, ptr %20, i32 0, i32 9
  store ptr %19, ptr %21, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.basic_block, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.insn_list_t, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  store ptr %25, ptr %8, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %37, label %28

28:                                               ; preds = %3
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.basic_block, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.insn_list_t, ptr %31, i32 0, i32 0
  store ptr %29, ptr %32, align 8, !tbaa !19
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.basic_block, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.insn_list_t, ptr %35, i32 0, i32 1
  store ptr %33, ptr %36, align 8, !tbaa !16
  br label %79

37:                                               ; preds = %3
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.insn, ptr %38, i32 0, i32 3
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 13
  br i1 %41, label %42, label %70

42:                                               ; preds = %37
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.insn, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %58

47:                                               ; preds = %42
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.insn, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = getelementptr inbounds %struct.insn, ptr %51, i32 0, i32 0
  store ptr %48, ptr %52, align 8, !tbaa !21
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.insn, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.insn, ptr %56, i32 0, i32 1
  store ptr %55, ptr %57, align 8, !tbaa !20
  br label %63

58:                                               ; preds = %42
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.basic_block, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.insn_list_t, ptr %61, i32 0, i32 0
  store ptr %59, ptr %62, align 8, !tbaa !19
  br label %63

63:                                               ; preds = %58, %47
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.insn, ptr %65, i32 0, i32 0
  store ptr %64, ptr %66, align 8, !tbaa !21
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.insn, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !20
  br label %78

70:                                               ; preds = %37
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.insn, ptr %72, i32 0, i32 0
  store ptr %71, ptr %73, align 8, !tbaa !21
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.basic_block, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct.insn_list_t, ptr %76, i32 0, i32 1
  store ptr %74, ptr %77, align 8, !tbaa !16
  br label %78

78:                                               ; preds = %70, %63
  br label %79

79:                                               ; preds = %78, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  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, !11, i64 20}
!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 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 32}
!15 = !{!10, !6, i64 56}
!16 = !{!17, !6, i64 8}
!17 = !{!"basic_block", !18, i64 0, !18, 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, !18, i64 31408, !11, i64 31424}
!18 = !{!"", !6, i64 0, !6, i64 8}
!19 = !{!17, !6, i64 0}
!20 = !{!10, !6, i64 8}
!21 = !{!10, !6, 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"

@INSN_ARENA = external dso_local local_unnamed_addr global ptr, align 8

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

; Function Attrs: nounwind uwtable
define dso_local void @append_unwound_phi_insn(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr @INSN_ARENA, align 8, !tbaa !5
  %5 = tail call ptr @arena_alloc(ptr noundef %4, i32 noundef 136)
  %6 = getelementptr inbounds i8, ptr %5, i64 20
  store i32 2, ptr %6, align 4, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %1, ptr %7, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %2, ptr %8, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr %0, ptr %9, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %12, label %13

12:                                               ; preds = %3
  store ptr %5, ptr %0, align 8, !tbaa !19
  br label %25

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %11, i64 20
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp eq i32 %15, 13
  br i1 %16, label %17, label %24

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %11, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %.not30 = icmp eq ptr %19, null
  br i1 %.not30, label %22, label %20

20:                                               ; preds = %17
  store ptr %5, ptr %19, align 8, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %19, ptr %21, align 8, !tbaa !20
  br label %23

22:                                               ; preds = %17
  store ptr %5, ptr %0, align 8, !tbaa !19
  br label %23

23:                                               ; preds = %22, %20
  store ptr %11, ptr %5, align 8, !tbaa !21
  br label %25

24:                                               ; preds = %13
  store ptr %5, ptr %11, align 8, !tbaa !21
  br label %25

25:                                               ; preds = %23, %24, %12
  %.sink = phi ptr [ %18, %23 ], [ %10, %24 ], [ %10, %12 ]
  store ptr %5, ptr %.sink, align 8, !tbaa !5
  ret void
}

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, !11, i64 20}
!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 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 32}
!15 = !{!10, !6, i64 56}
!16 = !{!17, !6, i64 8}
!17 = !{!"basic_block", !18, i64 0, !18, 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, !18, i64 31408, !11, i64 31424}
!18 = !{!"", !6, i64 0, !6, i64 8}
!19 = !{!17, !6, i64 0}
!20 = !{!10, !6, i64 8}
!21 = !{!10, !6, i64 0}


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