#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 *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main() {
  FILE *out = fopen("componentes.txt", "w");
  char b1[10], b2[10];
  int n, v, e, vv, ee;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    fprintf(out, "%d\n", n);
    for (int i = 0; i < n; i++) {
      v = (rand() % 26);
      e = v + 1;
      while (e > v)
        e = (rand() % 26);
      fprintf(out, "%d %d\n", v, e);
      for (int j = 0; j < e; j++) {
        vv = (rand() % v);
        ee = (rand() % v);
        snprintf(b1, 10, "%c", vv + 97);
        snprintf(b2, 10, "%c", ee + 97);
        fprintf(out, "%s %s\n", b1, b2);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1195 <main+0x45>
jmp    12b8 <main+0x168>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12b3 <main+0x163>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    11fb <main+0xab>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
jmp    11d8 <main+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12a0 <main+0x150>
mov    $0x0,%al
call   1070 <rand@plt>
cltd
idivl  -0x2c(%rbp)
mov    %edx,-0x34(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
cltd
idivl  -0x2c(%rbp)
mov    %edx,-0x38(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x34(%rbp),%ecx
add    $0x61,%ecx
mov    $0xa,%esi
lea    0xdc4(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x24(%rbp),%rdi
mov    -0x38(%rbp),%ecx
add    $0x61,%ecx
mov    $0xa,%esi
lea    0xda9(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    121a <main+0xca>
jmp    12a5 <main+0x155>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b1 <main+0x61>
jmp    1176 <main+0x26>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe9b(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
lea    0xe97(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
je     1313 <main+0x1c3>
lea    0x2e(%rsp),%r12
mov    %r13,0x18(%rsp)
jmp    11bd <main+0x6d>
nopl   (%rax)
lea    0xe6b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
je     1313 <main+0x1c3>
mov    %r13,%rdi
lea    0xe51(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11a0 <main+0x50>
xor    %eax,%eax
jmp    11ed <main+0x9d>
nopl   0x0(%rax)
mov    0x14(%rsp),%eax
add    $0x1,%eax
cmp    0x4(%rsp),%eax
jge    11a0 <main+0x50>
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rdx
imul   $0x4ec4ec4f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%edx
mov    %rdx,0x8(%rsp)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%r14
imul   $0x4ec4ec4f,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%r14d
cmp    0x8(%rsp),%r14d
jg     1220 <main+0xd0>
mov    %r13,%rdi
lea    0xdbb(%rip),%rsi
mov    0x8(%rsp),%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r14d,%r14d
jle    11e0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
cltd
mov    0x8(%rsp),%rbx
idiv   %ebx
lea    0xd86(%rip),%rbp
mov    %r12,%r15
mov    %edx,%r12d
xor    %eax,%eax
call   1070 <rand@plt>
cltd
idiv   %ebx
mov    %edx,%r13d
add    $0x61,%r12d
mov    %r15,%rdi
mov    $0xa,%esi
mov    %rbp,%rdx
mov    %r12d,%ecx
mov    %r15,%r12
lea    0x24(%rsp),%r15
mov    %rbp,%rbx
mov    0x18(%rsp),%rbp
call   1030 <snprintf@plt>
add    $0x61,%r13d
mov    %r15,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
mov    %r13d,%ecx
lea    0xd36(%rip),%rbx
call   1030 <snprintf@plt>
mov    %rbp,%r13
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0xffffffff,%r14d
jne    1280 <main+0x130>
jmp    11e0 <main+0x90>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"componentes.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"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [7 x i8] c"%s %s\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 i32
store i32 0, i32* %1
%12 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
br label %13
13: ; preds = %0, %73
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %74
18: ; preds = %13
%19 = load i32*, i32** %2
%20 = load i32, i32* %5
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %20)
store i32 0, i32* %10
br label %22
22: ; preds = %70, %18
%23 = load i32, i32* %10
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %73
26: ; preds = %22
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 26
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %31
31: ; preds = %35, %26
%32 = load i32, i32* %7
%33 = load i32, i32* %6
%34 = icmp sgt i32 %32, %33
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = call i32 (...) @rand()
%37 = srem i32 %36, 26
store i32 %37, i32* %7
br label %31
38: ; preds = %31
%39 = load i32*, i32** %2
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %41)
store i32 0, i32* %11
br label %43
43: ; preds = %66, %38
%44 = load i32, i32* %11
%45 = load i32, i32* %7
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %69
47: ; preds = %43
%48 = call i32 (...) @rand()
%49 = load i32, i32* %6
%50 = srem i32 %48, %49
store i32 %50, i32* %8
%51 = call i32 (...) @rand()
%52 = load i32, i32* %6
%53 = srem i32 %51, %52
store i32 %53, i32* %9
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 97
%57 = call i32 @snprintf(i8* %54, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 97
%61 = call i32 @snprintf(i8* %58, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = load i32*, i32** %2
%63 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%64 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %63, i8* %64)
br label %66
66: ; preds = %47
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
br label %43
69: ; preds = %43
br label %70
70: ; preds = %69
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %22
73: ; preds = %22
br label %13
74: ; preds = %17
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str = [16 x i8] c"componentes.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"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [7 x i8] c"%s %s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %48, label %15
11: ; preds = %31, %15
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %48, label %15
15: ; preds = %0, %11
%16 = phi i32 [ %13, %11 ], [ %9, %0 ]
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %11
20: ; preds = %15, %31
%21 = phi i32 [ %32, %31 ], [ 0, %15 ]
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 26
br label %24
24: ; preds = %20, %24
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 26
%27 = icmp sgt i32 %26, %23
br i1 %27, label %24, label %28
28: ; preds = %24
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %26)
%30 = icmp sgt i32 %26, 0
br i1 %30, label %35, label %31
31: ; preds = %35, %28
%32 = add nuw nsw i32 %21, 1
%33 = load i32, i32* %3
%34 = icmp slt i32 %32, %33
br i1 %34, label %20, label %11
35: ; preds = %28, %35
%36 = phi i32 [ %46, %35 ], [ 0, %28 ]
%37 = call i32 (...) @rand()
%38 = srem i32 %37, %23
%39 = call i32 (...) @rand()
%40 = srem i32 %39, %23
%41 = add nsw i32 %38, 97
%42 = call i32 @snprintf(i8* %5, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %41)
%43 = add nsw i32 %40, 97
%44 = call i32 @snprintf(i8* %6, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %5, i8* %6)
%46 = add nuw nsw i32 %36, 1
%47 = icmp eq i32 %46, %26
br i1 %47, label %31, label %35
48: ; preds = %11, %0
ret i32 0
}