#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 */
struct BitVector {
  int dummy;
};
struct BitMatrix {
  int dummy;
};

/* Variables and functions */
struct BitVector *BitMatrixGetCol(struct BitMatrix *, unsigned int);
int /*<<< orphan*/ BitMatrixSetCol(struct BitMatrix *, struct BitVector *,
                                   unsigned int);
int /*<<< orphan*/ BitVectorFree(struct BitVector *);
void BitMatrixSwapCols(struct BitMatrix *mat, unsigned int col1,
                       unsigned int col2) {
  struct BitVector *col1v = BitMatrixGetCol(mat, col1);
  struct BitVector *col2v = BitMatrixGetCol(mat, col2);
  BitMatrixSetCol(mat, col2v, col1);
  BitMatrixSetCol(mat, col1v, col2);
  BitVectorFree(col1v);
  BitVectorFree(col2v);
}


x86 assembly (clang, -O0):
<BitMatrixSwapCols>:
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),%esi
call   1030 <BitMatrixGetCol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <BitMatrixGetCol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <BitMatrixSetCol@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <BitMatrixSetCol@plt>
mov    -0x18(%rbp),%rdi
call   1050 <BitVectorFree@plt>
mov    -0x20(%rbp),%rdi
call   1050 <BitVectorFree@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BitMatrixSwapCols>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <BitMatrixGetCol@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <BitMatrixGetCol@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1040 <BitMatrixSetCol@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <BitMatrixSetCol@plt>
mov    %r15,%rdi
call   1050 <BitVectorFree@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <BitVectorFree@plt>

LLVM IR (-O0):
%struct.BitMatrix = type { i32 }
%struct.BitVector = type { i32 }
define void @BitMatrixSwapCols(%struct.BitMatrix* %0, i32 %1, i32 %2) {
%4 = alloca %struct.BitMatrix*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.BitVector*
%8 = alloca %struct.BitVector*
store %struct.BitMatrix* %0, %struct.BitMatrix** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load %struct.BitMatrix*, %struct.BitMatrix** %4
%10 = load i32, i32* %5
%11 = call %struct.BitVector* @BitMatrixGetCol(%struct.BitMatrix* %9, i32 %10)
store %struct.BitVector* %11, %struct.BitVector** %7
%12 = load %struct.BitMatrix*, %struct.BitMatrix** %4
%13 = load i32, i32* %6
%14 = call %struct.BitVector* @BitMatrixGetCol(%struct.BitMatrix* %12, i32 %13)
store %struct.BitVector* %14, %struct.BitVector** %8
%15 = load %struct.BitMatrix*, %struct.BitMatrix** %4
%16 = load %struct.BitVector*, %struct.BitVector** %8
%17 = load i32, i32* %5
%18 = call i32 @BitMatrixSetCol(%struct.BitMatrix* %15, %struct.BitVector* %16, i32 %17)
%19 = load %struct.BitMatrix*, %struct.BitMatrix** %4
%20 = load %struct.BitVector*, %struct.BitVector** %7
%21 = load i32, i32* %6
%22 = call i32 @BitMatrixSetCol(%struct.BitMatrix* %19, %struct.BitVector* %20, i32 %21)
%23 = load %struct.BitVector*, %struct.BitVector** %7
%24 = call i32 @BitVectorFree(%struct.BitVector* %23)
%25 = load %struct.BitVector*, %struct.BitVector** %8
%26 = call i32 @BitVectorFree(%struct.BitVector* %25)
ret void
}

LLVM IR (-O2):
%struct.BitMatrix = type { i32 }
%struct.BitVector = type { i32 }
define void @BitMatrixSwapCols(%struct.BitMatrix* %0, i32 %1, i32 %2) {
%4 = tail call %struct.BitVector* @BitMatrixGetCol(%struct.BitMatrix* %0, i32 %1)
%5 = tail call %struct.BitVector* @BitMatrixGetCol(%struct.BitMatrix* %0, i32 %2)
%6 = tail call i32 @BitMatrixSetCol(%struct.BitMatrix* %0, %struct.BitVector* %5, i32 %1)
%7 = tail call i32 @BitMatrixSetCol(%struct.BitMatrix* %0, %struct.BitVector* %4, i32 %2)
%8 = tail call i32 @BitVectorFree(%struct.BitVector* %4)
%9 = tail call i32 @BitVectorFree(%struct.BitVector* %5)
ret void
}