#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*/ Interactive_Test(int);
int /*<<< orphan*/ Random_Test(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int ans, n;
  srand(time(NULL));
  printf("\nTesting inverse function for matrices of complex doubles.\n");
  for (;;) {
    printf("\nChoose one of the following options:\n");
    printf("  0. exit the loop; or\n");
    printf("  1. test on randomly generated matrices; or\n");
    printf("  2. test user-given linear system.\n");
    printf("Type 0, 1, or 2 to select : ");
    scanf("%d", &ans);
    if (ans == 0)
      break;
    if ((ans == 1) || (ans == 2)) {
      printf("\nGive the dimension : ");
      scanf("%d", &n);
      if (ans == 1)
        Random_Test(n);
      else
        Interactive_Test(n);
    } else
      printf("Invalid choice.  Please try again...\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11e6 <main+0x86>
jmp    124b <main+0xeb>
cmpl   $0x1,-0x8(%rbp)
je     11fa <main+0x9a>
cmpl   $0x2,-0x8(%rbp)
jne    123a <main+0xda>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    122d <main+0xcd>
mov    -0xc(%rbp),%edi
call   1080 <Random_Test@plt>
jmp    1235 <main+0xd5>
mov    -0xc(%rbp),%edi
call   1070 <Interactive_Test@plt>
jmp    1246 <main+0xe6>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <main+0x2b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     12a7 <main+0x137>
lea    0xe2b(%rip),%rbx
lea    0xe9f(%rip),%r13
lea    0xeaf(%rip),%rbp
lea    0xed5(%rip),%r14
lea    0xdf2(%rip),%r15
mov    %rsp,%r12
jmp    126a <main+0xfa>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     12a7 <main+0x137>
add    $0xffffffff,%eax
cmp    $0x1,%eax
ja     1220 <main+0xb0>
lea    0xda7(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,(%rsp)
mov    0x4(%rsp),%edi
jne    12a0 <main+0x130>
call   1090 <Random_Test@plt>
jmp    122c <main+0xbc>
nopl   0x0(%rax)
call   1080 <Interactive_Test@plt>
jmp    122c <main+0xbc>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"\0ATesting inverse function for matrices of complex doubles.\0A\00"
@.str.1 = [39 x i8] c"\0AChoose one of the following options:\0A\00"
@.str.2 = [24 x i8] c" 0. exit the loop; or\0A\00"
@.str.3 = [46 x i8] c" 1. test on randomly generated matrices; or\0A\00"
@.str.4 = [37 x i8] c" 2. test user-given linear system.\0A\00"
@.str.5 = [29 x i8] c"Type 0, 1, or 2 to select : \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [23 x i8] c"\0AGive the dimension : \00"
@.str.8 = [38 x i8] c"Invalid choice. Please try again...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %37, %0
%8 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %7
br label %38
17: ; preds = %7
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %35
23: ; preds = %20, %17
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i32, i32* %3
%30 = call i32 @Random_Test(i32 %29)
br label %34
31: ; preds = %23
%32 = load i32, i32* %3
%33 = call i32 @Interactive_Test(i32 %32)
br label %34
34: ; preds = %31, %28
br label %37
35: ; preds = %20
%36 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %37
37: ; preds = %35, %34
br label %7
38: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [29 x i8] c"Type 0, 1, or 2 to select : \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [23 x i8] c"\0AGive the dimension : \00"
@str = [59 x i8] c"\0ATesting inverse function for matrices of complex doubles.\00"
@str.9 = [38 x i8] c"\0AChoose one of the following options:\00"
@str.10 = [23 x i8] c" 0. exit the loop; or\00"
@str.11 = [45 x i8] c" 1. test on randomly generated matrices; or\00"
@str.12 = [36 x i8] c" 2. test user-given linear system.\00"
@str.13 = [37 x i8] c"Invalid choice. Please try again...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.12, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 0
br i1 %15, label %41, label %16
16: ; preds = %0, %32
%17 = phi i32 [ %39, %32 ], [ %14, %0 ]
%18 = add i32 %17, -1
%19 = icmp ult i32 %18, 2
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 1
%25 = load i32, i32* %2
br i1 %24, label %26, label %28
26: ; preds = %20
%27 = call i32 @Random_Test(i32 %25)
br label %32
28: ; preds = %20
%29 = call i32 @Interactive_Test(i32 %25)
br label %32
30: ; preds = %16
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.13, i64 0, i64 0))
br label %32
32: ; preds = %26, %28, %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0))
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.11, i64 0, i64 0))
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.12, i64 0, i64 0))
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%39 = load i32, i32* %1
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %16
41: ; preds = %32, %0
ret i32 0
}