; LLVM IR from pandax381/microps :: icmp (icmp_output)

; 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.icmp_hdr = type { i8, i8, i16, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [58 x i8], align 1
@__func__.icmp_output = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @icmp_output(i8 noundef zeroext %0, i8 noundef zeroext %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [65515 x i8], align 16
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca [16 x i8], align 16
  %19 = alloca [16 x i8], align 16
  store i8 %0, ptr %8, align 1, !tbaa !5
  store i8 %1, ptr %9, align 1, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !8
  store ptr %3, ptr %11, align 8, !tbaa !10
  store i64 %4, ptr %12, align 8, !tbaa !12
  store i32 %5, ptr %13, align 4, !tbaa !8
  store i32 %6, ptr %14, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 65515, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #4
  %20 = getelementptr inbounds [65515 x i8], ptr %15, i64 0, i64 0
  store ptr %20, ptr %16, align 8, !tbaa !10
  %21 = load i8, ptr %8, align 1, !tbaa !5
  %22 = load ptr, ptr %16, align 8, !tbaa !10
  %23 = getelementptr inbounds %struct.icmp_hdr, ptr %22, i32 0, i32 0
  store i8 %21, ptr %23, align 4, !tbaa !14
  %24 = load i8, ptr %9, align 1, !tbaa !5
  %25 = load ptr, ptr %16, align 8, !tbaa !10
  %26 = getelementptr inbounds %struct.icmp_hdr, ptr %25, i32 0, i32 1
  store i8 %24, ptr %26, align 1, !tbaa !17
  %27 = load ptr, ptr %16, align 8, !tbaa !10
  %28 = getelementptr inbounds %struct.icmp_hdr, ptr %27, i32 0, i32 2
  store i16 0, ptr %28, align 2, !tbaa !18
  %29 = load i32, ptr %10, align 4, !tbaa !8
  %30 = load ptr, ptr %16, align 8, !tbaa !10
  %31 = getelementptr inbounds %struct.icmp_hdr, ptr %30, i32 0, i32 3
  store i32 %29, ptr %31, align 4, !tbaa !19
  %32 = load ptr, ptr %16, align 8, !tbaa !10
  %33 = getelementptr inbounds %struct.icmp_hdr, ptr %32, i64 1
  %34 = load ptr, ptr %11, align 8, !tbaa !10
  %35 = load i64, ptr %12, align 8, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %33, ptr align 1 %34, i64 %35, i1 false)
  %36 = load i64, ptr %12, align 8, !tbaa !12
  %37 = add i64 8, %36
  store i64 %37, ptr %17, align 8, !tbaa !12
  %38 = load ptr, ptr %16, align 8, !tbaa !10
  %39 = load i64, ptr %17, align 8, !tbaa !12
  %40 = trunc i64 %39 to i16
  %41 = call zeroext i16 @cksum16(ptr noundef %38, i16 noundef zeroext %40, i32 noundef 0)
  %42 = load ptr, ptr %16, align 8, !tbaa !10
  %43 = getelementptr inbounds %struct.icmp_hdr, ptr %42, i32 0, i32 2
  store i16 %41, ptr %43, align 2, !tbaa !18
  %44 = load ptr, ptr @stderr, align 8, !tbaa !10
  %45 = load i32, ptr %13, align 4, !tbaa !8
  %46 = getelementptr inbounds [16 x i8], ptr %18, i64 0, i64 0
  %47 = call ptr @ip_addr_ntop(i32 noundef %45, ptr noundef %46, i64 noundef 16)
  %48 = load i32, ptr %14, align 4, !tbaa !8
  %49 = getelementptr inbounds [16 x i8], ptr %19, i64 0, i64 0
  %50 = call ptr @ip_addr_ntop(i32 noundef %48, ptr noundef %49, i64 noundef 16)
  %51 = load ptr, ptr %16, align 8, !tbaa !10
  %52 = getelementptr inbounds %struct.icmp_hdr, ptr %51, i32 0, i32 0
  %53 = load i8, ptr %52, align 4, !tbaa !14
  %54 = call ptr @icmp_type_ntoa(i8 noundef zeroext %53)
  %55 = load ptr, ptr %16, align 8, !tbaa !10
  %56 = getelementptr inbounds %struct.icmp_hdr, ptr %55, i32 0, i32 0
  %57 = load i8, ptr %56, align 4, !tbaa !14
  %58 = zext i8 %57 to i32
  %59 = load i64, ptr %17, align 8, !tbaa !12
  %60 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %44, i32 noundef 68, ptr noundef @.str, i32 noundef 141, ptr noundef @__func__.icmp_output, ptr noundef @.str.1, ptr noundef %47, ptr noundef %50, ptr noundef %54, i32 noundef %58, i64 noundef %59)
  %61 = load ptr, ptr %16, align 8, !tbaa !10
  %62 = load i64, ptr %17, align 8, !tbaa !12
  call void @icmp_dump(ptr noundef %61, i64 noundef %62)
  %63 = load ptr, ptr %16, align 8, !tbaa !10
  %64 = load i64, ptr %17, align 8, !tbaa !12
  %65 = load i32, ptr %13, align 4, !tbaa !8
  %66 = load i32, ptr %14, align 4, !tbaa !8
  %67 = call i64 @ip_output(i8 noundef zeroext 1, ptr noundef %63, i64 noundef %64, i32 noundef %65, i32 noundef %66)
  %68 = trunc i64 %67 to i32
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 65515, ptr %15) #4
  ret i32 %68
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare zeroext i16 @cksum16(ptr noundef, i16 noundef zeroext, i32 noundef) #3

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #3

