#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 /*<<< orphan*/ iso3166_alpha2(char const *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int to_int(unsigned char const *, int);
int iban(const unsigned char *data, int data_len, int offset, int min, int max,
         int *p_err_no, int *p_err_posn, char err_msg[50],
         const int length_only) {
  data_len -= offset;
  if (data_len < min) {
    return 0;
  }
  if (data_len && data_len < 5) {
    *p_err_no = 4;
    return 0;
  }
  if (!length_only && data_len) {
    const unsigned char *d = data + offset;
    const unsigned char *de = d + (data_len > max ? max : data_len);
    int checksum = 0;
    int given_checksum;
    if (d[0] < 'A' || d[0] > 'Z' || d[1] < 'A' || d[1] > 'Z') {
      *p_err_no = 3;
      *p_err_posn = d - data + 1;
      sprintf(err_msg, "Non-alphabetic IBAN country code '%.2s'", d);
      return 0;
    }
    if (!iso3166_alpha2((const char *)d)) {
      *p_err_no = 3;
      *p_err_posn = d - data + 1;
      sprintf(err_msg, "Invalid IBAN country code '%.2s'", d);
      return 0;
    }
    d += 2;
    if (d[0] < '0' || d[0] > '9' || d[1] < '0' || d[1] > '9') {
      *p_err_no = 3;
      *p_err_posn = d - data + 1;
      sprintf(err_msg, "Non-numeric IBAN checksum '%.2s'", d);
      return 0;
    }
    given_checksum = to_int(d, 2);
    d += 2;
    for (; d < de; d++) {
      if (*d < '0' || (*d > '9' && *d < 'A') || *d > 'Z') {
        *p_err_no = 3;
        *p_err_posn = d - data + 1;
        sprintf(err_msg, "Invalid IBAN character '%c'", *d);
        return 0;
      }
      if (*d >= 'A') {
        checksum = checksum * 100 + *d - 'A' + 10;
      } else {
        checksum = checksum * 10 + *d - '0';
      }
      checksum %= 97;
    }
    checksum = (((checksum * 100) % 97) + (data[offset] - 'A' + 10)) * 100 +
               data[offset + 1] - 'A' + 10;
    checksum %= 97;
    checksum *= 100;
    checksum %= 97;
    checksum = 98 - checksum;
    if (checksum != given_checksum) {
      *p_err_no = 3;
      *p_err_posn = offset + 2 + 1;
      sprintf(err_msg, "Bad IBAN checksum '%.2s', expected '%02d'",
              data + offset + 2, checksum);
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<iban>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117b <iban+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
cmpl   $0x0,-0x14(%rbp)
je     11a5 <iban+0x75>
cmpl   $0x5,-0x14(%rbp)
jge    11a5 <iban+0x75>
mov    -0x28(%rbp),%rax
movl   $0x4,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
cmpl   $0x0,0x20(%rbp)
jne    1545 <iban+0x415>
cmpl   $0x0,-0x14(%rbp)
je     1545 <iban+0x415>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11e7 <iban+0xb7>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    11ed <iban+0xbd>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x41,%eax
jl     1247 <iban+0x117>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x5a,%eax
jg     1247 <iban+0x117>
mov    -0x30(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x41,%eax
jl     1247 <iban+0x117>
mov    -0x30(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x5a,%eax
jle    128a <iban+0x15a>
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
mov    -0x30(%rbp),%rdi
call   1030 <iso3166_alpha2@plt>
cmp    $0x0,%eax
jne    12df <iban+0x1af>
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
mov    -0x30(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
jl     132d <iban+0x1fd>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x39,%eax
jg     132d <iban+0x1fd>
mov    -0x30(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x30,%eax
jl     132d <iban+0x1fd>
mov    -0x30(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x39,%eax
jle    1370 <iban+0x240>
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xcec(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
mov    -0x30(%rbp),%rdi
mov    $0x2,%esi
call   1040 <to_int@plt>
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    147e <iban+0x34e>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
jl     13db <iban+0x2ab>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x39,%eax
jle    13cb <iban+0x29b>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x41,%eax
jl     13db <iban+0x2ab>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x5a,%eax
jle    1421 <iban+0x2f1>
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x30(%rbp),%rax
movzbl (%rax),%edx
lea    0xc5c(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x41,%eax
jl     144c <iban+0x31c>
imul   $0x64,-0x3c(%rbp),%eax
mov    -0x30(%rbp),%rcx
movzbl (%rcx),%ecx
add    %ecx,%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x3c(%rbp)
jmp    145f <iban+0x32f>
imul   $0xa,-0x3c(%rbp),%eax
mov    -0x30(%rbp),%rcx
movzbl (%rcx),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x61,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    138d <iban+0x25d>
imul   $0x64,-0x3c(%rbp),%eax
mov    $0x61,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sub    $0x41,%eax
add    $0xa,%eax
add    %eax,%edx
imul   $0x64,%edx,%eax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x61,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
imul   $0x64,-0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x61,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
mov    $0x62,%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
je     1540 <iban+0x410>
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
add    $0x1,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
add    %rax,%rdx
add    $0x2,%rdx
mov    -0x3c(%rbp),%ecx
lea    0xb59(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    154c <iban+0x41c>
jmp    1545 <iban+0x415>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iban>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
sub    %edx,%r14d
xor    %ebp,%ebp
cmp    %ecx,%r14d
jl     11c0 <iban+0x90>
mov    %r9,%r15
mov    %edx,%ebx
mov    %rdi,%r13
test   %r14d,%r14d
je     1167 <iban+0x37>
cmp    $0x4,%r14d
jg     1167 <iban+0x37>
movl   $0x4,(%r15)
jmp    11c0 <iban+0x90>
cmpl   $0x0,0x60(%rsp)
mov    $0x1,%ebp
jne    11c0 <iban+0x90>
test   %r14d,%r14d
je     11c0 <iban+0x90>
mov    0x58(%rsp),%rdi
mov    0x50(%rsp),%rcx
movslq %ebx,%rsi
cmp    %r8d,%r14d
cmovg  %r8d,%r14d
lea    (%rsi,%r13,1),%rdx
mov    0x0(%r13,%rsi,1),%al
add    $0xa5,%al
cmp    $0xe6,%al
jb     11a4 <iban+0x74>
mov    0x1(%rdx),%al
add    $0xa5,%al
cmp    $0xe5,%al
ja     11d1 <iban+0xa1>
movl   $0x3,(%r15)
add    $0x1,%ebx
mov    %ebx,(%rcx)
lea    0xe49(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,0x10(%rsp)
mov    %rdx,%rdi
mov    %rdx,%r12
call   1030 <iso3166_alpha2@plt>
test   %eax,%eax
je     1222 <iban+0xf2>
lea    0x2(%r12),%rdx
mov    0x2(%r12),%al
add    $0xc6,%al
cmp    $0xf6,%al
mov    0x58(%rsp),%rdi
mov    0x50(%rsp),%rcx
jb     1208 <iban+0xd8>
mov    0x1(%rdx),%al
add    $0xc6,%al
cmp    $0xf5,%al
ja     1249 <iban+0x119>
movl   $0x3,(%r15)
mov    %edx,%eax
sub    %r13d,%eax
add    $0x1,%eax
mov    %eax,(%rcx)
lea    0xe29(%rip),%rsi
jmp    11b7 <iban+0x87>
movl   $0x3,(%r15)
add    $0x1,%ebx
mov    0x50(%rsp),%rax
mov    %ebx,(%rax)
lea    0xdee(%rip),%rsi
xor    %ebp,%ebp
mov    0x58(%rsp),%rdi
mov    %r12,%rdx
jmp    11b9 <iban+0x89>
mov    %rdx,0x8(%rsp)
mov    %rdx,%rdi
mov    $0x2,%esi
call   1040 <to_int@plt>
mov    $0xffc9,%cx
cmp    $0x5,%r14d
jl     1311 <iban+0x1e1>
movslq %r14d,%r8
add    %r12,%r8
mov    0x8(%rsp),%rcx
add    $0x2,%rcx
lea    0x5(%rbx),%r9d
xor    %edi,%edi
jmp    12ba <iban+0x18a>
imul   %esi,%edi
lea    -0x37(%rdi),%esi
add    $0xffffffd0,%edi
cmp    $0x41,%dl
cmovae %esi,%edi
add    %edx,%edi
movslq %edi,%rdi
imul   $0x151d07eb,%rdi,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x23,%rdx
add    %esi,%edx
imul   $0x61,%edx,%edx
sub    %edx,%edi
add    $0x1,%rcx
add    $0x1,%r9d
cmp    %r8,%rcx
jae    12e8 <iban+0x1b8>
movzbl (%rcx),%edx
lea    -0x5b(%rdx),%esi
cmp    $0xd5,%sil
jb     13b4 <iban+0x284>
lea    -0x3a(%rdx),%esi
cmp    $0x6,%sil
jbe    13b4 <iban+0x284>
mov    $0x64,%esi
cmp    $0x41,%dl
jae    1280 <iban+0x150>
mov    $0xa,%esi
jmp    1280 <iban+0x150>
imul   $0x64,%edi,%ecx
movswl %cx,%edx
imul   $0xffffa8e9,%edx,%edx
shr    $0x10,%edx
add    %ecx,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
sar    $0x6,%esi
add    %edx,%esi
imul   $0x61,%esi,%edx
neg    %edx
add    %edx,%ecx
add    $0xffffffc9,%ecx
movzbl (%r12),%edx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    0x10(%rsp),%rdx
movzbl 0x1(%rdx,%r13,1),%edx
lea    (%rcx,%rdx,1),%esi
add    %edx,%ecx
add    $0xffffffc9,%ecx
movswl %cx,%edx
imul   $0xffffa8e9,%edx,%edx
shr    $0x10,%edx
add    %esi,%edx
add    $0xffffffc9,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
sar    $0x6,%esi
add    %edx,%esi
imul   $0x61,%esi,%edx
sub    %edx,%ecx
imul   $0x64,%ecx,%ecx
movswl %cx,%edx
imul   $0xffffa8e9,%edx,%edx
shr    $0x10,%edx
add    %ecx,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
sar    $0x6,%esi
add    %edx,%esi
imul   $0x61,%esi,%edx
sub    %ecx,%edx
add    $0x62,%edx
movzwl %dx,%ecx
cmp    %ecx,%eax
je     11c0 <iban+0x90>
movl   $0x3,(%r15)
add    $0x3,%ebx
mov    0x50(%rsp),%rax
mov    %ebx,(%rax)
lea    0xcea(%rip),%rsi
xor    %ebp,%ebp
mov    0x58(%rsp),%rdi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    11c0 <iban+0x90>
movl   $0x3,(%r15)
mov    0x50(%rsp),%rax
mov    %r9d,(%rax)
movzbl (%rcx),%edx
lea    0xc9d(%rip),%rsi
xor    %ebp,%ebp
mov    0x58(%rsp),%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    11c0 <iban+0x90>

LLVM IR (-O0):
@.str = [40 x i8] c"Non-alphabetic IBAN country code '%.2s'\00"
@.str.1 = [33 x i8] c"Invalid IBAN country code '%.2s'\00"
@.str.2 = [33 x i8] c"Non-numeric IBAN checksum '%.2s'\00"
@.str.3 = [28 x i8] c"Invalid IBAN character '%c'\00"
@.str.4 = [42 x i8] c"Bad IBAN checksum '%.2s', expected '%02d'\00"
define i32 @iban(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i8* %7, i32 %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i32
%23 = alloca i32
store i8* %0, i8** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32* %5, i32** %16
store i32* %6, i32** %17
store i8* %7, i8** %18
store i32 %8, i32* %19
%24 = load i32, i32* %13
%25 = load i32, i32* %12
%26 = sub nsw i32 %25, %24
store i32 %26, i32* %12
%27 = load i32, i32* %12
%28 = load i32, i32* %14
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %9
store i32 0, i32* %10
br label %277
31: ; preds = %9
%32 = load i32, i32* %12
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* %12
%36 = icmp slt i32 %35, 5
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = load i32*, i32** %16
store i32 4, i32* %38
store i32 0, i32* %10
br label %277
39: ; preds = %34, %31
%40 = load i32, i32* %19
%41 = icmp ne i32 %40, 0
br i1 %41, label %276, label %42
42: ; preds = %39
%43 = load i32, i32* %12
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %276
45: ; preds = %42
%46 = load i8*, i8** %11
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8* %49, i8** %20
%50 = load i8*, i8** %20
%51 = load i32, i32* %12
%52 = load i32, i32* %15
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %56
54: ; preds = %45
%55 = load i32, i32* %15
br label %58
56: ; preds = %45
%57 = load i32, i32* %12
br label %58
58: ; preds = %56, %54
%59 = phi i32 [ %55, %54 ], [ %57, %56 ]
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %50, i64 %60
store i8* %61, i8** %21
store i32 0, i32* %22
%62 = load i8*, i8** %20
%63 = getelementptr inbounds i8, i8* %62, i64 0
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = icmp slt i32 %65, 65
br i1 %66, label %85, label %67
67: ; preds = %58
%68 = load i8*, i8** %20
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = icmp sgt i32 %71, 90
br i1 %72, label %85, label %73
73: ; preds = %67
%74 = load i8*, i8** %20
%75 = getelementptr inbounds i8, i8* %74, i64 1
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = icmp slt i32 %77, 65
br i1 %78, label %85, label %79
79: ; preds = %73
%80 = load i8*, i8** %20
%81 = getelementptr inbounds i8, i8* %80, i64 1
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = icmp sgt i32 %83, 90
br i1 %84, label %85, label %98
85: ; preds = %79, %73, %67, %58
%86 = load i32*, i32** %16
store i32 3, i32* %86
%87 = load i8*, i8** %20
%88 = load i8*, i8** %11
%89 = ptrtoint i8* %87 to i64
%90 = ptrtoint i8* %88 to i64
%91 = sub i64 %89, %90
%92 = add nsw i64 %91, 1
%93 = trunc i64 %92 to i32
%94 = load i32*, i32** %17
store i32 %93, i32* %94
%95 = load i8*, i8** %18
%96 = load i8*, i8** %20
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %95, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %96)
store i32 0, i32* %10
br label %277
98: ; preds = %79
%99 = load i8*, i8** %20
%100 = call i32 @iso3166_alpha2(i8* %99)
%101 = icmp ne i32 %100, 0
br i1 %101, label %115, label %102
102: ; preds = %98
%103 = load i32*, i32** %16
store i32 3, i32* %103
%104 = load i8*, i8** %20
%105 = load i8*, i8** %11
%106 = ptrtoint i8* %104 to i64
%107 = ptrtoint i8* %105 to i64
%108 = sub i64 %106, %107
%109 = add nsw i64 %108, 1
%110 = trunc i64 %109 to i32
%111 = load i32*, i32** %17
store i32 %110, i32* %111
%112 = load i8*, i8** %18
%113 = load i8*, i8** %20
%114 = call i32 (i8*, i8*, ...) @sprintf(i8* %112, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %113)
store i32 0, i32* %10
br label %277
115: ; preds = %98
%116 = load i8*, i8** %20
%117 = getelementptr inbounds i8, i8* %116, i64 2
store i8* %117, i8** %20
%118 = load i8*, i8** %20
%119 = getelementptr inbounds i8, i8* %118, i64 0
%120 = load i8, i8* %119
%121 = zext i8 %120 to i32
%122 = icmp slt i32 %121, 48
br i1 %122, label %141, label %123
123: ; preds = %115
%124 = load i8*, i8** %20
%125 = getelementptr inbounds i8, i8* %124, i64 0
%126 = load i8, i8* %125
%127 = zext i8 %126 to i32
%128 = icmp sgt i32 %127, 57
br i1 %128, label %141, label %129
129: ; preds = %123
%130 = load i8*, i8** %20
%131 = getelementptr inbounds i8, i8* %130, i64 1
%132 = load i8, i8* %131
%133 = zext i8 %132 to i32
%134 = icmp slt i32 %133, 48
br i1 %134, label %141, label %135
135: ; preds = %129
%136 = load i8*, i8** %20
%137 = getelementptr inbounds i8, i8* %136, i64 1
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
%140 = icmp sgt i32 %139, 57
br i1 %140, label %141, label %154
141: ; preds = %135, %129, %123, %115
%142 = load i32*, i32** %16
store i32 3, i32* %142
%143 = load i8*, i8** %20
%144 = load i8*, i8** %11
%145 = ptrtoint i8* %143 to i64
%146 = ptrtoint i8* %144 to i64
%147 = sub i64 %145, %146
%148 = add nsw i64 %147, 1
%149 = trunc i64 %148 to i32
%150 = load i32*, i32** %17
store i32 %149, i32* %150
%151 = load i8*, i8** %18
%152 = load i8*, i8** %20
%153 = call i32 (i8*, i8*, ...) @sprintf(i8* %151, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %152)
store i32 0, i32* %10
br label %277
154: ; preds = %135
%155 = load i8*, i8** %20
%156 = call i32 @to_int(i8* %155, i32 2)
store i32 %156, i32* %23
%157 = load i8*, i8** %20
%158 = getelementptr inbounds i8, i8* %157, i64 2
store i8* %158, i8** %20
br label %159
159: ; preds = %223, %154
%160 = load i8*, i8** %20
%161 = load i8*, i8** %21
%162 = icmp ult i8* %160, %161
br i1 %162, label %163, label %226
163: ; preds = %159
%164 = load i8*, i8** %20
%165 = load i8, i8* %164
%166 = zext i8 %165 to i32
%167 = icmp slt i32 %166, 48
br i1 %167, label %183, label %168
168: ; preds = %163
%169 = load i8*, i8** %20
%170 = load i8, i8* %169
%171 = zext i8 %170 to i32
%172 = icmp sgt i32 %171, 57
br i1 %172, label %173, label %178
173: ; preds = %168
%174 = load i8*, i8** %20
%175 = load i8, i8* %174
%176 = zext i8 %175 to i32
%177 = icmp slt i32 %176, 65
br i1 %177, label %183, label %178
178: ; preds = %173, %168
%179 = load i8*, i8** %20
%180 = load i8, i8* %179
%181 = zext i8 %180 to i32
%182 = icmp sgt i32 %181, 90
br i1 %182, label %183, label %198
183: ; preds = %178, %173, %163
%184 = load i32*, i32** %16
store i32 3, i32* %184
%185 = load i8*, i8** %20
%186 = load i8*, i8** %11
%187 = ptrtoint i8* %185 to i64
%188 = ptrtoint i8* %186 to i64
%189 = sub i64 %187, %188
%190 = add nsw i64 %189, 1
%191 = trunc i64 %190 to i32
%192 = load i32*, i32** %17
store i32 %191, i32* %192
%193 = load i8*, i8** %18
%194 = load i8*, i8** %20
%195 = load i8, i8* %194
%196 = zext i8 %195 to i32
%197 = call i32 (i8*, i8*, ...) @sprintf(i8* %193, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %196)
store i32 0, i32* %10
br label %277
198: ; preds = %178
%199 = load i8*, i8** %20
%200 = load i8, i8* %199
%201 = zext i8 %200 to i32
%202 = icmp sge i32 %201, 65
br i1 %202, label %203, label %212
203: ; preds = %198
%204 = load i32, i32* %22
%205 = mul nsw i32 %204, 100
%206 = load i8*, i8** %20
%207 = load i8, i8* %206
%208 = zext i8 %207 to i32
%209 = add nsw i32 %205, %208
%210 = sub nsw i32 %209, 65
%211 = add nsw i32 %210, 10
store i32 %211, i32* %22
br label %220
212: ; preds = %198
%213 = load i32, i32* %22
%214 = mul nsw i32 %213, 10
%215 = load i8*, i8** %20
%216 = load i8, i8* %215
%217 = zext i8 %216 to i32
%218 = add nsw i32 %214, %217
%219 = sub nsw i32 %218, 48
store i32 %219, i32* %22
br label %220
220: ; preds = %212, %203
%221 = load i32, i32* %22
%222 = srem i32 %221, 97
store i32 %222, i32* %22
br label %223
223: ; preds = %220
%224 = load i8*, i8** %20
%225 = getelementptr inbounds i8, i8* %224, i32 1
store i8* %225, i8** %20
br label %159
226: ; preds = %159
%227 = load i32, i32* %22
%228 = mul nsw i32 %227, 100
%229 = srem i32 %228, 97
%230 = load i8*, i8** %11
%231 = load i32, i32* %13
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds i8, i8* %230, i64 %232
%234 = load i8, i8* %233
%235 = zext i8 %234 to i32
%236 = sub nsw i32 %235, 65
%237 = add nsw i32 %236, 10
%238 = add nsw i32 %229, %237
%239 = mul nsw i32 %238, 100
%240 = load i8*, i8** %11
%241 = load i32, i32* %13
%242 = add nsw i32 %241, 1
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds i8, i8* %240, i64 %243
%245 = load i8, i8* %244
%246 = zext i8 %245 to i32
%247 = add nsw i32 %239, %246
%248 = sub nsw i32 %247, 65
%249 = add nsw i32 %248, 10
store i32 %249, i32* %22
%250 = load i32, i32* %22
%251 = srem i32 %250, 97
store i32 %251, i32* %22
%252 = load i32, i32* %22
%253 = mul nsw i32 %252, 100
store i32 %253, i32* %22
%254 = load i32, i32* %22
%255 = srem i32 %254, 97
store i32 %255, i32* %22
%256 = load i32, i32* %22
%257 = sub nsw i32 98, %256
store i32 %257, i32* %22
%258 = load i32, i32* %22
%259 = load i32, i32* %23
%260 = icmp ne i32 %258, %259
br i1 %260, label %261, label %275
261: ; preds = %226
%262 = load i32*, i32** %16
store i32 3, i32* %262
%263 = load i32, i32* %13
%264 = add nsw i32 %263, 2
%265 = add nsw i32 %264, 1
%266 = load i32*, i32** %17
store i32 %265, i32* %266
%267 = load i8*, i8** %18
%268 = load i8*, i8** %11
%269 = load i32, i32* %13
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds i8, i8* %268, i64 %270
%272 = getelementptr inbounds i8, i8* %271, i64 2
%273 = load i32, i32* %22
%274 = call i32 (i8*, i8*, ...) @sprintf(i8* %267, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %272, i32 %273)
store i32 0, i32* %10
br label %277
275: ; preds = %226
br label %276
276: ; preds = %275, %42, %39
store i32 1, i32* %10
br label %277
277: ; preds = %276, %261, %183, %141, %102, %85, %37, %30
%278 = load i32, i32* %10
ret i32 %278
}

LLVM IR (-O2):
@.str = [40 x i8] c"Non-alphabetic IBAN country code '%.2s'\00"
@.str.1 = [33 x i8] c"Invalid IBAN country code '%.2s'\00"
@.str.2 = [33 x i8] c"Non-numeric IBAN checksum '%.2s'\00"
@.str.3 = [28 x i8] c"Invalid IBAN character '%c'\00"
@.str.4 = [42 x i8] c"Bad IBAN checksum '%.2s', expected '%02d'\00"
define i32 @iban(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6, i8* nocapture writeonly %7, i32 %8) {
%10 = sub nsw i32 %1, %2
%11 = icmp slt i32 %10, %3
br i1 %11, label %122, label %12
12: ; preds = %9
%13 = icmp ne i32 %10, 0
%14 = icmp slt i32 %10, 5
%15 = and i1 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 4, i32* %5
br label %122
17: ; preds = %12
%18 = icmp eq i32 %8, 0
%19 = select i1 %18, i1 %13, i1 false
br i1 %19, label %20, label %122
20: ; preds = %17
%21 = sext i32 %2 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = icmp sgt i32 %10, %4
%24 = select i1 %23, i32 %4, i32 %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %22
%28 = add i8 %27, -91
%29 = icmp ult i8 %28, -26
br i1 %29, label %35, label %30
30: ; preds = %20
%31 = getelementptr inbounds i8, i8* %22, i64 1
%32 = load i8, i8* %31
%33 = add i8 %32, -91
%34 = icmp ult i8 %33, -26
br i1 %34, label %35, label %38
35: ; preds = %30, %20
store i32 3, i32* %5
%36 = add i32 %2, 1
store i32 %36, i32* %6
%37 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %122
38: ; preds = %30
%39 = tail call i32 @iso3166_alpha2(i8* %22)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
store i32 3, i32* %5
%42 = add i32 %2, 1
store i32 %42, i32* %6
%43 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %122
44: ; preds = %38
%45 = getelementptr inbounds i8, i8* %22, i64 2
%46 = load i8, i8* %45
%47 = add i8 %46, -58
%48 = icmp ult i8 %47, -10
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = getelementptr inbounds i8, i8* %45, i64 1
%51 = load i8, i8* %50
%52 = add i8 %51, -58
%53 = icmp ult i8 %52, -10
br i1 %53, label %54, label %61
54: ; preds = %49, %44
store i32 3, i32* %5
%55 = ptrtoint i8* %45 to i64
%56 = ptrtoint i8* %0 to i64
%57 = sub i64 %55, %56
%58 = trunc i64 %57 to i32
%59 = add i32 %58, 1
store i32 %59, i32* %6
%60 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %45)
br label %122
61: ; preds = %49
%62 = tail call i32 @to_int(i8* %45, i32 2)
%63 = icmp sgt i32 %24, 4
br i1 %63, label %64, label %100
64: ; preds = %61
%65 = getelementptr inbounds i8, i8* %45, i64 2
br label %66
66: ; preds = %64, %84
%67 = phi i32 [ %92, %84 ], [ 0, %64 ]
%68 = phi i8* [ %93, %84 ], [ %65, %64 ]
%69 = load i8, i8* %68
%70 = add i8 %69, -58
%71 = icmp ult i8 %70, 7
%72 = add i8 %69, -91
%73 = icmp ult i8 %72, -43
%74 = or i1 %73, %71
br i1 %74, label %75, label %84
75: ; preds = %66
store i32 3, i32* %5
%76 = ptrtoint i8* %68 to i64
%77 = ptrtoint i8* %0 to i64
%78 = sub i64 %76, %77
%79 = trunc i64 %78 to i32
%80 = add i32 %79, 1
store i32 %80, i32* %6
%81 = load i8, i8* %68
%82 = zext i8 %81 to i32
%83 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %82)
br label %122
84: ; preds = %66
%85 = zext i8 %69 to i32
%86 = icmp ugt i8 %69, 64
%87 = select i1 %86, i32 100, i32 10
%88 = select i1 %86, i32 -55, i32 -48
%89 = mul nsw i32 %67, %87
%90 = add nsw i32 %89, %88
%91 = add nsw i32 %90, %85
%92 = srem i32 %91, 97
%93 = getelementptr inbounds i8, i8* %68, i64 1
%94 = icmp ult i8* %93, %26
br i1 %94, label %66, label %95
95: ; preds = %84
%96 = trunc i32 %92 to i16
%97 = mul i16 %96, 100
%98 = srem i16 %97, 97
%99 = add nsw i16 %98, -55
br label %100
100: ; preds = %95, %61
%101 = phi i16 [ -55, %61 ], [ %99, %95 ]
%102 = load i8, i8* %22
%103 = zext i8 %102 to i16
%104 = add nsw i16 %101, %103
%105 = mul i16 %104, 100
%106 = add nsw i32 %2, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %0, i64 %107
%109 = load i8, i8* %108
%110 = zext i8 %109 to i16
%111 = add i16 %105, %110
%112 = add nsw i16 %111, -55
%113 = srem i16 %112, 97
%114 = mul nsw i16 %113, 100
%115 = srem i16 %114, 97
%116 = sub nsw i16 98, %115
%117 = zext i16 %116 to i32
%118 = icmp eq i32 %62, %117
br i1 %118, label %122, label %119
119: ; preds = %100
store i32 3, i32* %5
%120 = add nsw i32 %2, 3
store i32 %120, i32* %6
%121 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %45, i32 %117)
br label %122
122: ; preds = %41, %119, %75, %54, %35, %17, %100, %9, %16
%123 = phi i32 [ 0, %16 ], [ 0, %9 ], [ 1, %100 ], [ 1, %17 ], [ 0, %35 ], [ 0, %54 ], [ 0, %75 ], [ 0, %119 ], [ 0, %41 ]
ret i32 %123
}