#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 /*<<< orphan*/ swap(int *, int *);
void col(int a[][4], int i, int j) {
  for (int k = 0; k < 4; ++k) {
    swap((int *)a + i * 4 + k, (int *)a + j * 4 + k);
  }
}


x86 assembly (clang, -O0):
<col>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1182 <col+0x72>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <col+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<col>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
shl    $0x2,%esi
movslq %esi,%r14
lea    (%rdi,%r14,4),%rdi
shl    $0x2,%edx
movslq %edx,%r15
lea    (%rbx,%r15,4),%rsi
call   1030 <swap@plt>
lea    (%rbx,%r14,4),%rdi
add    $0x4,%rdi
lea    (%rbx,%r15,4),%rsi
add    $0x4,%rsi
call   1030 <swap@plt>
lea    (%rbx,%r14,4),%rdi
add    $0x8,%rdi
lea    (%rbx,%r15,4),%rsi
add    $0x8,%rsi
call   1030 <swap@plt>
lea    (%rbx,%r14,4),%rdi
add    $0xc,%rdi
lea    0xc(%rbx,%r15,4),%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <swap@plt>

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

LLVM IR (-O2):
define void @col([4 x i32]* %0, i32 %1, i32 %2) {
%4 = shl nsw i32 %1, 2
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 %5
%7 = shl nsw i32 %2, 2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 %8
%10 = tail call i32 @swap(i32* %6, i32* %9)
%11 = getelementptr inbounds i32, i32* %6, i64 1
%12 = getelementptr inbounds i32, i32* %9, i64 1
%13 = tail call i32 @swap(i32* %11, i32* %12)
%14 = getelementptr inbounds i32, i32* %6, i64 2
%15 = getelementptr inbounds i32, i32* %9, i64 2
%16 = tail call i32 @swap(i32* %14, i32* %15)
%17 = getelementptr inbounds i32, i32* %6, i64 3
%18 = getelementptr inbounds i32, i32* %9, i64 3
%19 = tail call i32 @swap(i32* %17, i32* %18)
ret void
}