#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 *BitMatrixGetRow(struct BitMatrix *, unsigned int);
int /*<<< orphan*/ BitMatrixSetRow(struct BitMatrix *, struct BitVector *,
                                   unsigned int);
int /*<<< orphan*/ BitVectorFree(struct BitVector *);
void BitMatrixSwapRows(struct BitMatrix *mat, unsigned int row1,
                       unsigned int row2) {
  struct BitVector *row1v = BitMatrixGetRow(mat, row1);
  struct BitVector *row2v = BitMatrixGetRow(mat, row2);
  BitMatrixSetRow(mat, row2v, row1);
  BitMatrixSetRow(mat, row1v, row2);
  BitVectorFree(row1v);
  BitVectorFree(row2v);
}


x86 assembly (clang, -O0):
<BitMatrixSwapRows>:
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 <BitMatrixGetRow@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <BitMatrixGetRow@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <BitMatrixSetRow@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <BitMatrixSetRow@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):
<BitMatrixSwapRows>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <BitMatrixGetRow@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <BitMatrixGetRow@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1040 <BitMatrixSetRow@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <BitMatrixSetRow@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 @BitMatrixSwapRows(%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* @BitMatrixGetRow(%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* @BitMatrixGetRow(%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 @BitMatrixSetRow(%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 @BitMatrixSetRow(%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 @BitMatrixSwapRows(%struct.BitMatrix* %0, i32 %1, i32 %2) {
%4 = tail call %struct.BitVector* @BitMatrixGetRow(%struct.BitMatrix* %0, i32 %1)
%5 = tail call %struct.BitVector* @BitMatrixGetRow(%struct.BitMatrix* %0, i32 %2)
%6 = tail call i32 @BitMatrixSetRow(%struct.BitMatrix* %0, %struct.BitVector* %5, i32 %1)
%7 = tail call i32 @BitMatrixSetRow(%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
}