#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 min_el(int *, int);
int otr_el(int *, int);
int /*<<< orphan*/ printf(char *);
int change_els(int *arr, int size) {
  int buf;
  int minel, otrel;
  minel = min_el(arr, size);
  otrel = otr_el(arr, size);
  if (otrel == -4) {
    printf("Can't change cause there is no otr elements");
    return 0;
  } else {
    buf = arr[minel];
    arr[minel] = arr[otrel];
    arr[otrel] = buf;
  }
  return 0;
}


x86 assembly (clang, -O0):
<change_els>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <min_el@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <otr_el@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xfffffffc,-0x20(%rbp)
jne    117f <change_els+0x4f>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <change_els+0x88>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_els>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <min_el@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <otr_el@plt>
cmp    $0xfffffffc,%eax
jne    115e <change_els+0x2e>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
jmp    116f <change_els+0x3f>
movslq %r14d,%rcx
mov    (%rbx,%rcx,4),%edx
cltq
mov    (%rbx,%rax,4),%esi
mov    %esi,(%rbx,%rcx,4)
mov    %edx,(%rbx,%rax,4)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Can't change cause there is no otr elements\00"
define i32 @change_els(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%9 = load i32*, i32** %4
%10 = load i32, i32* %5
%11 = call i32 @min_el(i32* %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32*, i32** %4
%13 = load i32, i32* %5
%14 = call i32 @otr_el(i32* %12, i32 %13)
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, -4
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %40
19: ; preds = %2
%20 = load i32*, i32** %4
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %6
%25 = load i32*, i32** %4
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32*, i32** %4
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
%34 = load i32, i32* %6
%35 = load i32*, i32** %4
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %19
store i32 0, i32* %3
br label %40
40: ; preds = %39, %17
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [44 x i8] c"Can't change cause there is no otr elements\00"
define i32 @change_els(i32* %0, i32 %1) {
%3 = tail call i32 @min_el(i32* %0, i32 %1)
%4 = tail call i32 @otr_el(i32* %0, i32 %1)
%5 = icmp eq i32 %4, -4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %15
8: ; preds = %2
%9 = sext i32 %3 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
store i32 %14, i32* %10
store i32 %11, i32* %13
br label %15
15: ; preds = %8, %6
ret i32 0
}