#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 */
scalar_t__ getCosto(int *, int *, int);
scalar_t__ isBalanced(int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ memcpy(int *, int *, int);
void autoUpdateSolution(int *f, int *sol, int *bestSol, int n) {
  if (getCosto(f, sol, n) < getCosto(f, bestSol, n) && isBalanced(0, sol, n)) {
    memcpy(bestSol, sol, n * sizeof(int));
  }
}


x86 assembly (clang, -O0):
<autoUpdateSolution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <getCosto@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <getCosto@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    11aa <autoUpdateSolution+0x7a>
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %edi,%edi
call   1040 <isBalanced@plt>
cmp    $0x0,%rax
je     11aa <autoUpdateSolution+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<autoUpdateSolution>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %ecx,%edx
call   1030 <getCosto@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <getCosto@plt>
cmp    %rax,%r12
jge    1188 <autoUpdateSolution+0x58>
xor    %edi,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <isBalanced@plt>
test   %rax,%rax
je     1188 <autoUpdateSolution+0x58>
shl    $0x2,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <memcpy@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @autoUpdateSolution(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%9 = load i32*, i32** %5
%10 = load i32*, i32** %6
%11 = load i32, i32* %8
%12 = call i64 @getCosto(i32* %9, i32* %10, i32 %11)
%13 = load i32*, i32** %5
%14 = load i32*, i32** %7
%15 = load i32, i32* %8
%16 = call i64 @getCosto(i32* %13, i32* %14, i32 %15)
%17 = icmp slt i64 %12, %16
br i1 %17, label %18, label %31
18: ; preds = %4
%19 = load i32*, i32** %6
%20 = load i32, i32* %8
%21 = call i64 @isBalanced(i32 0, i32* %19, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %18
%24 = load i32*, i32** %7
%25 = load i32*, i32** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i32 @memcpy(i32* %24, i32* %25, i32 %29)
br label %31
31: ; preds = %23, %18, %4
ret void
}

LLVM IR (-O2):
define void @autoUpdateSolution(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = tail call i64 @getCosto(i32* %0, i32* %1, i32 %3)
%6 = tail call i64 @getCosto(i32* %0, i32* %2, i32 %3)
%7 = icmp slt i64 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = tail call i64 @isBalanced(i32 0, i32* %1, i32 %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = shl i32 %3, 2
%13 = tail call i32 @memcpy(i32* %2, i32* %1, i32 %12)
br label %14
14: ; preds = %11, %8, %4
ret void
}