#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int num, flag, base;
  printf("ÇëÑ¡ÔñÐèÒªÉú³ÉµÄÊý¾ÝÁ¿£º\n");
  printf("1£ºÊý¾ÝÁ¿100£¬È¡·¶Î§£¨1~1000£©\n");
  printf("2£ºÊý¾ÝÁ¿1000£¬È¡·¶Î§£¨1~10000£©\n");
  printf("3£ºÊý¾ÝÁ¿10000£¬È¡·¶Î§£¨1~100000£©\n");
  printf("ÇëÑ¡Ôñ£º");
  scanf("%d", &flag);
  switch (flag) {
  case 1:
    num = 100;
    base = 1000;
    break;
  case 2:
    num = 1000;
    base = 10000;
    break;
  case 3:
    num = 10000;
    base = 100000;
    break;
  default:
    printf("ÊäÈë´íÎó£¡\n");
    exit(0);
  }
  FILE *fp = freopen("input.txt", "w", stdout);
  printf("%d\n", num);
  srand(time(NULL));
  printf("%d\n", rand() % base + 1);
  for (int j = 0; j < num; j++) {
    printf("%10d%10d\n", rand() % base + 1, rand() % base + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf0d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf12(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x1,%eax
je     1212 <main+0xa2>
jmp    11f0 <main+0x80>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     1225 <main+0xb5>
jmp    1201 <main+0x91>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
je     1238 <main+0xc8>
jmp    124b <main+0xdb>
movl   $0x64,-0x8(%rbp)
movl   $0x3e8,-0x10(%rbp)
jmp    1260 <main+0xf0>
movl   $0x3e8,-0x8(%rbp)
movl   $0x2710,-0x10(%rbp)
jmp    1260 <main+0xf0>
movl   $0x2710,-0x8(%rbp)
movl   $0x186a0,-0x10(%rbp)
jmp    1260 <main+0xf0>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edx
lea    0xe8e(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1040 <freopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1090 <rand@plt>
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
add    $0x1,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1310 <main+0x1a0>
mov    $0x0,%al
call   1090 <rand@plt>
cltd
idivl  -0x10(%rbp)
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x28(%rbp),%esi
cltd
idivl  -0x10(%rbp)
add    $0x1,%edx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12c6 <main+0x156>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
jae    129a <main+0x11a>
cltq
lea    0xf25(%rip),%rcx
mov    (%rcx,%rax,4),%r15d
lea    0xf26(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    0x2ddc(%rip),%rax
mov    (%rax),%edx
lea    0xe07(%rip),%rdi
lea    0xe0a(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe00(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %r15d
lea    0x1(%rdx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcb(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %r15d
lea    0x1(%rdx),%ebp
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %r15d
add    $0x1,%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1260 <main+0xe0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"\C3\87\C3\AB\C3\91\C2\A1\C3\94\C3\B1\C3\90\C3\A8\C3\92\C2\AA\C3\89\C3\BA\C2\B3\C3\89\C2\B5\C3\84\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF\C2\A3\C2\BA\0A\00"
@.str.1 = [52 x i8] c"1\C2\A3\C2\BA\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF100\C2\A3\C2\AC\C3\88\C2\A1\C2\B7\C2\B6\C3\8E\C2\A7\C2\A3\C2\A81~1000\C2\A3\C2\A9\0A\00"
@.str.2 = [54 x i8] c"2\C2\A3\C2\BA\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF1000\C2\A3\C2\AC\C3\88\C2\A1\C2\B7\C2\B6\C3\8E\C2\A7\C2\A3\C2\A81~10000\C2\A3\C2\A9\0A\00"
@.str.3 = [56 x i8] c"3\C2\A3\C2\BA\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF10000\C2\A3\C2\AC\C3\88\C2\A1\C2\B7\C2\B6\C3\8E\C2\A7\C2\A3\C2\A81~100000\C2\A3\C2\A9\0A\00"
@.str.4 = [17 x i8] c"\C3\87\C3\AB\C3\91\C2\A1\C3\94\C3\B1\C2\A3\C2\BA\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [22 x i8] c"\C3\8A\C3\A4\C3\88\C3\AB\C2\B4\C3\AD\C3\8E\C3\B3\C2\A3\C2\A1\0A\00"
@.str.7 = [10 x i8] c"input.txt\00"
@.str.8 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [10 x i8] c"%10d%10d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
switch i32 %13, label %17 [
i32 1, label %14
i32 2, label %15
i32 3, label %16
]
14: ; preds = %0
store i32 100, i32* %2
store i32 1000, i32* %4
br label %20
15: ; preds = %0
store i32 1000, i32* %2
store i32 10000, i32* %4
br label %20
16: ; preds = %0
store i32 10000, i32* %2
store i32 100000, i32* %4
br label %20
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %16, %15, %14
%21 = load i32, i32* @stdout
%22 = call i32* @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %21)
store i32* %22, i32** %5
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %23)
%25 = call i32 @time(i32* null)
%26 = call i32 @srand(i32 %25)
%27 = call i32 (...) @rand()
%28 = load i32, i32* %4
%29 = srem i32 %27, %28
%30 = add nsw i32 %29, 1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %30)
store i32 0, i32* %6
br label %32
32: ; preds = %46, %20
%33 = load i32, i32* %6
%34 = load i32, i32* %2
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %32
%37 = call i32 (...) @rand()
%38 = load i32, i32* %4
%39 = srem i32 %37, %38
%40 = add nsw i32 %39, 1
%41 = call i32 (...) @rand()
%42 = load i32, i32* %4
%43 = srem i32 %41, %42
%44 = add nsw i32 %43, 1
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %40, i32 %44)
br label %46
46: ; preds = %36
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %32
49: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [17 x i8] c"\C3\87\C3\AB\C3\91\C2\A1\C3\94\C3\B1\C2\A3\C2\BA\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.7 = [10 x i8] c"input.txt\00"
@.str.8 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [10 x i8] c"%10d%10d\0A\00"
@str = [49 x i8] c"\C3\87\C3\AB\C3\91\C2\A1\C3\94\C3\B1\C3\90\C3\A8\C3\92\C2\AA\C3\89\C3\BA\C2\B3\C3\89\C2\B5\C3\84\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF\C2\A3\C2\BA\00"
@str.11 = [51 x i8] c"1\C2\A3\C2\BA\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF100\C2\A3\C2\AC\C3\88\C2\A1\C2\B7\C2\B6\C3\8E\C2\A7\C2\A3\C2\A81~1000\C2\A3\C2\A9\00"
@str.12 = [53 x i8] c"2\C2\A3\C2\BA\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF1000\C2\A3\C2\AC\C3\88\C2\A1\C2\B7\C2\B6\C3\8E\C2\A7\C2\A3\C2\A81~10000\C2\A3\C2\A9\00"
@str.13 = [55 x i8] c"3\C2\A3\C2\BA\C3\8A\C3\BD\C2\BE\C3\9D\C3\81\C2\BF10000\C2\A3\C2\AC\C3\88\C2\A1\C2\B7\C2\B6\C3\8E\C2\A7\C2\A3\C2\A81~100000\C2\A3\C2\A9\00"
@str.14 = [21 x i8] c"\C3\8A\C3\A4\C3\88\C3\AB\C2\B4\C3\AD\C3\8E\C3\B3\C2\A3\C2\A1\00"
@switch.table.main = [3 x i32] [i32 1000, i32 10000, i32 100000]
@switch.table.main.15 = [3 x i32] [i32 100, i32 1000, i32 10000]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.11, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.13, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -1
%11 = icmp ult i32 %10, 3
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %0
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.main, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = sext i32 %10 to i64
%20 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.main.15, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* @stdout
%23 = call i32* @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %21)
%25 = call i32 @time(i32* null)
%26 = call i32 @srand(i32 %25)
%27 = call i32 (...) @rand()
%28 = srem i32 %27, %18
%29 = add nsw i32 %28, 1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %29)
br label %32
31: ; preds = %32
ret i32 0
32: ; preds = %15, %32
%33 = phi i32 [ 0, %15 ], [ %41, %32 ]
%34 = call i32 (...) @rand()
%35 = srem i32 %34, %18
%36 = add nsw i32 %35, 1
%37 = call i32 (...) @rand()
%38 = srem i32 %37, %18
%39 = add nsw i32 %38, 1
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %36, i32 %39)
%41 = add nuw nsw i32 %33, 1
%42 = icmp eq i32 %41, %21
br i1 %42, label %31, label %32
}