; LLVM IR from quarkslab/crypto-condor :: crypto_condor/primitives/_testu01/mylib (tcode)

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

@Line = external hidden global [256 x i8], align 16
@fin = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@L1 = external hidden global i64, align 8
@fout = external hidden global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

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

11:                                               ; preds = %40, %2
  %12 = load ptr, ptr @fin, align 8, !tbaa !9
  %13 = call ptr @fgets(ptr noundef @Line, i32 noundef 255, ptr noundef %12)
  %14 = icmp ne ptr null, %13
  br i1 %14, label %15, label %41

15:                                               ; preds = %11
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  %19 = call i32 @ProcessLine(ptr noundef @Line)
  store i32 %19, ptr %8, align 4, !tbaa !5
  br label %40

20:                                               ; preds = %15
  %21 = call ptr @strstr(ptr noundef @Line, ptr noundef @.str) #6
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %39

24:                                               ; preds = %20
  %25 = call ptr @strstr(ptr noundef @Line, ptr noundef @.str.1) #6
  store ptr %25, ptr %6, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %38

27:                                               ; preds = %24
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  store i8 0, ptr %28, align 1, !tbaa !11
  %29 = call ptr @strchr(ptr noundef @Line, i32 noundef 37) #6
  store ptr %29, ptr %7, align 8, !tbaa !9
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = icmp eq ptr null, %30
  br i1 %31, label %32, label %37

32:                                               ; preds = %27
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = load i64, ptr @L1, align 8, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %33, i64 %34
  %36 = call i32 @ProcessLine(ptr noundef %35)
  store i32 %36, ptr %8, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %32, %27
  br label %38

38:                                               ; preds = %37, %24
  br label %39

39:                                               ; preds = %38, %23
  br label %40

40:                                               ; preds = %39, %18
  br label %11, !llvm.loop !14

41:                                               ; preds = %11
  %42 = load ptr, ptr @fout, align 8, !tbaa !9
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.2) #5
  %44 = load ptr, ptr @fout, align 8, !tbaa !9
  %45 = call i32 @fclose(ptr noundef %44)
  %46 = load ptr, ptr @fin, align 8, !tbaa !9
  %47 = call i32 @fclose(ptr noundef %46)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret i32 0
}

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

; Function Attrs: nounwind uwtable
declare hidden void @Init(i32 noundef, ptr noundef) #0

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @ProcessLine(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strstr(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

declare i32 @fclose(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 = { "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 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@Line = external hidden global [256 x i8], align 16
@fin = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@L1 = external hidden local_unnamed_addr global i64, align 8
@fout = external hidden local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @Init(i32 noundef %0, ptr noundef %1)
  %3 = load ptr, ptr @fin, align 8, !tbaa !5
  %4 = tail call ptr @fgets(ptr noundef nonnull @Line, i32 noundef 255, ptr noundef %3)
  %.not9 = icmp eq ptr %4, null
  br i1 %.not9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %16
  %.010 = phi i32 [ %.1, %16 ], [ 0, %2 ]
  %.not6 = icmp eq i32 %.010, 0
  br i1 %.not6, label %5, label %.sink.split

5:                                                ; preds = %.lr.ph
  %6 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) @Line, ptr noundef nonnull dereferenceable(1) @.str) #3
  %.not7 = icmp eq ptr %6, null
  br i1 %.not7, label %7, label %16

7:                                                ; preds = %5
  %8 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) @Line, ptr noundef nonnull dereferenceable(1) @.str.1) #3
  %.not8 = icmp eq ptr %8, null
  br i1 %.not8, label %16, label %9

9:                                                ; preds = %7
  store i8 0, ptr %8, align 1, !tbaa !9
  %10 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) @Line, i32 noundef 37) #3
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %16

12:                                               ; preds = %9
  %13 = load i64, ptr @L1, align 8, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %8, i64 %13
  br label %.sink.split

.sink.split:                                      ; preds = %.lr.ph, %12
  %.sink = phi ptr [ %14, %12 ], [ @Line, %.lr.ph ]
  %15 = tail call i32 @ProcessLine(ptr noundef nonnull %.sink)
  br label %16

16:                                               ; preds = %.sink.split, %5, %9, %7
  %.1 = phi i32 [ 0, %5 ], [ 0, %9 ], [ 0, %7 ], [ %15, %.sink.split ]
  %17 = load ptr, ptr @fin, align 8, !tbaa !5
  %18 = tail call ptr @fgets(ptr noundef nonnull @Line, i32 noundef 255, ptr noundef %17)
  %.not = icmp eq ptr %18, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %16, %2
  %19 = load ptr, ptr @fout, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.2) #4
  %21 = load ptr, ptr @fout, align 8, !tbaa !5
  %22 = tail call i32 @fclose(ptr noundef %21)
  %23 = load ptr, ptr @fin, align 8, !tbaa !5
  %24 = tail call i32 @fclose(ptr noundef %23)
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden void @Init(i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @ProcessLine(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #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 = { 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: 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 #3 = { nounwind willreturn memory(read) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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