#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 atoi(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int, int);
int scanf(char *, int *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int cmin, cmax, rmin, rmax;
  int c, r;
  int discarded = 0;
  char buf[1024];
  if (argc < 5) {
    fprintf(stderr, "Usage: %s <cmin> <cmax> <rmin> <rmax>\n", argv[0]);
    return 1;
  }
  cmin = atoi(argv[1]);
  cmax = atoi(argv[2]);
  rmin = atoi(argv[3]);
  rmax = atoi(argv[4]);
  while (fgets(buf, 1024, stdin)) {
    if (scanf("%d %d\n", &c, &r) == 2) {
      if (cmin <= c && c <= cmax && rmin <= r && r <= rmax) {
        printf("%d %d\n", c, r);
      } else
        discarded++;
    }
  }
  fprintf(stderr, "Discarded %d samples\n", discarded);
  return 0;
}


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   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11a4 <main+0x54>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a0 <main+0x150>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
lea    -0x430(%rbp),%rdi
mov    0x2df6(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     127f <main+0x12f>
lea    0xe18(%rip),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    127a <main+0x12a>
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     126c <main+0x11c>
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     126c <main+0x11c>
mov    -0x1c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     126c <main+0x11c>
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     126c <main+0x11c>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
jmp    1275 <main+0x125>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    127a <main+0x12a>
jmp    11e4 <main+0x94>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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    $0x428,%rsp
mov    %rsi,%rbp
cmp    $0x4,%edi
jg     118e <main+0x3e>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xe83(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    126f <main+0x11f>
mov    0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,0x10(%rsp)
mov    0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    0x20(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    0x2e1f(%rip),%rbx
mov    (%rbx),%edx
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
mov    $0x0,%ebp
test   %rax,%rax
je     1254 <main+0x104>
xor    %ebp,%ebp
lea    0xe3a(%rip),%r14
lea    0x1c(%rsp),%r12
lea    0x18(%rsp),%r15
lea    0x20(%rsp),%r13
jmp    1217 <main+0xc7>
xchg   %ax,%ax
add    $0x1,%ebp
mov    (%rbx),%edx
mov    %r13,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1254 <main+0x104>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    1203 <main+0xb3>
mov    0x1c(%rsp),%esi
cmp    %esi,0x14(%rsp)
jg     1200 <main+0xb0>
cmp    0x10(%rsp),%esi
jg     1200 <main+0xb0>
mov    0x18(%rsp),%edx
cmp    %edx,0xc(%rsp)
jg     1200 <main+0xb0>
cmp    0x8(%rsp),%edx
jg     1200 <main+0xb0>
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1203 <main+0xb3>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Usage: %s <cmin> <cmax> <rmin> <rmax>\0A\00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [22 x i8] c"Discarded %d samples\0A\00"
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 i32
%12 = alloca i32
%13 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 5
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %76
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* %6
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %7
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %8
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %9
br label %39
39: ; preds = %71, %22
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%41 = load i32, i32* @stdin
%42 = call i64 @fgets(i8* %40, i32 1024, i32 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %72
44: ; preds = %39
%45 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11)
%46 = icmp eq i32 %45, 2
br i1 %46, label %47, label %71
47: ; preds = %44
%48 = load i32, i32* %6
%49 = load i32, i32* %10
%50 = icmp sle i32 %48, %49
br i1 %50, label %51, label %67
51: ; preds = %47
%52 = load i32, i32* %10
%53 = load i32, i32* %7
%54 = icmp sle i32 %52, %53
br i1 %54, label %55, label %67
55: ; preds = %51
%56 = load i32, i32* %8
%57 = load i32, i32* %11
%58 = icmp sle i32 %56, %57
br i1 %58, label %59, label %67
59: ; preds = %55
%60 = load i32, i32* %11
%61 = load i32, i32* %9
%62 = icmp sle i32 %60, %61
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i32, i32* %10
%65 = load i32, i32* %11
%66 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %64, i32 %65)
br label %70
67: ; preds = %59, %55, %51, %47
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
br label %70
70: ; preds = %67, %63
br label %71
71: ; preds = %70, %44
br label %39
72: ; preds = %39
%73 = load i32, i32* @stderr
%74 = load i32, i32* %12
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %74)
store i32 0, i32* %3
br label %76
76: ; preds = %72, %16
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Usage: %s <cmin> <cmax> <rmin> <rmax>\0A\00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [22 x i8] c"Discarded %d samples\0A\00"
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, 5
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %57
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
%27 = load i32, i32* @stdin
%28 = call i64 @fgets(i8* %8, i32 1024, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %53, label %30
30: ; preds = %14, %48
%31 = phi i32 [ %49, %48 ], [ 0, %14 ]
%32 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %48
34: ; preds = %30
%35 = load i32, i32* %3
%36 = icmp sgt i32 %17, %35
%37 = icmp sgt i32 %35, %20
%38 = select i1 %36, i1 true, i1 %37
br i1 %38, label %46, label %39
39: ; preds = %34
%40 = load i32, i32* %4
%41 = icmp sgt i32 %23, %40
%42 = icmp sgt i32 %40, %26
%43 = select i1 %41, i1 true, i1 %42
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %40)
br label %48
46: ; preds = %39, %34
%47 = add nsw i32 %31, 1
br label %48
48: ; preds = %44, %46, %30
%49 = phi i32 [ %31, %44 ], [ %47, %46 ], [ %31, %30 ]
%50 = load i32, i32* @stdin
%51 = call i64 @fgets(i8* %8, i32 1024, i32 %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %30
53: ; preds = %48, %14
%54 = phi i32 [ 0, %14 ], [ %49, %48 ]
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %57
57: ; preds = %53, %10
%58 = phi i32 [ 1, %10 ], [ 0, %53 ]
ret i32 %58
}