#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 */
float *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ solve(float **, int, int);
int main(void) {
  float **arr;
  int i, j, n, choice;
  printf("Enter no. of variables : ");
  scanf("%d", &n);
  arr = (float **)malloc(n * sizeof(float *));
  for (i = 0; i < n; i++)
    arr[i] = malloc((n + 1) * sizeof(float));
  for (i = 0; i < n; i++) {
    printf(
        "Enter the co-efficient of variables and constant term of eqn. %d : \n",
        i + 1);
    for (j = 0; j < (n + 1); j++)
      scanf("%f", &arr[i][j]);
  }
  printf("Enter 1 pivoting else enter 0:");
  scanf("%d", &choice);
  if (choice)
    solve(arr, n, 1);
  else
    solve(arr, n, 0);
  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   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c5 <main+0x85>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <main+0x49>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    124a <main+0x10a>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1237 <main+0xf7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f3 <main+0xb3>
jmp    123c <main+0xfc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cc <main+0x8c>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdbb(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x0,-0x20(%rbp)
je     128a <main+0x14a>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x1,%edx
call   1030 <solve@plt>
jmp    1298 <main+0x158>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %edx,%edx
call   1030 <solve@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    (%rsp),%r14d
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1220 <main+0xe0>
lea    0x4(,%r14,4),%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11a0 <main+0x60>
test   %r14d,%r14d
jle    1220 <main+0xe0>
lea    0xe5d(%rip),%r14
lea    0xe9b(%rip),%r13
xor    %r12d,%r12d
jmp    11d7 <main+0x97>
nopl   0x0(%rax)
cltq
cmp    %rax,%r12
jge    1220 <main+0xe0>
mov    %r12,%rbx
add    $0x1,%r12
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%eax
test   %eax,%eax
js     11d0 <main+0x90>
mov    (%r15,%rbx,8),%rbx
mov    $0xffffffffffffffff,%rbp
nopl   (%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movslq (%rsp),%rax
add    $0x1,%rbp
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1200 <main+0xc0>
jmp    11d0 <main+0x90>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde5(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %edx,%edx
cmpl   $0x0,0x4(%rsp)
setne  %dl
mov    (%rsp),%esi
mov    %r15,%rdi
call   1030 <solve@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter no. of variables : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [69 x i8] c"Enter the co-efficient of variables and constant term of eqn. %d : \0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [31 x i8] c"Enter 1 pivoting else enter 0:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float**
%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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call float* @malloc(i32 %12)
%14 = bitcast float* %13 to float**
store float** %14, float*** %2
store i32 0, i32* %3
br label %15
15: ; preds = %30, %0
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call float* @malloc(i32 %24)
%26 = load float**, float*** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float*, float** %26, i64 %28
store float* %25, float** %29
br label %30
30: ; preds = %19
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %15
33: ; preds = %15
store i32 0, i32* %3
br label %34
34: ; preds = %61, %33
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %64
38: ; preds = %34
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0), i32 %40)
store i32 0, i32* %4
br label %42
42: ; preds = %57, %38
%43 = load i32, i32* %4
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
%46 = icmp slt i32 %43, %45
br i1 %46, label %47, label %60
47: ; preds = %42
%48 = load float**, float*** %2
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds float*, float** %48, i64 %50
%52 = load float*, float** %51
%53 = load i32, i32* %4
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds float, float* %52, i64 %54
%56 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %55)
br label %57
57: ; preds = %47
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %42
60: ; preds = %42
br label %61
61: ; preds = %60
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %34
64: ; preds = %34
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%67 = load i32, i32* %6
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %64
%70 = load float**, float*** %2
%71 = load i32, i32* %5
%72 = call i32 @solve(float** %70, i32 %71, i32 1)
br label %77
73: ; preds = %64
%74 = load float**, float*** %2
%75 = load i32, i32* %5
%76 = call i32 @solve(float** %74, i32 %75, i32 0)
br label %77
77: ; preds = %73, %69
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter no. of variables : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [69 x i8] c"Enter the co-efficient of variables and constant term of eqn. %d : \0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [31 x i8] c"Enter 1 pivoting else enter 0:\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = shl i32 %7, 3
%9 = call float* @malloc(i32 %8)
%10 = bitcast float* %9 to float**
%11 = icmp sgt i32 %7, 0
br i1 %11, label %12, label %45
12: ; preds = %0
%13 = shl i32 %7, 2
%14 = add i32 %13, 4
%15 = zext i32 %7 to i64
br label %17
16: ; preds = %17
br i1 %11, label %27, label %45
17: ; preds = %12, %17
%18 = phi i64 [ 0, %12 ], [ %21, %17 ]
%19 = call float* @malloc(i32 %14)
%20 = getelementptr inbounds float*, float** %10, i64 %18
store float* %19, float** %20
%21 = add nuw nsw i64 %18, 1
%22 = icmp eq i64 %21, %15
br i1 %22, label %16, label %17
23: ; preds = %37, %27
%24 = phi i32 [ %32, %27 ], [ %42, %37 ]
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %29, %25
br i1 %26, label %27, label %45
27: ; preds = %16, %23
%28 = phi i64 [ %29, %23 ], [ 0, %16 ]
%29 = add nuw nsw i64 %28, 1
%30 = trunc i64 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %1
%33 = icmp slt i32 %32, 0
br i1 %33, label %23, label %34
34: ; preds = %27
%35 = getelementptr inbounds float*, float** %10, i64 %28
%36 = load float*, float** %35
br label %37
37: ; preds = %34, %37
%38 = phi i64 [ 0, %34 ], [ %41, %37 ]
%39 = getelementptr inbounds float, float* %36, i64 %38
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %39)
%41 = add nuw nsw i64 %38, 1
%42 = load i32, i32* %1
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %38, %43
br i1 %44, label %37, label %23
45: ; preds = %23, %0, %16
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 0
%50 = load i32, i32* %1
%51 = zext i1 %49 to i32
%52 = call i32 @solve(float** %10, i32 %50, i32 %51)
ret i32 0
}