#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*/ manual_test(int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ random_test(int, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int k, n, m, l, i, t;
  printf("How many tests you want: \n");
  scanf("%d", &k);
  printf("Please give the degree of the first polynomial:\n");
  scanf("%d", &n);
  printf("Please give the degree of the second polynomial:\n");
  scanf("%d", &m);
  printf("How many common divisors you want in the test: \n");
  scanf("%d", &l);
  printf("Please choose what kind of test you want:\n");
  printf("1. random test\n");
  printf("2. interactive test\n");
  scanf("%d", &t);
  for (i = 1; i <= k; i++) {
    printf("\n******* The No. %d test *********\n", i);
    if (t == 1)
      random_test(n, m, l);
    if (t == 2)
      manual_test(n, m, l);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe23(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1268 <main+0x128>
mov    -0x18(%rbp),%esi
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    123d <main+0xfd>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <random_test@plt>
cmpl   $0x2,-0x1c(%rbp)
jne    1255 <main+0x115>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <manual_test@plt>
jmp    125a <main+0x11a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1208 <main+0xc8>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xe97(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xf0a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    126d <main+0x11d>
lea    0xe03(%rip),%rbx
xor    %ebp,%ebp
jmp    1216 <main+0xc6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    0x14(%rsp),%ebp
jge    126d <main+0x11d>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     1240 <main+0xf0>
cmp    $0x2,%eax
jne    1210 <main+0xc0>
jmp    125a <main+0x10a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
call   1070 <random_test@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jne    1210 <main+0xc0>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
call   1050 <manual_test@plt>
jmp    1210 <main+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"How many tests you want: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"Please give the degree of the first polynomial:\0A\00"
@.str.3 = [50 x i8] c"Please give the degree of the second polynomial:\0A\00"
@.str.4 = [49 x i8] c"How many common divisors you want in the test: \0A\00"
@.str.5 = [43 x i8] c"Please choose what kind of test you want:\0A\00"
@.str.6 = [16 x i8] c"1. random test\0A\00"
@.str.7 = [21 x i8] c"2. interactive test\0A\00"
@.str.8 = [36 x i8] c"\0A******* The No. %d test *********\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
store i32 1, i32* %6
br label %20
20: ; preds = %43, %0
%21 = load i32, i32* %6
%22 = load i32, i32* %2
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %46
24: ; preds = %20
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = call i32 @random_test(i32 %30, i32 %31, i32 %32)
br label %34
34: ; preds = %29, %24
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = call i32 @manual_test(i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %37, %34
br label %43
43: ; preds = %42
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %20
46: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.8 = [36 x i8] c"\0A******* The No. %d test *********\0A\00"
@str = [26 x i8] c"How many tests you want: \00"
@str.9 = [48 x i8] c"Please give the degree of the first polynomial:\00"
@str.10 = [49 x i8] c"Please give the degree of the second polynomial:\00"
@str.11 = [48 x i8] c"How many common divisors you want in the test: \00"
@str.12 = [42 x i8] c"Please choose what kind of test you want:\00"
@str.13 = [15 x i8] c"1. random test\00"
@str.14 = [20 x i8] c"2. interactive test\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.9, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.10, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.11, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.12, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.14, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%23 = load i32, i32* %1
%24 = icmp slt i32 %23, 1
br i1 %24, label %48, label %25
25: ; preds = %0, %44
%26 = phi i32 [ %45, %44 ], [ 1, %0 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = call i32 @random_test(i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %5
br label %36
36: ; preds = %30, %25
%37 = phi i32 [ %35, %30 ], [ %28, %25 ]
%38 = icmp eq i32 %37, 2
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = call i32 @manual_test(i32 %40, i32 %41, i32 %42)
br label %44
44: ; preds = %36, %39
%45 = add nuw nsw i32 %26, 1
%46 = load i32, i32* %1
%47 = icmp slt i32 %26, %46
br i1 %47, label %25, label %48
48: ; preds = %44, %0
ret i32 0
}