; LLVM IR from thunlp/SE-WRL :: word2vec (word2phrase)

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

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @ReadWord(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  br label %8

8:                                                ; preds = %60, %45, %18, %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call i32 @feof(ptr noundef %9) #4
  %11 = icmp ne i32 %10, 0
  %12 = xor i1 %11, true
  br i1 %12, label %13, label %61

13:                                               ; preds = %8
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call i32 @fgetc(ptr noundef %14)
  store i32 %15, ptr %6, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 13
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  br label %8, !llvm.loop !11

19:                                               ; preds = %13
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 32
  br i1 %21, label %28, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 9
  br i1 %24, label %28, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 10
  br i1 %27, label %28, label %46

28:                                               ; preds = %25, %22, %19
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %31, label %39

31:                                               ; preds = %28
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 10
  br i1 %33, label %34, label %38

34:                                               ; preds = %31
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call i32 @ungetc(i32 noundef %35, ptr noundef %36)
  br label %38

38:                                               ; preds = %34, %31
  br label %61

39:                                               ; preds = %28
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 10
  br i1 %41, label %42, label %45

42:                                               ; preds = %39
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = call ptr @strcpy(ptr noundef %43, ptr noundef @.str) #4
  store i32 1, ptr %7, align 4
  br label %66

45:                                               ; preds = %39
  br label %8, !llvm.loop !11

46:                                               ; preds = %25
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %49, i64 %51
  store i8 %48, ptr %52, align 1, !tbaa !13
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !9
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = icmp sge i32 %55, 59
  br i1 %56, label %57, label %60

57:                                               ; preds = %46
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr %5, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %57, %46
  br label %8, !llvm.loop !11

61:                                               ; preds = %38, %8
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  store i8 0, ptr %65, align 1, !tbaa !13
  store i32 0, ptr %7, align 4
  br label %66

66:                                               ; preds = %61, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %67 = load i32, ptr %7, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

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

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #2

declare i32 @fgetc(ptr noundef) #3

declare i32 @ungetc(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, 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"

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @ReadWord(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @feof(ptr noundef %1) #3
  %.not3246 = icmp eq i32 %3, 0
  br i1 %.not3246, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %2, %.outer
  %.0.ph47 = phi i32 [ %spec.select, %.outer ], [ 0, %2 ]
  %.not49 = icmp eq i32 %.0.ph47, 0
  br i1 %.not49, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.backedge.us
  %4 = tail call i32 @fgetc(ptr noundef %1)
  switch i32 %4, label %.outer [
    i32 13, label %.backedge.us
    i32 10, label %8
    i32 9, label %.loopexit
    i32 32, label %.loopexit
  ]

.backedge.us:                                     ; preds = %.lr.ph.split.us
  %5 = tail call i32 @feof(ptr noundef %1) #3
  %.not.us = icmp eq i32 %5, 0
  br i1 %.not.us, label %.lr.ph.split.us, label %.loopexit, !llvm.loop !5

.lr.ph.split:                                     ; preds = %.lr.ph, %.backedge
  %6 = tail call i32 @fgetc(ptr noundef %1)
  switch i32 %6, label %.outer [
    i32 13, label %.backedge
    i32 10, label %10
    i32 9, label %.backedge
    i32 32, label %.backedge
  ]

.backedge:                                        ; preds = %.lr.ph.split, %.lr.ph.split, %.lr.ph.split
  %7 = tail call i32 @feof(ptr noundef %1) #3
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.lr.ph.split, label %.loopexit, !llvm.loop !5

8:                                                ; preds = %.lr.ph.split.us
  %9 = tail call i32 @ungetc(i32 noundef 10, ptr noundef %1)
  br label %.loopexit

10:                                               ; preds = %.lr.ph.split
  %11 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str) #3
  br label %20

.outer:                                           ; preds = %.lr.ph.split.us, %.lr.ph.split
  %.us-phi = phi i32 [ %6, %.lr.ph.split ], [ %4, %.lr.ph.split.us ]
  %12 = trunc i32 %.us-phi to i8
  %13 = sext i32 %.0.ph47 to i64
  %14 = getelementptr inbounds i8, ptr %0, i64 %13
  store i8 %12, ptr %14, align 1, !tbaa !7
  %15 = icmp slt i32 %.0.ph47, 58
  %16 = zext i1 %15 to i32
  %spec.select = add i32 %.0.ph47, %16
  %17 = tail call i32 @feof(ptr noundef %1) #3
  %.not32 = icmp eq i32 %17, 0
  br i1 %.not32, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %.outer, %.backedge.us, %.lr.ph.split.us, %.lr.ph.split.us, %.backedge, %2, %8
  %.0.ph31 = phi i32 [ %.0.ph47, %8 ], [ 0, %2 ], [ 0, %.backedge ], [ %.0.ph47, %.lr.ph.split.us ], [ %.0.ph47, %.lr.ph.split.us ], [ %.0.ph47, %.backedge.us ], [ %spec.select, %.outer ]
  %18 = sext i32 %.0.ph31 to i64
  %19 = getelementptr inbounds i8, ptr %0, i64 %18
  store i8 0, ptr %19, align 1, !tbaa !7
  br label %20

20:                                               ; preds = %.loopexit, %10
  ret void
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @ungetc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #1

; 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 #2

attributes #0 = { nofree 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 = { 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 #2 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


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