declare ptr @ip_addr_ntop(i32 noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden ptr @icmp_type_ntoa(i8 noundef zeroext) #0

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

declare i64 @ip_output(i8 noundef zeroext, ptr noundef, i64 noundef, i32 noundef, i32 noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !6, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"icmp_hdr", !6, i64 0, !6, i64 1, !16, i64 2, !9, i64 4}
!16 = !{!"short", !6, i64 0}
!17 = !{!15, !6, i64 1}
!18 = !{!15, !16, i64 2}
!19 = !{!15, !9, i64 4}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [58 x i8], align 1
@__func__.icmp_output = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @icmp_output(i8 noundef zeroext %0, i8 noundef zeroext %1, i32 noundef %2, ptr nocapture noundef readonly %3, i64 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca [65515 x i8], align 16
  %9 = alloca [16 x i8], align 16
  %10 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 65515, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #4
  store i8 %0, ptr %8, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %8, i64 1
  store i8 %1, ptr %11, align 1, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %8, i64 2
  store i16 0, ptr %12, align 2, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %2, ptr %13, align 4, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %8, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %14, ptr align 1 %3, i64 %4, i1 false)
  %15 = add i64 %4, 8
  %16 = trunc i64 %15 to i16
  %17 = call zeroext i16 @cksum16(ptr noundef nonnull %8, i16 noundef zeroext %16, i32 noundef 0) #4
  store i16 %17, ptr %12, align 2, !tbaa !12
  %18 = load ptr, ptr @stderr, align 8, !tbaa !14
  %19 = call ptr @ip_addr_ntop(i32 noundef %5, ptr noundef nonnull %9, i64 noundef 16) #4
  %20 = call ptr @ip_addr_ntop(i32 noundef %6, ptr noundef nonnull %10, i64 noundef 16) #4
  %21 = load i8, ptr %8, align 16, !tbaa !5
  %22 = call ptr @icmp_type_ntoa(i8 noundef zeroext %21)
  %23 = load i8, ptr %8, align 16, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %18, i32 noundef 68, ptr noundef nonnull @.str, i32 noundef 141, ptr noundef nonnull @__func__.icmp_output, ptr noundef nonnull @.str.1, ptr noundef %19, ptr noundef %20, ptr noundef %22, i32 noundef %24, i64 noundef %15) #4
  call void @icmp_dump(ptr noundef nonnull %8, i64 noundef %15)
  %26 = call i64 @ip_output(i8 noundef zeroext 1, ptr noundef nonnull %8, i64 noundef %15, i32 noundef %5, i32 noundef %6) #4
  %27 = trunc i64 %26 to i32
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 65515, ptr nonnull %8) #4
  ret i32 %27
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare zeroext i16 @cksum16(ptr noundef, i16 noundef zeroext, i32 noundef) local_unnamed_addr #3

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #3

declare ptr @ip_addr_ntop(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden ptr @icmp_type_ntoa(i8 noundef zeroext) local_unnamed_addr #0

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

declare i64 @ip_output(i8 noundef zeroext, ptr noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"icmp_hdr", !7, i64 0, !7, i64 1, !9, i64 2, !10, i64 4}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"short", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!6, !7, i64 1}
!12 = !{!6, !9, i64 2}
!13 = !{!6, !10, i64 4}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass