#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 lookfor_notzero(int, int, double **, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ swap_row(double *, double *, int);
int make_pivit_notzero(int imax, int jmax, double matrix[imax][jmax], int i,
                       int j) {
  if (matrix[i][j] == 0) {
    int s = lookfor_notzero(imax, jmax, matrix, i + 1, j);
    if (s > 0) {
      swap_row(matrix[i], matrix[s], jmax);
    } else {
      printf("pivit i:%d,j:%d seems to be zero and unswitchable\n", i, j);
    }
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<make_pivit_notzero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%edx
mov    %rdx,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f5 <make_pivit_notzero+0xc5>
jp     11f5 <make_pivit_notzero+0xc5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%r8d
call   1030 <lookfor_notzero@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11de <make_pivit_notzero+0xae>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
imul   %rcx,%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rax
imul   %rcx,%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0xc(%rbp),%edx
call   1050 <swap_row@plt>
jmp    11f0 <make_pivit_notzero+0xc0>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
jmp    11fc <make_pivit_notzero+0xcc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_pivit_notzero>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
movslq %ecx,%rax
imul   %r13,%rax
lea    (%rdx,%rax,8),%r12
movslq %r8d,%rax
movsd  (%r12,%rax,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a5 <make_pivit_notzero+0x75>
jp     11a5 <make_pivit_notzero+0x75>
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%rbp
mov    %esi,%ebx
lea    0x1(%r15),%ecx
call   1030 <lookfor_notzero@plt>
test   %eax,%eax
jle    1193 <make_pivit_notzero+0x63>
mov    %eax,%eax
imul   %r13,%rax
lea    0x0(,%rax,8),%rsi
add    %rbp,%rsi
mov    %r12,%rdi
mov    %ebx,%edx
call   1050 <swap_row@plt>
jmp    11a5 <make_pivit_notzero+0x75>
lea    0xe66(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"pivit i:%d,j:%d seems to be zero and unswitchable\0A\00"
define i32 @make_pivit_notzero(i32 %0, i32 %1, double* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%13 = load i32, i32* %7
%14 = zext i32 %13 to i64
%15 = load i32, i32* %8
%16 = zext i32 %15 to i64
%17 = load double*, double** %9
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = mul nsw i64 %19, %16
%21 = getelementptr inbounds double, double* %17, i64 %20
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %27, label %56
27: ; preds = %5
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = load double*, double** %9
%31 = bitcast double* %30 to double**
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
%34 = load i32, i32* %11
%35 = call i32 @lookfor_notzero(i32 %28, i32 %29, double** %31, i32 %33, i32 %34)
store i32 %35, i32* %12
%36 = load i32, i32* %12
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %27
%39 = load double*, double** %9
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = mul nsw i64 %41, %16
%43 = getelementptr inbounds double, double* %39, i64 %42
%44 = load double*, double** %9
%45 = load i32, i32* %12
%46 = sext i32 %45 to i64
%47 = mul nsw i64 %46, %16
%48 = getelementptr inbounds double, double* %44, i64 %47
%49 = load i32, i32* %8
%50 = call i32 @swap_row(double* %43, double* %48, i32 %49)
br label %55
51: ; preds = %27
%52 = load i32, i32* %10
%53 = load i32, i32* %11
%54 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %52, i32 %53)
br label %55
55: ; preds = %51, %38
br label %57
56: ; preds = %5
store i32 0, i32* %6
br label %57
57: ; preds = %56, %55
%58 = load i32, i32* %6
ret i32 %58
}

LLVM IR (-O2):
@.str = [51 x i8] c"pivit i:%d,j:%d seems to be zero and unswitchable\0A\00"
define i32 @make_pivit_notzero(i32 %0, i32 %1, double* %2, i32 %3, i32 %4) {
%6 = zext i32 %1 to i64
%7 = sext i32 %3 to i64
%8 = mul nsw i64 %7, %6
%9 = getelementptr inbounds double, double* %2, i64 %8
%10 = sext i32 %4 to i64
%11 = getelementptr inbounds double, double* %9, i64 %10
%12 = load double, double* %11
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %14, label %26
14: ; preds = %5
%15 = bitcast double* %2 to double**
%16 = add nsw i32 %3, 1
%17 = tail call i32 @lookfor_notzero(i32 %0, i32 %1, double** %15, i32 %16, i32 %4)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = zext i32 %17 to i64
%21 = mul nuw nsw i64 %20, %6
%22 = getelementptr inbounds double, double* %2, i64 %21
%23 = tail call i32 @swap_row(double* %9, double* %22, i32 %1)
br label %26
24: ; preds = %14
%25 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
br label %26
26: ; preds = %5, %19, %24
ret i32 0
}