; 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.block = type { [1600 x %struct.var], i32, ptr, ptr, ptr, 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.func = type { %struct.var, [8 x %struct.var], i32, i32, i32, ptr, ptr, %struct.symbol_list_t, i32, i32, ptr }
%struct.symbol_list_t = type { ptr, ptr }

; 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 willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

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

13:                                               ; preds = %48, %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %52

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %17

17:                                               ; preds = %42, %16
  %18 = load i32, ptr %7, align 4, !tbaa !12
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.block, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = icmp slt i32 %18, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  store i32 5, ptr %8, align 4
  br label %45

24:                                               ; preds = %17
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.block, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %7, align 4, !tbaa !12
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1600 x %struct.var], ptr %26, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.var, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds [32 x i8], ptr %30, i64 0, i64 0
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call i32 @strcmp(ptr noundef %31, ptr noundef %32) #4
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %41, label %35

35:                                               ; preds = %24
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.block, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %7, align 4, !tbaa !12
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1600 x %struct.var], ptr %37, i64 0, i64 %39
  store ptr %40, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %45

41:                                               ; preds = %24
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %7, align 4, !tbaa !12
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %7, align 4, !tbaa !12
  br label %17, !llvm.loop !14

45:                                               ; preds = %35, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %46 = load i32, ptr %8, align 4
  switch i32 %46, label %88 [
    i32 5, label %47
  ]

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.block, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  store ptr %51, ptr %5, align 8, !tbaa !5
  br label %13, !llvm.loop !17

52:                                               ; preds = %13
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %87

55:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !12
  br label %56

56:                                               ; preds = %81, %55
  %57 = load i32, ptr %9, align 4, !tbaa !12
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.func, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 8, !tbaa !18
  %61 = icmp slt i32 %57, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %56
  store i32 8, ptr %8, align 4
  br label %84

63:                                               ; preds = %56
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.func, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %9, align 4, !tbaa !12
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [8 x %struct.var], ptr %65, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.var, ptr %68, i32 0, i32 1
  %70 = getelementptr inbounds [32 x i8], ptr %69, i64 0, i64 0
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = call i32 @strcmp(ptr noundef %70, ptr noundef %71) #4
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %80, label %74

74:                                               ; preds = %63
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.func, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %9, align 4, !tbaa !12
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [8 x %struct.var], ptr %76, i64 0, i64 %78
  store ptr %79, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %84

80:                                               ; preds = %63
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %9, align 4, !tbaa !12
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %9, align 4, !tbaa !12
  br label %56, !llvm.loop !25

84:                                               ; preds = %74, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %85 = load i32, ptr %8, align 4
  switch i32 %85, label %88 [
    i32 8, label %86
  ]

86:                                               ; preds = %84
  br label %87

87:                                               ; preds = %86, %52
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %88

88:                                               ; preds = %87, %84, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %89 = load ptr, ptr %3, align 8
  ret ptr %89
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 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 #3 = { nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!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 1510416}
!10 = !{!"block", !7, i64 0, !11, i64 1510400, !6, i64 1510408, !6, i64 1510416, !6, i64 1510424, !11, i64 1510432, !6, i64 1510440}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 1510400}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !6, i64 1510408}
!17 = distinct !{!17, !15}
!18 = !{!19, !11, i64 8496}
!19 = !{!"func", !20, i64 0, !7, i64 944, !11, i64 8496, !11, i64 8500, !11, i64 8504, !6, i64 8512, !6, i64 8520, !24, i64 8528, !11, i64 8544, !11, i64 8548, !6, i64 8552}
!20 = !{!"var", !7, i64 0, !7, i64 32, !11, i64 64, !21, i64 68, !21, i64 69, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !11, i64 104, !7, i64 112, !11, i64 624, !22, i64 628, !23, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !11, i64 936, !21, i64 940, !21, i64 941, !21, i64 942}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!"", !11, i64 0, !7, i64 4, !11, i64 260}
!23 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!24 = !{!"", !6, i64 0, !6, i64 8}
!25 = distinct !{!25, !15}


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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find_local_var(ptr nocapture noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #1 {
.preheader37.preheader:
  %2 = getelementptr inbounds i8, ptr %1, i64 1510416
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  br label %.preheader37

.preheader37:                                     ; preds = %.preheader37.preheader, %._crit_edge
  %.02742 = phi ptr [ %11, %._crit_edge ], [ %1, %.preheader37.preheader ]
  %4 = getelementptr inbounds i8, ptr %.02742, i64 1510400
  %5 = load i32, ptr %4, align 8, !tbaa !11
  %.not3339 = icmp sgt i32 %5, 0
  br i1 %.not3339, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader37
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %.lr.ph

6:                                                ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %.lr.ph.preheader, %6
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %6 ]
  %7 = getelementptr inbounds [1600 x %struct.var], ptr %.02742, i64 0, i64 %indvars.iv
  %8 = getelementptr inbounds i8, ptr %7, i64 32
  %9 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %0) #2
  %.not32 = icmp eq i32 %9, 0
  br i1 %.not32, label %.thread, label %6

