#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  FILE *out = fopen("entrada.txt", "w");
  char b1[10], b2[10];
  int n, i, j, v, e, h;
  double vv, ee;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    fprintf(out, "%d\n", n);
    for (int i = 0; i < n; i++) {
      h = (rand() % 501);
      fprintf(out, "%d\n", h);
      for (i = 0; i < h; i++) {
        vv = (rand() % 10001);
        ee = (rand() % 10001);
        fprintf(out, "%d %d\n", vv, ee);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xea1(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1185 <main+0x45>
jmp    125d <main+0x11d>
mov    -0x10(%rbp),%rdi
cvtsi2sdl -0x28(%rbp),%xmm0
lea    0xe7f(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1258 <main+0x118>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x1f5,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
cvtsi2sdl -0x3c(%rbp),%xmm0
lea    0xe43(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1245 <main+0x105>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x2711,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x2711,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
lea    0xde1(%rip),%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11df <main+0x9f>
jmp    124a <main+0x10a>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11a3 <main+0x63>
jmp    1166 <main+0x26>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xea3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     12b5 <main+0x175>
lea    0xe8c(%rip),%r14
lea    0xe82(%rip),%r15
jmp    11bd <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe67(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     12b5 <main+0x175>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
cmpl   $0x0,0xc(%rsp)
jg     11e9 <main+0xa9>
jmp    11a0 <main+0x60>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11a0 <main+0x60>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r13
imul   $0x20b3dd41,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x1f5,%eax,%eax
sub    %eax,%r13d
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
test   %r13d,%r13d
jle    11e0 <main+0xa0>
mov    %r13d,%r12d
nop
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffffd1b1b919,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x2711,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffffd1b1b919,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x2711,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    %rbx,%rdi
mov    %r15,%rsi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1030 <fprintf@plt>
add    $0xffffffff,%r12d
jne    1230 <main+0xf0>
mov    %r13d,%ebp
jmp    11e0 <main+0xa0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"entrada.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store i32 0, i32* %1
%14 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %2
br label %15
15: ; preds = %0, %58
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
br label %59
20: ; preds = %15
%21 = load i32*, i32** %2
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to double
%24 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %23)
store i32 0, i32* %13
br label %25
25: ; preds = %55, %20
%26 = load i32, i32* %13
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %58
29: ; preds = %25
%30 = call i32 (...) @rand()
%31 = srem i32 %30, 501
store i32 %31, i32* %10
%32 = load i32*, i32** %2
%33 = load i32, i32* %10
%34 = sitofp i32 %33 to double
%35 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %34)
store i32 0, i32* %13
br label %36
36: ; preds = %51, %29
%37 = load i32, i32* %13
%38 = load i32, i32* %10
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %54
40: ; preds = %36
%41 = call i32 (...) @rand()
%42 = srem i32 %41, 10001
%43 = sitofp i32 %42 to double
store double %43, double* %11
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 10001
%46 = sitofp i32 %45 to double
store double %46, double* %12
%47 = load i32*, i32** %2
%48 = load double, double* %11
%49 = load double, double* %12
%50 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %48, double %49)
br label %51
51: ; preds = %40
%52 = load i32, i32* %13
%53 = add nsw i32 %52, 1
store i32 %53, i32* %13
br label %36
54: ; preds = %36
br label %55
55: ; preds = %54
%56 = load i32, i32* %13
%57 = add nsw i32 %56, 1
store i32 %57, i32* %13
br label %25
58: ; preds = %25
br label %15
59: ; preds = %19
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [12 x i8] c"entrada.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %39, label %11
7: ; preds = %34, %11
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %39, label %11
11: ; preds = %0, %7
%12 = phi i32 [ %9, %7 ], [ %5, %0 ]
%13 = sitofp i32 %12 to double
%14 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %13)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %11, %34
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 501
%20 = sitofp i32 %19 to double
%21 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %20)
%22 = icmp sgt i32 %19, 0
br i1 %22, label %23, label %34
23: ; preds = %17, %23
%24 = phi i32 [ %32, %23 ], [ 0, %17 ]
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 10001
%27 = sitofp i32 %26 to double
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 10001
%30 = sitofp i32 %29 to double
%31 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %27, double %30)
%32 = add nuw nsw i32 %24, 1
%33 = icmp eq i32 %32, %19
br i1 %33, label %34, label %23
34: ; preds = %23, %17
%35 = phi i32 [ 0, %17 ], [ %19, %23 ]
%36 = add nuw nsw i32 %35, 1
%37 = load i32, i32* %1
%38 = icmp slt i32 %36, %37
br i1 %38, label %17, label %7
39: ; preds = %7, %0
ret i32 0
}