#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 sa_align_ukk3(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *, char *,
                  int, int (*)(char, char), char);
int strlen(char *);
int asm_ukk_score3(char *a, char *b, int (*score_func)(char, char)) {
  int threshold = (1 << 2);
  int it, max_it = ((32 - 2 - 1));
  int sc = -2;
  int n_a, n_b, del;
  n_a = strlen(a);
  n_b = strlen(b);
  del = score_func(-1, -1);
  threshold = ((n_a > n_b) ? ((n_a - n_b + 1) * del) : ((n_b - n_a + 1) * del));
  for (it = 0; (it < max_it) && (sc < 0); it++) {
    sc = sa_align_ukk3(NULL, NULL, a, b, threshold, score_func, '-');
    threshold *= 2;
  }
  return sc;
}


x86 assembly (clang, -O0):
<asm_ukk_score3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x4,-0x1c(%rbp)
movl   $0x1d,-0x24(%rbp)
movl   $0xfffffffe,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    $0xffffffff,%esi
mov    %esi,%edi
call   *-0x18(%rbp)
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    118f <asm_ukk_score3+0x6f>
mov    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
add    $0x1,%eax
imul   -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    119f <asm_ukk_score3+0x7f>
mov    -0x30(%rbp),%eax
sub    -0x2c(%rbp),%eax
add    $0x1,%eax
imul   -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x39(%rbp)
jge    11c7 <asm_ukk_score3+0xa7>
cmpl   $0x0,-0x28(%rbp)
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11d7 <asm_ukk_score3+0xb7>
jmp    1214 <asm_ukk_score3+0xf4>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x18(%rbp),%r9
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
movl   $0x2d,(%rsp)
call   1040 <sa_align_ukk3@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ac <asm_ukk_score3+0x8c>
mov    -0x28(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asm_ukk_score3>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %ebp,%ecx
sub    %eax,%ecx
neg    %ecx
sub    %eax,%ebp
cmovle %ecx,%ebp
mov    $0xffffffff,%edi
mov    $0xffffffff,%esi
call   *%r14
add    $0x1,%ebp
imul   %eax,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x2d,(%rsp)
xor    %edi,%edi
xor    %esi,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %ebp,%r8d
mov    %r14,%r9
call   1040 <sa_align_ukk3@plt>
cmp    $0x1b,%ebx
ja     119a <asm_ukk_score3+0x7a>
add    %ebp,%ebp
add    $0x1,%ebx
test   %eax,%eax
js     1170 <asm_ukk_score3+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @asm_ukk_score3(i8* %0, i8* %1, i32 (i8, i8)* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32 (i8, i8)*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 (i8, i8)* %2, i32 (i8, i8)** %6
store i32 4, i32* %7
store i32 29, i32* %9
store i32 -2, i32* %10
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %11
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %12
%18 = load i32 (i8, i8)*, i32 (i8, i8)** %6
%19 = call i32 %18(i8 signext -1, i8 signext -1)
store i32 %19, i32* %13
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %3
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = sub nsw i32 %24, %25
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %13
%29 = mul nsw i32 %27, %28
br label %37
30: ; preds = %3
%31 = load i32, i32* %12
%32 = load i32, i32* %11
%33 = sub nsw i32 %31, %32
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %13
%36 = mul nsw i32 %34, %35
br label %37
37: ; preds = %30, %23
%38 = phi i32 [ %29, %23 ], [ %36, %30 ]
store i32 %38, i32* %7
store i32 0, i32* %8
br label %39
39: ; preds = %56, %37
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i32, i32* %10
%45 = icmp slt i32 %44, 0
br label %46
46: ; preds = %43, %39
%47 = phi i1 [ false, %39 ], [ %45, %43 ]
br i1 %47, label %48, label %59
48: ; preds = %46
%49 = load i8*, i8** %4
%50 = load i8*, i8** %5
%51 = load i32, i32* %7
%52 = load i32 (i8, i8)*, i32 (i8, i8)** %6
%53 = call i32 @sa_align_ukk3(i32* null, i32* null, i8* %49, i8* %50, i32 %51, i32 (i8, i8)* %52, i8 signext 45)
store i32 %53, i32* %10
%54 = load i32, i32* %7
%55 = mul nsw i32 %54, 2
store i32 %55, i32* %7
br label %56
56: ; preds = %48
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %39
59: ; preds = %46
%60 = load i32, i32* %10
ret i32 %60
}

LLVM IR (-O2):
define i32 @asm_ukk_score3(i8* %0, i8* %1, i32 (i8, i8)* %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i32 %2(i8 signext -1, i8 signext -1)
%7 = icmp sgt i32 %4, %5
%8 = sub nsw i32 %4, %5
%9 = sub nsw i32 %5, %4
%10 = select i1 %7, i32 %8, i32 %9
%11 = add nsw i32 %10, 1
%12 = mul nsw i32 %11, %6
br label %13
13: ; preds = %3, %13
%14 = phi i32 [ %12, %3 ], [ %17, %13 ]
%15 = phi i32 [ 0, %3 ], [ %18, %13 ]
%16 = tail call i32 @sa_align_ukk3(i32* null, i32* null, i8* %0, i8* %1, i32 %14, i32 (i8, i8)* %2, i8 signext 45)
%17 = shl nsw i32 %14, 1
%18 = add nuw nsw i32 %15, 1
%19 = icmp ult i32 %15, 28
%20 = icmp slt i32 %16, 0
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %13, label %22
22: ; preds = %13
ret i32 %16
}