; LLVM IR from kparc/ksimple :: a (main)

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

@WS = external hidden global i64, align 8
@l = external hidden global ptr, align 8
@t = external dso_local global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i64 @wu(i64 noundef) #0

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @wg() #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @w(i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @W(i64 noundef) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @_r(i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @rl(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @e(ptr noundef) #0

; 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 i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  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) #4
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp eq i32 2, %11
  %13 = zext i1 %12 to i32
  %14 = sext i32 %13 to i64
  store i64 %14, ptr %6, align 8, !tbaa !11
  %15 = load i64, ptr %6, align 8, !tbaa !11
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %2
  br label %21

18:                                               ; preds = %2
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef @.str.12)
  %20 = sext i32 %19 to i64
  br label %21

21:                                               ; preds = %18, %17
  %22 = phi i64 [ %15, %17 ], [ %20, %18 ]
  br label %23

23:                                               ; preds = %105, %82, %21
  %24 = load i64, ptr %6, align 8, !tbaa !11
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %29

27:                                               ; preds = %23
  %28 = call i64 @w(i64 noundef 32)
  br label %29

29:                                               ; preds = %27, %26
  %30 = phi i64 [ %24, %26 ], [ %28, %27 ]
  %31 = load ptr, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %31, i64 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call i64 @rl(ptr noundef %33)
  %35 = icmp ne i64 128, %34
  br i1 %35, label %36, label %106

36:                                               ; preds = %29
  %37 = load ptr, ptr @l, align 8, !tbaa !9
  %38 = load i8, ptr %37, align 1, !tbaa !13
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %105

40:                                               ; preds = %36
  %41 = load ptr, ptr @l, align 8, !tbaa !9
  %42 = load i8, ptr %41, align 1, !tbaa !13
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 92, %43
  br i1 %44, label %45, label %77

45:                                               ; preds = %40
  %46 = load ptr, ptr @l, align 8, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %46, i64 2
  %48 = load i8, ptr %47, align 1, !tbaa !13
  %49 = icmp ne i8 %48, 0
  br i1 %49, label %77, label %50

50:                                               ; preds = %45
  %51 = load ptr, ptr @l, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %51, i64 1
  %53 = load i8, ptr %52, align 1, !tbaa !13
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 92, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %50
  br label %106

57:                                               ; preds = %50
  %58 = load ptr, ptr @l, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %58, i64 1
  %60 = load i8, ptr %59, align 1, !tbaa !13
  %61 = sext i8 %60 to i32
  %62 = icmp eq i32 119, %61
  br i1 %62, label %63, label %66

63:                                               ; preds = %57
  %64 = load i64, ptr @WS, align 8, !tbaa !11
  %65 = call i64 @wu(i64 noundef %64)
  br label %75

66:                                               ; preds = %57
  %67 = load ptr, ptr @l, align 8, !tbaa !9
  %68 = getelementptr inbounds i8, ptr %67, i64 1
  %69 = load i8, ptr %68, align 1, !tbaa !13
  %70 = sext i8 %69 to i32
  %71 = icmp eq i32 118, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %66
  call void @wg()
  br label %74

73:                                               ; preds = %66
  br label %74

74:                                               ; preds = %73, %72
  br label %75

75:                                               ; preds = %74, %63
  br label %76

76:                                               ; preds = %75
  br label %104

77:                                               ; preds = %45, %40
  %78 = load ptr, ptr @l, align 8, !tbaa !9
  %79 = load i8, ptr %78, align 1, !tbaa !13
  %80 = sext i8 %79 to i32
  %81 = icmp eq i32 47, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %77
  br label %23, !llvm.loop !14

83:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %84 = load ptr, ptr @l, align 8, !tbaa !9
  %85 = call i64 @e(ptr noundef %84)
  store i64 %85, ptr %7, align 8, !tbaa !11
  %86 = load ptr, ptr @l, align 8, !tbaa !9
  %87 = getelementptr inbounds i8, ptr %86, i64 1
  %88 = load i8, ptr %87, align 1, !tbaa !13
  %89 = sext i8 %88 to i32
  %90 = icmp eq i32 58, %89
  br i1 %90, label %91, label %93

91:                                               ; preds = %83
  %92 = load i64, ptr %7, align 8, !tbaa !11
  br label %100

93:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %94 = load i64, ptr %7, align 8, !tbaa !11
  %95 = call i64 @W(i64 noundef %94)
  store i64 %95, ptr %9, align 8, !tbaa !11
  %96 = load i64, ptr %7, align 8, !tbaa !11
  %97 = call i64 @_r(i64 noundef %96)
  %98 = load i64, ptr %9, align 8, !tbaa !11
  store i64 %98, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %99 = load i64, ptr %10, align 8, !tbaa !11
  br label %100

100:                                              ; preds = %93, %91
  %101 = phi i64 [ %92, %91 ], [ %99, %93 ]
  store i64 %101, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %102 = load i64, ptr %8, align 8, !tbaa !11
  br label %103

103:                                              ; preds = %100
  br label %104

104:                                              ; preds = %103, %76
  br label %105

105:                                              ; preds = %104, %36
  br label %23, !llvm.loop !14

106:                                              ; preds = %56, %29
  %107 = load ptr, ptr @l, align 8, !tbaa !9
  call void @free(ptr noundef %107) #4
  %108 = load ptr, ptr @t, align 8, !tbaa !9
  %109 = call i32 @fclose(ptr noundef %108)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i32 0
}

