; LLVM IR from holzschu/ios_system :: shell_cmds/hexdump (display)

; 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 [3 x i8], align 1
@skip = external global i64, align 8
@stdin = external global ptr, align 8
@_argv = external hidden global ptr, align 8
@next.done = external hidden global i32, align 4
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@exitval = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1

; 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
define dso_local i32 @next(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %9, ptr @_argv, align 8, !tbaa !5
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %58

10:                                               ; preds = %1
  br label %11

11:                                               ; preds = %57, %21, %10
  %12 = load ptr, ptr @_argv, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %27

15:                                               ; preds = %11
  %16 = load ptr, ptr @_argv, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = load ptr, ptr @stdin, align 8, !tbaa !5
  %19 = call ptr @freopen(ptr noundef %17, ptr noundef @.str.4, ptr noundef %18)
  %20 = icmp ne ptr %19, null
  br i1 %20, label %26, label %21

21:                                               ; preds = %15
  %22 = load ptr, ptr @_argv, align 8, !tbaa !5
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  call void (ptr, ...) @warn(ptr noundef @.str, ptr noundef %23)
  store i32 1, ptr @exitval, align 4, !tbaa !9
  %24 = load ptr, ptr @_argv, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %24, i32 1
  store ptr %25, ptr @_argv, align 8, !tbaa !5
  br label %11

26:                                               ; preds = %15
  store i32 1, ptr @next.done, align 4, !tbaa !9
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %33

27:                                               ; preds = %11
  %28 = load i32, ptr @next.done, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @next.done, align 4, !tbaa !9
  %30 = icmp ne i32 %28, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %58

32:                                               ; preds = %27
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %32, %26
  %34 = load i64, ptr @skip, align 8, !tbaa !11
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %46

36:                                               ; preds = %33
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load ptr, ptr @_argv, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  br label %43

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42, %39
  %44 = phi ptr [ %41, %39 ], [ @.str.5, %42 ]
  %45 = load i32, ptr %4, align 4, !tbaa !9
  call void @doskip(ptr noundef %44, i32 noundef %45)
  br label %46

46:                                               ; preds = %43, %33
  %47 = load ptr, ptr @_argv, align 8, !tbaa !5
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %53

50:                                               ; preds = %46
  %51 = load ptr, ptr @_argv, align 8, !tbaa !5
  %52 = getelementptr inbounds ptr, ptr %51, i32 1
  store ptr %52, ptr @_argv, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %50, %46
  %54 = load i64, ptr @skip, align 8, !tbaa !11
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %57, label %56

56:                                               ; preds = %53
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %58

57:                                               ; preds = %53
  br label %11

58:                                               ; preds = %56, %31, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %59 = load i32, ptr %2, align 4
  ret i32 %59
}

declare void @warn(ptr noundef, ...) #2

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @doskip(ptr noundef, i32 noundef) #1

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 = { "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, !12, i64 0}
!12 = !{!"long", !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 [3 x i8], align 1
@skip = external local_unnamed_addr global i64, align 8
@stdin = external local_unnamed_addr global ptr, align 8
@_argv = external hidden local_unnamed_addr global ptr, align 8
@next.done = external hidden local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@exitval = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @next(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.preheader.preheader, label %2

.preheader.preheader:                             ; preds = %1
  %.pre = load ptr, ptr @_argv, align 8, !tbaa !5
  br label %.preheader

2:                                                ; preds = %1
  store ptr %0, ptr @_argv, align 8, !tbaa !5
  br label %.loopexit

.preheader:                                       ; preds = %.preheader.backedge, %.preheader.preheader
  %3 = phi ptr [ %.pre, %.preheader.preheader ], [ %.be, %.preheader.backedge ]
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not7 = icmp eq ptr %4, null
  br i1 %.not7, label %13, label %5

5:                                                ; preds = %.preheader
  %6 = load ptr, ptr @stdin, align 8, !tbaa !5
  %7 = tail call ptr @freopen(ptr noundef nonnull %4, ptr noundef nonnull @.str.4, ptr noundef %6) #2
  %.not9 = icmp eq ptr %7, null
  br i1 %.not9, label %8, label %.thread

8:                                                ; preds = %5
  %9 = load ptr, ptr @_argv, align 8, !tbaa !5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  tail call void (ptr, ...) @warn(ptr noundef nonnull @.str, ptr noundef %10) #2
  store i32 1, ptr @exitval, align 4, !tbaa !9
  %11 = load ptr, ptr @_argv, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr %12, ptr @_argv, align 8, !tbaa !5
  br label %.preheader.backedge

.preheader.backedge:                              ; preds = %8, %28
  %.be = phi ptr [ %12, %8 ], [ %29, %28 ]
  br label %.preheader

13:                                               ; preds = %.preheader
  %14 = load i32, ptr @next.done, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr @next.done, align 4, !tbaa !9
  %.not8 = icmp eq i32 %14, 0
  br i1 %.not8, label %16, label %.loopexit

16:                                               ; preds = %13
  %17 = load i64, ptr @skip, align 8, !tbaa !11
  %.not10 = icmp eq i64 %17, 0
  br i1 %.not10, label %23, label %21

.thread:                                          ; preds = %5
  store i32 1, ptr @next.done, align 4, !tbaa !9
  %18 = load i64, ptr @skip, align 8, !tbaa !11
  %.not1015 = icmp eq i64 %18, 0
  %.pre22 = load ptr, ptr @_argv, align 8, !tbaa !5
  br i1 %.not1015, label %23, label %19

19:                                               ; preds = %.thread
  %20 = load ptr, ptr %.pre22, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %16, %19
  %.01620 = phi i32 [ 1, %19 ], [ 0, %16 ]
  %22 = phi ptr [ %20, %19 ], [ @.str.5, %16 ]
  tail call void @doskip(ptr noundef %22, i32 noundef %.01620)
  %.pre21 = load ptr, ptr @_argv, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %.thread, %21, %16
  %24 = phi ptr [ %.pre22, %.thread ], [ %.pre21, %21 ], [ %3, %16 ]
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %.not12 = icmp eq ptr %25, null
  br i1 %.not12, label %28, label %26

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %27, ptr @_argv, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %26, %23
  %29 = phi ptr [ %27, %26 ], [ %24, %23 ]
  %30 = load i64, ptr @skip, align 8, !tbaa !11
  %.not13 = icmp eq i64 %30, 0
  br i1 %.not13, label %.loopexit, label %.preheader.backedge

.loopexit:                                        ; preds = %28, %13, %2
  %.04 = phi i32 [ 1, %2 ], [ 1, %28 ], [ 0, %13 ]
  ret i32 %.04
}

declare void @warn(ptr noundef, ...) local_unnamed_addr #1

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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 = { 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, !12, i64 0}
!12 = !{!"long", !7, i64 0}


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