._crit_edge:                                      ; preds = %6, %.preheader37
  %10 = getelementptr inbounds i8, ptr %.02742, i64 1510408
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %._crit_edge43, label %.preheader37, !llvm.loop !15

._crit_edge43:                                    ; preds = %._crit_edge
  %.not29 = icmp eq ptr %3, null
  br i1 %.not29, label %.thread, label %.preheader

.preheader:                                       ; preds = %._crit_edge43
  %12 = getelementptr inbounds i8, ptr %3, i64 944
  %13 = getelementptr inbounds i8, ptr %3, i64 8496
  %14 = load i32, ptr %13, align 8, !tbaa !16
  %.not3144 = icmp sgt i32 %14, 0
  br i1 %.not3144, label %.lr.ph46.preheader, label %.thread

.lr.ph46.preheader:                               ; preds = %.preheader
  %wide.trip.count55 = zext nneg i32 %14 to i64
  br label %.lr.ph46

15:                                               ; preds = %.lr.ph46
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next53, %wide.trip.count55
  br i1 %exitcond56.not, label %.thread, label %.lr.ph46, !llvm.loop !23

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %15
  %indvars.iv52 = phi i64 [ 0, %.lr.ph46.preheader ], [ %indvars.iv.next53, %15 ]
  %16 = getelementptr inbounds [8 x %struct.var], ptr %12, i64 0, i64 %indvars.iv52
  %17 = getelementptr inbounds i8, ptr %16, i64 32
  %18 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %17, ptr noundef nonnull dereferenceable(1) %0) #2
  %.not30 = icmp eq i32 %18, 0
  br i1 %.not30, label %.thread, label %15

.thread:                                          ; preds = %.lr.ph, %15, %.lr.ph46, %.preheader, %._crit_edge43
  %.3 = phi ptr [ null, %._crit_edge43 ], [ null, %.preheader ], [ null, %15 ], [ %16, %.lr.ph46 ], [ %7, %.lr.ph ]
  ret ptr %.3
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nofree nounwind memory(read, inaccessiblemem: none) 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 willreturn memory(read) }

!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, !10, i64 1510416}
!6 = !{!"block", !7, i64 0, !9, i64 1510400, !10, i64 1510408, !10, i64 1510416, !10, i64 1510424, !9, i64 1510432, !10, i64 1510440}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !9, i64 1510400}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !10, i64 1510408}
!15 = distinct !{!15, !13}
!16 = !{!17, !9, i64 8496}
!17 = !{!"func", !18, i64 0, !7, i64 944, !9, i64 8496, !9, i64 8500, !9, i64 8504, !10, i64 8512, !10, i64 8520, !22, i64 8528, !9, i64 8544, !9, i64 8548, !10, i64 8552}
!18 = !{!"var", !7, i64 0, !7, i64 32, !9, i64 64, !19, i64 68, !19, i64 69, !9, i64 72, !9, i64 76, !9, i64 80, !9, i64 84, !9, i64 88, !10, i64 96, !9, i64 104, !7, i64 112, !9, i64 624, !20, i64 628, !21, i64 896, !10, i64 912, !10, i64 920, !10, i64 928, !9, i64 936, !19, i64 940, !19, i64 941, !19, i64 942}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{!"", !9, i64 0, !7, i64 4, !9, i64 260}
!21 = !{!"ref_block_list", !10, i64 0, !10, i64 8}
!22 = !{!"", !10, i64 0, !10, i64 8}
!23 = distinct !{!23, !13}


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