#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_ukk(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *, char *,
                 int);
int asm_ukk_score(char *a, char *b) {
  int threshold = (1 << 2);
  int it, max_it = ((32 - 2 - 1));
  int sc = -2;
  for (it = 0; (it < max_it) && (sc < 0); it++) {
    sc = sa_align_ukk(NULL, NULL, a, b, threshold);
    threshold *= 2;
  }
  return sc;
}


x86 assembly (clang, -O0):
<asm_ukk_score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
movl   $0x1d,-0x1c(%rbp)
movl   $0xfffffffe,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x21(%rbp)
jge    1157 <asm_ukk_score+0x47>
cmpl   $0x0,-0x20(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1167 <asm_ukk_score+0x57>
jmp    1199 <asm_ukk_score+0x89>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1030 <sa_align_ukk@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <asm_ukk_score+0x2c>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asm_ukk_score>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
mov    $0x4,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %ebp,%r8d
call   1030 <sa_align_ukk@plt>
cmp    $0x1b,%ebx
ja     1150 <asm_ukk_score+0x40>
add    %ebp,%ebp
add    $0x1,%ebx
test   %eax,%eax
js     1130 <asm_ukk_score+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @asm_ukk_score(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 4, i32* %5
store i32 29, i32* %7
store i32 -2, i32* %8
store i32 0, i32* %6
br label %9
9: ; preds = %25, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 0
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %28
18: ; preds = %16
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = call i32 @sa_align_ukk(i32* null, i32* null, i8* %19, i8* %20, i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %5
%24 = mul nsw i32 %23, 2
store i32 %24, i32* %5
br label %25
25: ; preds = %18
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %9
28: ; preds = %16
%29 = load i32, i32* %8
ret i32 %29
}

LLVM IR (-O2):
define i32 @asm_ukk_score(i8* %0, i8* %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 4, %2 ], [ %7, %3 ]
%5 = phi i32 [ 0, %2 ], [ %8, %3 ]
%6 = tail call i32 @sa_align_ukk(i32* null, i32* null, i8* %0, i8* %1, i32 %4)
%7 = shl nsw i32 %4, 1
%8 = add nuw nsw i32 %5, 1
%9 = icmp ult i32 %5, 28
%10 = icmp slt i32 %6, 0
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %3, label %12
12: ; preds = %3
ret i32 %6
}