#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int, int);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int in_old = -1, count = 0, discard;
  int in, out;
  char buf[1024];
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <samples to discard per modulation>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  discard = atoi(argv[1]);
  while (fgets(buf, 1024, stdin)) {
    if (sscanf(buf, "%d %d", &in, &out) == 2) {
      if (in != in_old) {
        in_old = in;
        count = 0;
      }
      count++;
      if (count > discard)
        printf("%d %d\n", in, out);
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bb <main+0x5b>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe58(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x430(%rbp),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     125d <main+0xfd>
lea    -0x430(%rbp),%rdi
lea    0xe32(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    1258 <main+0xf8>
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     122c <main+0xcc>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1253 <main+0xf3>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0xf8>
jmp    11cb <main+0x6b>
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
cmp    $0x1,%edi
jle    1258 <main+0xf8>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,0x4(%rsp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     123d <main+0xdd>
mov    $0xffffffff,%r13d
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
xor    %r14d,%r14d
jmp    11f1 <main+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13d,%r15d
mov    0x2e0e(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
mov    %r15d,%r13d
test   %rax,%rax
je     123d <main+0xdd>
mov    %rbp,%rdi
lea    0xe34(%rip),%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11d0 <main+0x70>
mov    0xc(%rsp),%r15d
cmp    %r13d,%r15d
mov    %r14d,%eax
mov    $0x0,%ecx
cmovne %ecx,%eax
lea    0x1(%rax),%r14d
cmp    0x4(%rsp),%eax
jl     11d3 <main+0x73>
mov    0x8(%rsp),%edx
lea    0xe02(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
jmp    11d3 <main+0x73>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd95(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"Usage: %s <samples to discard per modulation>\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i32 0, i32* %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
br label %27
27: ; preds = %53, %22
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%29 = load i32, i32* @stdin
%30 = call i64 @fgets(i8* %28, i32 1024, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %54
32: ; preds = %27
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32* %10)
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %53
36: ; preds = %32
%37 = load i32, i32* %9
%38 = load i32, i32* %6
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = load i32, i32* %9
store i32 %41, i32* %6
store i32 0, i32* %7
br label %42
42: ; preds = %40, %36
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = icmp sgt i32 %45, %46
br i1 %47, label %48, label %52
48: ; preds = %42
%49 = load i32, i32* %9
%50 = load i32, i32* %10
%51 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %49, i32 %50)
br label %52
52: ; preds = %48, %42
br label %53
53: ; preds = %52, %32
br label %27
54: ; preds = %27
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"Usage: %s <samples to discard per modulation>\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = load i32, i32* @stdin
%21 = call i64 @fgets(i8* %8, i32 1024, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %43, label %23
23: ; preds = %16, %37
%24 = phi i32 [ %39, %37 ], [ -1, %16 ]
%25 = phi i32 [ %38, %37 ], [ 0, %16 ]
%26 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, %24
%31 = select i1 %30, i32 %25, i32 0
%32 = add nsw i32 %31, 1
%33 = icmp slt i32 %31, %19
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = load i32, i32* %4
%36 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %35)
br label %37
37: ; preds = %28, %34, %23
%38 = phi i32 [ %32, %34 ], [ %32, %28 ], [ %25, %23 ]
%39 = phi i32 [ %29, %34 ], [ %29, %28 ], [ %24, %23 ]
%40 = load i32, i32* @stdin
%41 = call i64 @fgets(i8* %8, i32 1024, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %23
43: ; preds = %37, %16
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}