#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 /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ test_arr(int);
int /*<<< orphan*/ test_rec(int);
int /*<<< orphan*/ test_squ(int);
int /*<<< orphan*/ test_squ_2(int);
void run_test() {
  int test_case = -1;
  int type = 0;
  while (!type) {
    printf("테스트 하고자 하는 알고리즘을 선택해주세요\n1. Recursive\n2. "
           "Array\n3. Recursive squaring\n");
    scanf("%d", &type);
    printf("테스트 하고자 하는 최대 숫자를 입력해주세요(양의정수)\n");
    while (test_case < 0) {
      scanf("%d", &test_case);
      if (test_case < 0)
        printf("0이상의 정수를 입력해주세요\n");
    }
    switch (type) {
    case 1:
      if (test_case > 40)
        printf("주의! 40번째 수 위로는 연산이 오래 걸리거나 메모리가 부족할 수 "
               "있습니다.\n");
      test_rec(test_case);
      break;
    case 2:
      test_arr(test_case);
      break;
    case 3:
      test_squ(test_case);
      break;
    case 4:
      test_squ_2(test_case);
      break;
    default:
      printf("올바른 번호를 입력해주세요\n");
    }
  }
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118c <run_test+0x2c>
jmp    126d <run_test+0x10d>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xecf(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jge    11e9 <run_test+0x89>
lea    0xeb6(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jge    11e4 <run_test+0x84>
lea    0xeed(%rip),%rdi
call   1040 <printf@plt>
jmp    11b4 <run_test+0x54>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     125c <run_test+0xfc>
mov    -0x10(%rbp),%rax
lea    0xdf7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x28,-0x4(%rbp)
jle    1228 <run_test+0xc8>
lea    0xed2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1080 <test_rec@plt>
jmp    1268 <run_test+0x108>
mov    -0x4(%rbp),%edi
call   1060 <test_arr@plt>
jmp    1268 <run_test+0x108>
mov    -0x4(%rbp),%edi
call   1050 <test_squ@plt>
jmp    1268 <run_test+0x108>
mov    -0x4(%rbp),%edi
call   1030 <test_squ_2@plt>
jmp    1268 <run_test+0x108>
lea    0xef9(%rip),%rdi
call   1040 <printf@plt>
jmp    1176 <run_test+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe8f(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xef0(%rip),%r12
mov    %rsp,%r13
lea    0xfc0(%rip),%rbp
lea    0xe62(%rip),%r14
jmp    11bb <run_test+0x5b>
lea    0xf89(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax)
cmpl   $0x0,0x4(%rsp)
jne    127a <run_test+0x11a>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    %r12,%rdi
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <puts@plt>
mov    (%rsp),%edi
test   %edi,%edi
jns    1210 <run_test+0xb0>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%edi
test   %edi,%edi
jns    1210 <run_test+0xb0>
mov    %rbp,%rdi
jmp    11e0 <run_test+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11a0 <run_test+0x40>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
cmp    $0x29,%edi
jb     1239 <run_test+0xd9>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%edi
call   1080 <test_rec@plt>
jmp    11b0 <run_test+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1060 <test_arr@plt>
jmp    11b0 <run_test+0x50>
nopw   0x0(%rax,%rax,1)
call   1050 <test_squ@plt>
jmp    11b0 <run_test+0x50>
nopw   0x0(%rax,%rax,1)
call   1040 <test_squ_2@plt>
jmp    11b0 <run_test+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [107 x i8] c"\ED\85\8C\EC\8A\A4\ED\8A\B8 \ED\95\98\EA\B3\A0\EC\9E\90 \ED\95\98\EB\8A\94 \EC\95\8C\EA\B3\A0\EB\A6\AC\EC\A6\98\EC\9D\84 \EC\84\A0\ED\83\9D\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94\0A1. Recursive\0A2. Array\0A3. Recursive squaring\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [78 x i8] c"\ED\85\8C\EC\8A\A4\ED\8A\B8 \ED\95\98\EA\B3\A0\EC\9E\90 \ED\95\98\EB\8A\94 \EC\B5\9C\EB\8C\80 \EC\88\AB\EC\9E\90\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94(\EC\96\91\EC\9D\98\EC\A0\95\EC\88\98)\0A\00"
@.str.3 = [41 x i8] c"0\EC\9D\B4\EC\83\81\EC\9D\98 \EC\A0\95\EC\88\98\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94\0A\00"
@.str.4 = [103 x i8] c"\EC\A3\BC\EC\9D\98! 40\EB\B2\88\EC\A7\B8 \EC\88\98 \EC\9C\84\EB\A1\9C\EB\8A\94 \EC\97\B0\EC\82\B0\EC\9D\B4 \EC\98\A4\EB\9E\98 \EA\B1\B8\EB\A6\AC\EA\B1\B0\EB\82\98 \EB\A9\94\EB\AA\A8\EB\A6\AC\EA\B0\80 \EB\B6\80\EC\A1\B1\ED\95\A0 \EC\88\98 \EC\9E\88\EC\8A\B5\EB\8B\88\EB\8B\A4.\0A\00"
@.str.5 = [40 x i8] c"\EC\98\AC\EB\B0\94\EB\A5\B8 \EB\B2\88\ED\98\B8\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94\0A\00"
define void @run_test() {
%1 = alloca i32
%2 = alloca i32
store i32 -1, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %42, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %43
7: ; preds = %3
%8 = call i32 @printf(i8* getelementptr inbounds ([107 x i8], [107 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 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %20, %7
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
br label %11
21: ; preds = %11
%22 = load i32, i32* %2
switch i32 %22, label %40 [
i32 1, label %23
i32 2, label %31
i32 3, label %34
i32 4, label %37
]
23: ; preds = %21
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 40
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = load i32, i32* %1
%30 = call i32 @test_rec(i32 %29)
br label %42
31: ; preds = %21
%32 = load i32, i32* %1
%33 = call i32 @test_arr(i32 %32)
br label %42
34: ; preds = %21
%35 = load i32, i32* %1
%36 = call i32 @test_squ(i32 %35)
br label %42
37: ; preds = %21
%38 = load i32, i32* %1
%39 = call i32 @test_squ_2(i32 %38)
br label %42
40: ; preds = %21
%41 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %37, %34, %31, %28
br label %3
43: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [106 x i8] c"\ED\85\8C\EC\8A\A4\ED\8A\B8 \ED\95\98\EA\B3\A0\EC\9E\90 \ED\95\98\EB\8A\94 \EC\95\8C\EA\B3\A0\EB\A6\AC\EC\A6\98\EC\9D\84 \EC\84\A0\ED\83\9D\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94\0A1. Recursive\0A2. Array\0A3. Recursive squaring\00"
@str.6 = [77 x i8] c"\ED\85\8C\EC\8A\A4\ED\8A\B8 \ED\95\98\EA\B3\A0\EC\9E\90 \ED\95\98\EB\8A\94 \EC\B5\9C\EB\8C\80 \EC\88\AB\EC\9E\90\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94(\EC\96\91\EC\9D\98\EC\A0\95\EC\88\98)\00"
@str.7 = [102 x i8] c"\EC\A3\BC\EC\9D\98! 40\EB\B2\88\EC\A7\B8 \EC\88\98 \EC\9C\84\EB\A1\9C\EB\8A\94 \EC\97\B0\EC\82\B0\EC\9D\B4 \EC\98\A4\EB\9E\98 \EA\B1\B8\EB\A6\AC\EA\B1\B0\EB\82\98 \EB\A9\94\EB\AA\A8\EB\A6\AC\EA\B0\80 \EB\B6\80\EC\A1\B1\ED\95\A0 \EC\88\98 \EC\9E\88\EC\8A\B5\EB\8B\88\EB\8B\A4.\00"
@str.8 = [39 x i8] c"\EC\98\AC\EB\B0\94\EB\A5\B8 \EB\B2\88\ED\98\B8\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94\00"
@str.9 = [40 x i8] c"0\EC\9D\B4\EC\83\81\EC\9D\98 \EC\A0\95\EC\88\98\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\B4\EC\A3\BC\EC\84\B8\EC\9A\94\00"
define void @run_test() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %0, %38
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.6, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %5, %15
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 0
br i1 %18, label %11, label %19
19: ; preds = %11, %15, %5
%20 = phi i32 [ %9, %5 ], [ %13, %11 ], [ %17, %15 ]
%21 = load i32, i32* %2
switch i32 %21, label %36 [
i32 1, label %22
i32 2, label %30
i32 3, label %32
i32 4, label %34
]
22: ; preds = %19
%23 = icmp ugt i32 %20, 40
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([102 x i8], [102 x i8]* @str.7, i64 0, i64 0))
%26 = load i32, i32* %1
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ %26, %24 ], [ %20, %22 ]
%29 = call i32 @test_rec(i32 %28)
br label %38
30: ; preds = %19
%31 = call i32 @test_arr(i32 %20)
br label %38
32: ; preds = %19
%33 = call i32 @test_squ(i32 %20)
br label %38
34: ; preds = %19
%35 = call i32 @test_squ_2(i32 %20)
br label %38
36: ; preds = %19
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
br label %38
38: ; preds = %36, %34, %32, %30, %27
%39 = load i32, i32* %2
%40 = icmp eq i32 %39, 0
br i1 %40, label %5, label %41
41: ; preds = %38
ret void
}