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


x86 assembly (clang, -O0):
<asm_ukk_score2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x4,-0x1c(%rbp)
movl   $0x20000000,-0x24(%rbp)
movl   $0xfffffffe,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    115d <asm_ukk_score2+0x4d>
cmpl   $0x0,-0x28(%rbp)
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    116d <asm_ukk_score2+0x5d>
jmp    11af <asm_ukk_score2+0x9f>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
xor    %esi,%esi
mov    %rsi,%rdi
mov    %eax,(%rsp)
movl   $0x2d,0x8(%rsp)
call   1030 <sa_align_ukk2@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    1142 <asm_ukk_score2+0x32>
mov    -0x28(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asm_ukk_score2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebp,%ebp
mov    $0x4,%ebx
xchg   %ax,%ax
xor    %edi,%edi
xor    %esi,%esi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %ebx,%r8d
mov    %r15d,%r9d
push   $0x2d
push   %r14
call   1030 <sa_align_ukk2@plt>
add    $0x10,%rsp
cmp    $0x1ffffffe,%ebp
ja     115e <asm_ukk_score2+0x4e>
add    %ebx,%ebx
add    $0x1,%ebp
test   %eax,%eax
js     1130 <asm_ukk_score2+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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