#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 */
unsigned int neg_nums_in_row(int *, int, unsigned int, unsigned int);
unsigned int row_with_max_negs(int *arr, unsigned int rows,
                               unsigned int columns) {
  unsigned int max_num = neg_nums_in_row(arr, 1, rows, columns);
  unsigned int max_index = 1;
  for (int row = 2; row <= rows; row++)
    if (neg_nums_in_row(arr, row, rows, columns) > max_num) {
      max_num = neg_nums_in_row(arr, row, rows, columns);
      max_index = row;
    };
  return max_index;
}


x86 assembly (clang, -O0):
<row_with_max_negs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    $0x1,%esi
call   1030 <neg_nums_in_row@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     119c <row_with_max_negs+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <neg_nums_in_row@plt>
cmp    -0x14(%rbp),%eax
jbe    1189 <row_with_max_negs+0x79>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <neg_nums_in_row@plt>
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118e <row_with_max_negs+0x7e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <row_with_max_negs+0x37>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<row_with_max_negs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r13d
mov    %rdi,%r12
movl   $0x1,0x4(%rsp)
mov    $0x1,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
call   1030 <neg_nums_in_row@plt>
cmp    $0x2,%r13d
jae    1155 <row_with_max_negs+0x45>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    %r13d,%r15d
neg    %r15d
movl   $0x1,0x4(%rsp)
mov    $0x2,%ebp
jmp    1183 <row_with_max_negs+0x73>
nopl   0x0(%rax)
lea    (%r15,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     1142 <row_with_max_negs+0x32>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
call   1030 <neg_nums_in_row@plt>
cmp    %ebx,%eax
jbe    1170 <row_with_max_negs+0x60>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
call   1030 <neg_nums_in_row@plt>
mov    %eax,%ebx
mov    %ebp,%eax
mov    %ebp,0x4(%rsp)
jmp    1170 <row_with_max_negs+0x60>

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

LLVM IR (-O2):
define i32 @row_with_max_negs(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @neg_nums_in_row(i32* %0, i32 1, i32 %1, i32 %2)
%5 = icmp ult i32 %1, 2
br i1 %5, label %6, label %8
6: ; preds = %16, %3
%7 = phi i32 [ 1, %3 ], [ %18, %16 ]
ret i32 %7
8: ; preds = %3, %16
%9 = phi i32 [ %19, %16 ], [ 2, %3 ]
%10 = phi i32 [ %18, %16 ], [ 1, %3 ]
%11 = phi i32 [ %17, %16 ], [ %4, %3 ]
%12 = tail call i32 @neg_nums_in_row(i32* %0, i32 %9, i32 %1, i32 %2)
%13 = icmp ugt i32 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 @neg_nums_in_row(i32* %0, i32 %9, i32 %1, i32 %2)
br label %16
16: ; preds = %8, %14
%17 = phi i32 [ %15, %14 ], [ %11, %8 ]
%18 = phi i32 [ %9, %14 ], [ %10, %8 ]
%19 = add nuw i32 %9, 1
%20 = icmp eq i32 %9, %1
br i1 %20, label %6, label %8
}