declare i32 @fclose(ptr noundef) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !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"

@WS = external hidden local_unnamed_addr global i64, align 8
@l = external hidden local_unnamed_addr global ptr, align 8
@t = external dso_local local_unnamed_addr global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i64 @wu(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @wg() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @w(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @W(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @_r(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @rl(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @e(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp eq i32 %0, 2
  br i1 %3, label %.split.us, label %.split

.split.us:                                        ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call i64 @rl(ptr noundef %5)
  %.not.us16 = icmp eq i64 %6, 128
  br i1 %.not.us16, label %.split13.us, label %.lr.ph17

.lr.ph17:                                         ; preds = %.split.us, %.backedge.us
  %7 = load ptr, ptr @l, align 8, !tbaa !5
  %8 = load i8, ptr %7, align 1, !tbaa !9
  switch i8 %8, label %.thread.us [
    i8 0, label %.backedge.us
    i8 92, label %9
    i8 47, label %.backedge.us
  ]

9:                                                ; preds = %.lr.ph17
  %10 = getelementptr inbounds i8, ptr %7, i64 2
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %.not11.us = icmp eq i8 %11, 0
  br i1 %.not11.us, label %12, label %.thread.us

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %7, i64 1
  %14 = load i8, ptr %13, align 1, !tbaa !9
  switch i8 %14, label %.backedge.us [
    i8 92, label %.split13.us
    i8 119, label %16
    i8 118, label %15
  ]

15:                                               ; preds = %12
  tail call void @wg()
  br label %.backedge.us

16:                                               ; preds = %12
  %17 = load i64, ptr @WS, align 8, !tbaa !10
  %18 = tail call i64 @wu(i64 noundef %17)
  br label %.backedge.us

.thread.us:                                       ; preds = %9, %.lr.ph17
  %19 = tail call i64 @e(ptr noundef nonnull %7)
  %20 = load ptr, ptr @l, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 1
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = icmp eq i8 %22, 58
  br i1 %23, label %.backedge.us, label %24

24:                                               ; preds = %.thread.us
  %25 = tail call i64 @W(i64 noundef %19)
  %26 = tail call i64 @_r(i64 noundef %19)
  br label %.backedge.us

.backedge.us:                                     ; preds = %.lr.ph17, %12, %15, %16, %.thread.us, %24, %.lr.ph17
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = tail call i64 @rl(ptr noundef %27)
  %.not.us = icmp eq i64 %28, 128
  br i1 %.not.us, label %.split13.us, label %.lr.ph17, !llvm.loop !12

.split:                                           ; preds = %2
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull @.str.12)
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  %31 = tail call i64 @w(i64 noundef 32)
  %32 = load ptr, ptr %30, align 8, !tbaa !5
  %33 = tail call i64 @rl(ptr noundef %32)
  %.not14 = icmp eq i64 %33, 128
  br i1 %.not14, label %.split13.us, label %.lr.ph

.lr.ph:                                           ; preds = %.split, %.backedge
  %34 = load ptr, ptr @l, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !9
  switch i8 %35, label %.thread [
    i8 0, label %.backedge
    i8 92, label %36
    i8 47, label %.backedge
  ]

36:                                               ; preds = %.lr.ph
  %37 = getelementptr inbounds i8, ptr %34, i64 2
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %.not11 = icmp eq i8 %38, 0
  br i1 %.not11, label %39, label %.thread

39:                                               ; preds = %36
  %40 = getelementptr inbounds i8, ptr %34, i64 1
  %41 = load i8, ptr %40, align 1, !tbaa !9
  switch i8 %41, label %.backedge [
    i8 92, label %.split13.us
    i8 119, label %42
    i8 118, label %45
  ]

42:                                               ; preds = %39
  %43 = load i64, ptr @WS, align 8, !tbaa !10
  %44 = tail call i64 @wu(i64 noundef %43)
  br label %.backedge

45:                                               ; preds = %39
  tail call void @wg()
  br label %.backedge

.thread:                                          ; preds = %.lr.ph, %36
  %46 = tail call i64 @e(ptr noundef nonnull %34)
  %47 = load ptr, ptr @l, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = load i8, ptr %48, align 1, !tbaa !9
  %50 = icmp eq i8 %49, 58
  br i1 %50, label %.backedge, label %51

51:                                               ; preds = %.thread
  %52 = tail call i64 @W(i64 noundef %46)
  %53 = tail call i64 @_r(i64 noundef %46)
  br label %.backedge

.backedge:                                        ; preds = %45, %42, %39, %.thread, %51, %.lr.ph, %.lr.ph
  %54 = tail call i64 @w(i64 noundef 32)
  %55 = load ptr, ptr %30, align 8, !tbaa !5
  %56 = tail call i64 @rl(ptr noundef %55)
  %.not = icmp eq i64 %56, 128
  br i1 %.not, label %.split13.us, label %.lr.ph, !llvm.loop !12

.split13.us:                                      ; preds = %39, %.backedge, %12, %.backedge.us, %.split, %.split.us
  %57 = load ptr, ptr @l, align 8, !tbaa !5
  tail call void @free(ptr noundef %57) #3
  %58 = load ptr, ptr @t, align 8, !tbaa !5
  %59 = tail call i32 @fclose(ptr noundef %58)
  ret i32 0
}

; 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = !{!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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass