; 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] }

@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
declare ptr @strcpy(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @add_insn(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7) #1 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store i32 %6, ptr %15, align 4, !tbaa !9
  store ptr %7, ptr %16, align 8, !tbaa !5
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %8
  br label %82

21:                                               ; preds = %8
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.basic_block, ptr %23, i32 0, i32 31
  store ptr %22, ptr %24, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %25 = load ptr, ptr @INSN_ARENA, align 8, !tbaa !5
  %26 = call ptr @arena_alloc(ptr noundef %25, i32 noundef 136)
  store ptr %26, ptr %17, align 8, !tbaa !5
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = load ptr, ptr %17, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.insn, ptr %28, i32 0, i32 3
  store i32 %27, ptr %29, align 4, !tbaa !15
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = load ptr, ptr %17, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.insn, ptr %31, i32 0, i32 4
  store ptr %30, ptr %32, align 8, !tbaa !17
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = load ptr, ptr %17, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.insn, ptr %34, i32 0, i32 5
  store ptr %33, ptr %35, align 8, !tbaa !18
  %36 = load ptr, ptr %14, align 8, !tbaa !5
  %37 = load ptr, ptr %17, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.insn, ptr %37, i32 0, i32 6
  store ptr %36, ptr %38, align 8, !tbaa !19
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = load ptr, ptr %17, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.insn, ptr %40, i32 0, i32 7
  store i32 %39, ptr %41, align 8, !tbaa !20
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load ptr, ptr %17, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.insn, ptr %43, i32 0, i32 9
  store ptr %42, ptr %44, align 8, !tbaa !21
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %53

47:                                               ; preds = %21
  %48 = load ptr, ptr %17, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.insn, ptr %48, i32 0, i32 11
  %50 = getelementptr inbounds [64 x i8], ptr %49, i64 0, i64 0
  %51 = load ptr, ptr %16, align 8, !tbaa !5
  %52 = call ptr @strcpy(ptr noundef %50, ptr noundef %51) #3
  br label %53

53:                                               ; preds = %47, %21
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.basic_block, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.insn_list_t, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !22
  %58 = icmp ne ptr %57, null
  br i1 %58, label %64, label %59

59:                                               ; preds = %53
  %60 = load ptr, ptr %17, align 8, !tbaa !5
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.basic_block, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds %struct.insn_list_t, ptr %62, i32 0, i32 0
  store ptr %60, ptr %63, align 8, !tbaa !22
  br label %71

64:                                               ; preds = %53
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.basic_block, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds %struct.insn_list_t, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = getelementptr inbounds %struct.insn, ptr %69, i32 0, i32 0
  store ptr %65, ptr %70, align 8, !tbaa !24
  br label %71

71:                                               ; preds = %64, %59
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.basic_block, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.insn_list_t, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !23
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.insn, ptr %76, i32 0, i32 1
  store ptr %75, ptr %77, align 8, !tbaa !25
  %78 = load ptr, ptr %17, align 8, !tbaa !5
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.basic_block, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.insn_list_t, ptr %80, i32 0, i32 1
  store ptr %78, ptr %81, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %82

82:                                               ; preds = %71, %20
  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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 31400}
!12 = !{!"basic_block", !13, i64 0, !13, 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, !10, i64 8536, !7, i64 8544, !10, i64 14944, !7, i64 14952, !10, i64 21352, !7, i64 21360, !10, i64 27760, !10, i64 27764, !10, i64 27768, !7, i64 27776, !7, i64 28288, !10, i64 28800, !10, i64 28804, !10, i64 28808, !14, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !13, i64 31408, !10, i64 31424}
!13 = !{!"", !6, i64 0, !6, i64 8}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !10, i64 20}
!16 = !{!"insn", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !14, i64 52, !6, i64 56, !6, i64 64, !7, i64 72}
!17 = !{!16, !6, i64 24}
!18 = !{!16, !6, i64 32}
!19 = !{!16, !6, i64 40}
!20 = !{!16, !10, i64 48}
!21 = !{!16, !6, i64 56}
!22 = !{!12, !6, i64 0}
!23 = !{!12, !6, i64 8}
!24 = !{!16, !6, i64 0}
!25 = !{!16, !6, i64 8}


; 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: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @add_insn(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef readonly %7) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %32, label %9

9:                                                ; preds = %8
  %10 = getelementptr inbounds i8, ptr %1, i64 31400
  store ptr %0, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr @INSN_ARENA, align 8, !tbaa !13
  %12 = tail call ptr @arena_alloc(ptr noundef %11, i32 noundef 136)
  %13 = getelementptr inbounds i8, ptr %12, i64 20
  store i32 %2, ptr %13, align 4, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %3, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %12, i64 32
  store ptr %4, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %12, i64 40
  store ptr %5, ptr %16, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %12, i64 48
  store i32 %6, ptr %17, align 8, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %12, i64 56
  store ptr %1, ptr %18, align 8, !tbaa !20
  %.not27 = icmp eq ptr %7, null
  br i1 %.not27, label %22, label %19

19:                                               ; preds = %9
  %20 = getelementptr inbounds i8, ptr %12, i64 72
  %21 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %20, ptr noundef nonnull dereferenceable(1) %7) #2
  br label %22

22:                                               ; preds = %19, %9
  %23 = load ptr, ptr %1, align 8, !tbaa !21
  %.not28 = icmp eq ptr %23, null
  br i1 %.not28, label %24, label %25

24:                                               ; preds = %22
  store ptr %12, ptr %1, align 8, !tbaa !21
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 8
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !22
  br label %28

25:                                               ; preds = %22
  %26 = getelementptr inbounds i8, ptr %1, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !22
  store ptr %12, ptr %27, align 8, !tbaa !23
  br label %28

28:                                               ; preds = %25, %24
  %29 = phi ptr [ %27, %25 ], [ %.pre, %24 ]
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  %31 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %29, ptr %31, align 8, !tbaa !24
  store ptr %12, ptr %30, align 8, !tbaa !22
  br label %32

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


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