#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 get_matrix(unsigned int **, unsigned long, unsigned long);
int /*<<< orphan*/ set_matrix(unsigned int **, unsigned long, unsigned long,
                              unsigned int);
void add_vector_z(unsigned int **M, unsigned long k, unsigned long j,
                  unsigned long n_col) {
  for (unsigned long i = 0; i < n_col; ++i) {
    unsigned int sum = get_matrix(M, k, i) + get_matrix(M, j, i);
    set_matrix(M, k, i, sum);
  }
}


x86 assembly (clang, -O0):
<add_vector_z>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a2 <add_vector_z+0x82>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <get_matrix@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <get_matrix@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <set_matrix@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1140 <add_vector_z+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_vector_z>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rcx,%rcx
je     1179 <add_vector_z+0x59>
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <get_matrix@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <get_matrix@plt>
add    %eax,%ebp
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1040 <set_matrix@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <add_vector_z+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @add_vector_z(i32** %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %7
6: ; preds = %7, %4
ret void
7: ; preds = %4, %7
%8 = phi i64 [ %13, %7 ], [ 0, %4 ]
%9 = tail call i32 @get_matrix(i32** %0, i64 %1, i64 %8)
%10 = tail call i32 @get_matrix(i32** %0, i64 %2, i64 %8)
%11 = add i32 %10, %9
%12 = tail call i32 @set_matrix(i32** %0, i64 %1, i64 %8, i32 %11)
%13 = add nuw i64 %8, 1
%14 = icmp eq i64 %13, %3
br i1 %14, label %6, label %7
}