#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint16_t;

/* Variables and functions */
int find_iso_from_start(int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
void find_best_iso(uint8_t n, uint8_t min_hd, uint8_t min_iso, uint16_t a_len) {
  uint16_t min_b_len, longest, longest_b;
  min_b_len = 2;
  do {
    printf("trying a: %d, min b: %d, total: %d\n", a_len, min_b_len,
           a_len + min_b_len);
    longest = find_iso_from_start(0, n, min_hd, min_iso, a_len, min_b_len);
    min_b_len = longest - a_len - 3;
  } while (longest > (a_len++ * 2));
}


x86 assembly (clang, -O0):
<find_best_iso>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
xor    %edi,%edi
call   1040 <find_iso_from_start@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
shl    $0x1,%ecx
cmp    %ecx,%eax
jg     113b <find_best_iso+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_best_iso>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r13d
lea    (%rbx,%rbx,1),%r12d
add    $0xfffffffe,%r12d
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rbx,%rbp,1),%ecx
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %edi,%edi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
mov    %ebp,%r9d
call   1040 <find_iso_from_start@plt>
mov    %eax,%ebp
sub    %ebx,%ebp
add    $0xfffffffd,%ebp
add    $0x1,%ebx
add    $0x2,%r12d
cmp    %r12d,%eax
jg     1150 <find_best_iso+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"trying a: %d, min b: %d, total: %d\0A\00"
define void @find_best_iso(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 2, i32* %9
br label %12
12: ; preds = %29, %4
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = add nsw i32 %15, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14, i32 %17)
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = call i32 @find_iso_from_start(i32 0, i32 %19, i32 %20, i32 %21, i32 %22, i32 %23)
store i32 %24, i32* %10
%25 = load i32, i32* %10
%26 = load i32, i32* %8
%27 = sub nsw i32 %25, %26
%28 = sub nsw i32 %27, 3
store i32 %28, i32* %9
br label %29
29: ; preds = %12
%30 = load i32, i32* %10
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
%33 = mul nsw i32 %31, 2
%34 = icmp sgt i32 %30, %33
br i1 %34, label %12, label %35
35: ; preds = %29
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"trying a: %d, min b: %d, total: %d\0A\00"
define void @find_best_iso(i32 %0, i32 %1, i32 %2, i32 %3) {
br label %5
5: ; preds = %5, %4
%6 = phi i32 [ 2, %4 ], [ %12, %5 ]
%7 = phi i32 [ %3, %4 ], [ %13, %5 ]
%8 = add nsw i32 %7, %6
%9 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %6, i32 %8)
%10 = tail call i32 @find_iso_from_start(i32 0, i32 %0, i32 %1, i32 %2, i32 %7, i32 %6)
%11 = sub i32 -3, %7
%12 = add i32 %11, %10
%13 = add nsw i32 %7, 1
%14 = shl nsw i32 %7, 1
%15 = icmp sgt i32 %10, %14
br i1 %15, label %5, label %16
16: ; preds = %5
ret void
}