#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 */
size_t mat_to_arr(int, unsigned int, unsigned int);
unsigned int neg_nums_in_row(int *arr, int row, unsigned int rows,
                             unsigned int columns) {
  int res = 0;
  for (unsigned int col = 1; col <= columns; col++)
    if (arr[mat_to_arr(row, col, columns)] < 0)
      res++;
  return res;
}


x86 assembly (clang, -O0):
<neg_nums_in_row>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
ja     1182 <neg_nums_in_row+0x72>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <mat_to_arr@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax,%rcx,4)
jge    116f <neg_nums_in_row+0x5f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <neg_nums_in_row+0x64>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <neg_nums_in_row+0x23>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neg_nums_in_row>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
je     1150 <neg_nums_in_row+0x40>
mov    %ecx,%r12d
mov    %esi,%r14d
mov    %rdi,%r15
xor    %ebp,%ebp
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    %r14d,%edi
mov    %ebx,%esi
mov    %r12d,%edx
call   1030 <mat_to_arr@plt>
mov    (%r15,%rax,4),%eax
shr    $0x1f,%eax
add    %eax,%ebp
add    $0x1,%ebx
cmp    %r12d,%ebx
jbe    1130 <neg_nums_in_row+0x20>
jmp    1152 <neg_nums_in_row+0x42>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @neg_nums_in_row(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
br label %11
11: ; preds = %28, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %8
%14 = icmp ule i32 %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = load i32, i32* %6
%18 = load i32, i32* %10
%19 = load i32, i32* %8
%20 = call i64 @mat_to_arr(i32 %17, i32 %18, i32 %19)
%21 = getelementptr inbounds i32, i32* %16, i64 %20
%22 = load i32, i32* %21
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %27
27: ; preds = %24, %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %10
%30 = add i32 %29, 1
store i32 %30, i32* %10
br label %11
31: ; preds = %11
%32 = load i32, i32* %9
ret i32 %32
}

LLVM IR (-O2):
define i32 @neg_nums_in_row(i32* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %8, %4
%7 = phi i32 [ 0, %4 ], [ %15, %8 ]
ret i32 %7
8: ; preds = %4, %8
%9 = phi i32 [ %16, %8 ], [ 1, %4 ]
%10 = phi i32 [ %15, %8 ], [ 0, %4 ]
%11 = tail call i64 @mat_to_arr(i32 %1, i32 %9, i32 %3)
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = lshr i32 %13, 31
%15 = add nuw nsw i32 %14, %10
%16 = add i32 %9, 1
%17 = icmp ugt i32 %16, %3
br i1 %17, label %6, label %8
}