#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*/ printf(char *, ...);
int main() {
  printf("1000 1000 250000 4\n");
  for (int i = 1; i < 1001; i++) {
    for (int k = 1; k < 1001; k++) {
      if (i < 501 && k > 500) {
        printf("%d %d\n", i, k);
      }
    }
  }
  printf("1\n3\n5\n11\n0 0 0 0");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x3e9,-0x8(%rbp)
jge    11a9 <main+0x99>
movl   $0x1,-0xc(%rbp)
cmpl   $0x3e9,-0xc(%rbp)
jge    1196 <main+0x86>
cmpl   $0x1f5,-0x8(%rbp)
jge    1183 <main+0x73>
cmpl   $0x1f4,-0xc(%rbp)
jle    1183 <main+0x73>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1188 <main+0x78>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <main+0x38>
jmp    119b <main+0x8b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1134 <main+0x24>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xec4(%rip),%r14
jmp    114b <main+0x2b>
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x3e9,%ebx
je     118b <main+0x6b>
mov    $0x1,%ebp
jmp    116b <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x3e9,%ebp
je     1140 <main+0x20>
cmp    $0x1f4,%ebx
ja     1160 <main+0x40>
cmp    $0x1f5,%ebp
jb     1160 <main+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <main+0x40>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"1000 1000 250000 4\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [17 x i8] c"1\0A3\0A5\0A11\0A0 0 0 0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %5
5: ; preds = %27, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1001
br i1 %7, label %8, label %30
8: ; preds = %5
store i32 1, i32* %3
br label %9
9: ; preds = %23, %8
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 1001
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 501
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 500
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
br label %22
22: ; preds = %18, %15, %12
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %9
26: ; preds = %9
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %5
30: ; preds = %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [17 x i8] c"1\0A3\0A5\0A11\0A0 0 0 0\00"
@str = [19 x i8] c"1000 1000 250000 4\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %7
%3 = phi i32 [ 1, %0 ], [ %8, %7 ]
%4 = icmp ult i32 %3, 501
br label %10
5: ; preds = %7
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
7: ; preds = %16
%8 = add nuw nsw i32 %3, 1
%9 = icmp eq i32 %8, 1001
br i1 %9, label %5, label %2
10: ; preds = %2, %16
%11 = phi i32 [ 1, %2 ], [ %17, %16 ]
%12 = icmp ugt i32 %11, 500
%13 = select i1 %4, i1 %12, i1 false
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %11)
br label %16
16: ; preds = %10, %14
%17 = add nuw nsw i32 %11, 1
%18 = icmp eq i32 %17, 1001
br i1 %18, label %7, label %10
}