#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*/ print_left_right(int, int);
int /*<<< orphan*/ print_vector(int *);
void swap(int vector[], int element_a, int element_b) {
  int place_holder;
  if (vector[element_a] > vector[element_b]) {
    print_vector(vector);
    print_left_right(element_a, element_b);
    place_holder = vector[element_a];
    vector[element_a] = vector[element_b];
    vector[element_b] = place_holder;
  }
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1194 <swap+0x74>
mov    -0x8(%rbp),%rdi
call   1030 <print_vector@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <print_left_right@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
push   %r15
push   %r14
push   %rbx
movslq %esi,%r14
mov    (%rdi,%r14,4),%eax
movslq %edx,%r15
cmp    (%rdi,%r15,4),%eax
jle    1158 <swap+0x38>
mov    %rdi,%rbx
call   1030 <print_vector@plt>
mov    %r14d,%edi
mov    %r15d,%esi
call   1040 <print_left_right@plt>
mov    (%rbx,%r14,4),%eax
mov    (%rbx,%r15,4),%ecx
mov    %ecx,(%rbx,%r14,4)
mov    %eax,(%rbx,%r15,4)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @swap(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32*, i32** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
%12 = load i32, i32* %11
%13 = load i32*, i32** %4
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = icmp sgt i32 %12, %17
br i1 %18, label %19, label %44
19: ; preds = %3
%20 = load i32*, i32** %4
%21 = call i32 @print_vector(i32* %20)
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 @print_left_right(i32 %22, i32 %23)
%25 = load i32*, i32** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
store i32 %29, i32* %7
%30 = load i32*, i32** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i32*, i32** %4
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
%39 = load i32, i32* %7
%40 = load i32*, i32** %4
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
store i32 %39, i32* %43
br label %44
44: ; preds = %19, %3
ret void
}

LLVM IR (-O2):
define void @swap(i32* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i32, i32* %0, i64 %4
%6 = load i32, i32* %5
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = icmp sgt i32 %6, %9
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = tail call i32 @print_vector(i32* %0)
%13 = tail call i32 @print_left_right(i32 %1, i32 %2)
%14 = load i32, i32* %5
%15 = load i32, i32* %8
store i32 %15, i32* %5
store i32 %14, i32* %8
br label %16
16: ; preds = %11, %3
ret void
}