#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 mint_network {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ mint_network_cpy(struct mint_network *,
                                    struct mint_network *);
int /*<<< orphan*/ mint_network_del(struct mint_network *);
struct mint_network *mint_network_dup(struct mint_network *);
float mint_random_search(struct mint_network *net1,
                         float (*perf)(struct mint_network *),
                         void (*mut)(struct mint_network *), float target,
                         long max) {
  float p1, p2;
  long count = 0;
  struct mint_network *net2 = mint_network_dup(net1);
  p1 = perf(net1);
  while (p1 < target && count++ < max) {
    mut(net2);
    p2 = perf(net2);
    if (p2 > p1) {
      p1 = p2;
      mint_network_cpy(net1, net2);
    } else {
      mint_network_cpy(net2, net1);
    }
  }
  mint_network_del(net2);
  return p1;
}


x86 assembly (clang, -O0):
<mint_random_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <mint_network_dup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rdi
call   *%rax
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
xor    %eax,%eax
ucomiss %xmm1,%xmm0
mov    %al,-0x41(%rbp)
jbe    11a2 <mint_random_search+0x72>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
cmp    -0x28(%rbp),%rax
setl   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11b2 <mint_random_search+0x82>
jmp    1208 <mint_random_search+0xd8>
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rdi
call   *%rax
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%rdi
call   *%rax
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    11f6 <mint_random_search+0xc6>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <mint_network_cpy@plt>
jmp    1203 <mint_random_search+0xd3>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <mint_network_cpy@plt>
jmp    1171 <mint_random_search+0x41>
mov    -0x40(%rbp),%rdi
call   1050 <mint_network_del@plt>
movss  -0x2c(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mint_random_search>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
movss  %xmm0,0x4(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <mint_network_dup@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   *%r15
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
movss  %xmm0,(%rsp)
jbe    11c5 <mint_random_search+0x95>
xor    %ebp,%ebp
test   %r13,%r13
cmovg  %r13,%rbp
add    $0x1,%rbp
jmp    11a0 <mint_random_search+0x70>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <mint_network_cpy@plt>
movss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
movss  %xmm0,(%rsp)
ucomiss %xmm0,%xmm1
jbe    11c5 <mint_random_search+0x95>
add    $0xffffffffffffffff,%rbp
je     11c5 <mint_random_search+0x95>
mov    %rbx,%rdi
call   *%r14
mov    %rbx,%rdi
call   *%r15
ucomiss (%rsp),%xmm0
jbe    1180 <mint_random_search+0x50>
mov    %r12,%rdi
mov    %rbx,%rsi
movss  %xmm0,(%rsp)
jmp    1186 <mint_random_search+0x56>
mov    %rbx,%rdi
call   1050 <mint_network_del@plt>
movss  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mint_network = type { i32 }
define float @mint_random_search(%struct.mint_network* %0, float (%struct.mint_network*)* %1, void (%struct.mint_network*)* %2, float %3, i64 %4) {
%6 = alloca %struct.mint_network*
%7 = alloca float (%struct.mint_network*)*
%8 = alloca void (%struct.mint_network*)*
%9 = alloca float
%10 = alloca i64
%11 = alloca float
%12 = alloca float
%13 = alloca i64
%14 = alloca %struct.mint_network*
store %struct.mint_network* %0, %struct.mint_network** %6
store float (%struct.mint_network*)* %1, float (%struct.mint_network*)** %7
store void (%struct.mint_network*)* %2, void (%struct.mint_network*)** %8
store float %3, float* %9
store i64 %4, i64* %10
store i64 0, i64* %13
%15 = load %struct.mint_network*, %struct.mint_network** %6
%16 = call %struct.mint_network* @mint_network_dup(%struct.mint_network* %15)
store %struct.mint_network* %16, %struct.mint_network** %14
%17 = load float (%struct.mint_network*)*, float (%struct.mint_network*)** %7
%18 = load %struct.mint_network*, %struct.mint_network** %6
%19 = call float %17(%struct.mint_network* %18)
store float %19, float* %11
br label %20
20: ; preds = %49, %5
%21 = load float, float* %11
%22 = load float, float* %9
%23 = fcmp olt float %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i64, i64* %13
%26 = add nsw i64 %25, 1
store i64 %26, i64* %13
%27 = load i64, i64* %10
%28 = icmp slt i64 %25, %27
br label %29
29: ; preds = %24, %20
%30 = phi i1 [ false, %20 ], [ %28, %24 ]
br i1 %30, label %31, label %50
31: ; preds = %29
%32 = load void (%struct.mint_network*)*, void (%struct.mint_network*)** %8
%33 = load %struct.mint_network*, %struct.mint_network** %14
%34 = load float (%struct.mint_network*)*, float (%struct.mint_network*)** %7
%35 = load %struct.mint_network*, %struct.mint_network** %14
%36 = call float %34(%struct.mint_network* %35)
store float %36, float* %12
%37 = load float, float* %12
%38 = load float, float* %11
%39 = fcmp ogt float %37, %38
br i1 %39, label %40, label %45
40: ; preds = %31
%41 = load float, float* %12
store float %41, float* %11
%42 = load %struct.mint_network*, %struct.mint_network** %6
%43 = load %struct.mint_network*, %struct.mint_network** %14
%44 = call i32 @mint_network_cpy(%struct.mint_network* %42, %struct.mint_network* %43)
br label %49
45: ; preds = %31
%46 = load %struct.mint_network*, %struct.mint_network** %14
%47 = load %struct.mint_network*, %struct.mint_network** %6
%48 = call i32 @mint_network_cpy(%struct.mint_network* %46, %struct.mint_network* %47)
br label %49
49: ; preds = %45, %40
br label %20
50: ; preds = %29
%51 = load %struct.mint_network*, %struct.mint_network** %14
%52 = call i32 @mint_network_del(%struct.mint_network* %51)
%53 = load float, float* %11
ret float %53
}

LLVM IR (-O2):
%struct.mint_network = type { i32 }
define float @mint_random_search(%struct.mint_network* %0, float (%struct.mint_network*)* nocapture %1, void (%struct.mint_network*)* nocapture %2, float %3, i64 %4) {
%6 = tail call %struct.mint_network* @mint_network_dup(%struct.mint_network* %0)
%7 = tail call float %1(%struct.mint_network* %0)
%8 = fcmp olt float %7, %3
br i1 %8, label %9, label %26
9: ; preds = %5
%10 = call i64 @llvm.smax.i64(i64 %4, i64 0)
br label %11
11: ; preds = %9, %23
%12 = phi float [ %24, %23 ], [ %7, %9 ]
%13 = phi i64 [ %14, %23 ], [ 0, %9 ]
%14 = add nuw i64 %13, 1
%15 = icmp eq i64 %13, %10
br i1 %15, label %26, label %16
16: ; preds = %11
tail call void %2(%struct.mint_network* %6)
%17 = tail call float %1(%struct.mint_network* %6)
%18 = fcmp ogt float %17, %12
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @mint_network_cpy(%struct.mint_network* %0, %struct.mint_network* %6)
br label %23
21: ; preds = %16
%22 = tail call i32 @mint_network_cpy(%struct.mint_network* %6, %struct.mint_network* %0)
br label %23
23: ; preds = %21, %19
%24 = phi float [ %17, %19 ], [ %12, %21 ]
%25 = fcmp olt float %24, %3
br i1 %25, label %11, label %26
26: ; preds = %11, %23, %5
%27 = phi float [ %7, %5 ], [ %24, %23 ], [ %12, %11 ]
%28 = tail call i32 @mint_network_del(%struct.mint_network* %6)
ret float %27
}