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


x86 assembly (clang, -O0):
<row>:
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 <row+0x72>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x10(%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 <row+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<row>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
movslq %esi,%r14
movslq %edx,%r15
lea    (%rdi,%r14,4),%rdi
lea    (%rbx,%r15,4),%rsi
call   1030 <swap@plt>
lea    (%rbx,%r14,4),%rdi
add    $0x10,%rdi
lea    (%rbx,%r15,4),%rsi
add    $0x10,%rsi
call   1030 <swap@plt>
lea    (%rbx,%r14,4),%rdi
add    $0x20,%rdi
lea    (%rbx,%r15,4),%rsi
add    $0x20,%rsi
call   1030 <swap@plt>
lea    (%rbx,%r14,4),%rdi
add    $0x30,%rdi
lea    0x30(%rbx,%r15,4),%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <swap@plt>

LLVM IR (-O0):
define void @row([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* %7
%15 = mul nsw i32 %14, 4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %13, i64 %16
%18 = load i32, i32* %5
%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* %7
%24 = mul nsw i32 %23, 4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
%27 = load i32, i32* %6
%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 @row([4 x i32]* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 %4
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 %5
%8 = tail call i32 @swap(i32* %6, i32* %7)
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 4
%10 = getelementptr inbounds i32, i32* %9, i64 %4
%11 = getelementptr inbounds i32, i32* %9, i64 %5
%12 = tail call i32 @swap(i32* %10, i32* %11)
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 8
%14 = getelementptr inbounds i32, i32* %13, i64 %4
%15 = getelementptr inbounds i32, i32* %13, i64 %5
%16 = tail call i32 @swap(i32* %14, i32* %15)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 0, i64 12
%18 = getelementptr inbounds i32, i32* %17, i64 %4
%19 = getelementptr inbounds i32, i32* %17, i64 %5
%20 = tail call i32 @swap(i32* %18, i32* %19)
ret void
}