#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 scalar_t__ wchar_t;
typedef int /*<<< orphan*/ s;
typedef int /*<<< orphan*/ mbstate_t;

/* Variables and functions */
int MB_CUR_MAX;
size_t mbrtowc(scalar_t__ *, char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int check_ascii(const char *locname) {
  int c;
  int res = 0;
  printf("Testing locale \"%s\":\n", locname);
  for (c = 0; c <= 127; ++c) {
    char buf[MB_CUR_MAX];
    wchar_t wc = 0xffffffff;
    mbstate_t s;
    size_t n, i;
    for (i = 0; i < MB_CUR_MAX; ++i)
      buf[i] = c + i;
    memset(&s, '\0', sizeof(s));
    n = mbrtowc(&wc, buf, MB_CUR_MAX, &s);
    if (n == (size_t)-1) {
      printf("%s: '\\x%x': encoding error\n", locname, c);
      ++res;
    } else if (n == (size_t)-2) {
      printf("%s: '\\x%x': incomplete character\n", locname, c);
      ++res;
    } else if (n == 0 && c != 0) {
      printf("%s: '\\x%x': 0 returned\n", locname, c);
      ++res;
    } else if (n != 0 && c == 0) {
      printf("%s: '\\x%x': not 0 returned\n", locname, c);
      ++res;
    } else if (c != 0 && n != 1) {
      printf("%s: '\\x%x': not 1 returned\n", locname, c);
      ++res;
    } else if (wc != (wchar_t)c) {
      printf("%s: '\\x%x': wc != L'\\x%x'\n", locname, c, c);
      ++res;
    }
  }
  printf(res == 1 ? "%d error\n" : "%d errors\n", res);
  return res != 0;
}


x86 assembly (clang, -O0):
<check_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jg     1372 <check_ascii+0x242>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    $0xffffffff,%eax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    0x2e4a(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jae    11e0 <check_ascii+0xb0>
mov    -0x48(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    -0x40(%rbp),%rcx
mov    %cl,%dl
mov    -0x40(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11a3 <check_ascii+0x73>
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x48(%rbp),%rsi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
lea    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0xffffffffffffffff,-0x38(%rbp)
jne    123c <check_ascii+0x10c>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    135d <check_ascii+0x22d>
cmpq   $0xfffffffffffffffe,-0x38(%rbp)
jne    126a <check_ascii+0x13a>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1358 <check_ascii+0x228>
cmpq   $0x0,-0x38(%rbp)
jne    12a2 <check_ascii+0x172>
cmpl   $0x0,-0xc(%rbp)
je     12a2 <check_ascii+0x172>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1353 <check_ascii+0x223>
cmpq   $0x0,-0x38(%rbp)
je     12da <check_ascii+0x1aa>
cmpl   $0x0,-0xc(%rbp)
jne    12da <check_ascii+0x1aa>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    134e <check_ascii+0x21e>
cmpl   $0x0,-0xc(%rbp)
je     1312 <check_ascii+0x1e2>
cmpq   $0x1,-0x38(%rbp)
je     1312 <check_ascii+0x1e2>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1349 <check_ascii+0x219>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
je     1344 <check_ascii+0x214>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1349 <check_ascii+0x219>
jmp    134e <check_ascii+0x21e>
jmp    1353 <check_ascii+0x223>
jmp    1358 <check_ascii+0x228>
jmp    135d <check_ascii+0x22d>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115c <check_ascii+0x2c>
mov    -0x10(%rbp),%ecx
lea    0xd4d(%rip),%rdi
lea    0xd3c(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdi
mov    -0x10(%rbp),%esi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_ascii>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%rsi
lea    0xf82(%rip),%rdi
mov    %rsi,-0x30(%rbp)
xor    %eax,%eax
call   1040 <printf@plt>
movdqa 0xf1e(%rip),%xmm11
xor    %r13d,%r13d
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %rsp,%rbx
mov    0x2e7e(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    $0xffffffff,%eax
mov    %rax,-0x38(%rbp)
movslq (%rcx),%rax
test   %rax,%rax
je     16f1 <check_ascii+0x5c1>
cmp    $0x10,%eax
jae    11b0 <check_ascii+0x80>
xor    %ecx,%ecx
jmp    16e0 <check_ascii+0x5b0>
xchg   %ax,%ax
mov    %rax,%rcx
and    $0xfffffffffffffff0,%rcx
movq   %r13,%xmm0
pshufd $0x44,%xmm0,%xmm1
lea    -0x10(%rcx),%rsi
mov    %rsi,%rdi
shr    $0x4,%rdi
add    $0x1,%rdi
mov    %edi,%edx
and    $0x3,%edx
cmp    $0x30,%rsi
movdqa %xmm1,-0x50(%rbp)
jae    122b <check_ascii+0xfb>
xor    %esi,%esi
movdqa 0xe86(%rip),%xmm4
movdqa 0xe6e(%rip),%xmm7
movdqa 0xe55(%rip),%xmm9
movdqa 0xe3c(%rip),%xmm10
movdqa 0xe23(%rip),%xmm15
movdqa 0xe0b(%rip),%xmm5
movdqa 0xdf2(%rip),%xmm14
movdqa 0xdda(%rip),%xmm6
jmp    15e3 <check_ascii+0x4b3>
and    $0xfffffffffffffffc,%rdi
xor    %esi,%esi
movaps 0xe38(%rip),%xmm4
movdqa 0xe20(%rip),%xmm7
movdqa 0xe07(%rip),%xmm9
movaps 0xdef(%rip),%xmm10
movdqa 0xdd6(%rip),%xmm15
movdqa 0xdbe(%rip),%xmm5
movaps 0xda6(%rip),%xmm14
movaps 0xd8f(%rip),%xmm6
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movaps %xmm6,-0x60(%rbp)
movaps %xmm14,-0x70(%rbp)
movdqa %xmm15,-0xb0(%rbp)
ff ff
movdqa %xmm9,-0xc0(%rbp)
ff ff
movaps %xmm10,-0x80(%rbp)
movaps %xmm4,-0x90(%rbp)
movdqa -0x60(%rbp),%xmm6
movdqa -0x50(%rbp),%xmm0
paddq  %xmm0,%xmm6
movdqa -0x70(%rbp),%xmm14
paddq  %xmm0,%xmm14
movdqa %xmm5,%xmm13
paddq  %xmm0,%xmm13
movdqa %xmm15,%xmm8
paddq  %xmm0,%xmm8
movdqa -0x80(%rbp),%xmm12
paddq  %xmm0,%xmm12
movdqa %xmm9,%xmm2
paddq  %xmm0,%xmm2
movdqa %xmm7,%xmm10
paddq  %xmm0,%xmm10
movdqa -0x90(%rbp),%xmm4
ff
paddq  %xmm0,%xmm4
movdqa %xmm4,%xmm1
pand   %xmm11,%xmm1
movdqa %xmm10,%xmm9
pand   %xmm11,%xmm9
packuswb %xmm9,%xmm1
movdqa 0xd71(%rip),%xmm9
movdqa %xmm2,%xmm0
pand   %xmm11,%xmm0
movdqa %xmm12,%xmm3
pand   %xmm11,%xmm3
packuswb %xmm3,%xmm0
packuswb %xmm0,%xmm1
movdqa %xmm8,%xmm0
pand   %xmm11,%xmm0
movdqa %xmm13,%xmm3
pand   %xmm11,%xmm3
packuswb %xmm3,%xmm0
movdqa %xmm14,%xmm3
pand   %xmm11,%xmm3
movdqa %xmm6,%xmm11
pand   0xd17(%rip),%xmm6
packuswb %xmm6,%xmm3
packuswb %xmm3,%xmm0
packuswb %xmm0,%xmm1
movdqa %xmm1,(%r15,%rsi,1)
movdqa %xmm11,%xmm1
movdqa %xmm11,-0xa0(%rbp)
ff ff
paddq  %xmm9,%xmm1
movdqa %xmm12,%xmm0
paddq  %xmm9,%xmm0
movdqa %xmm10,%xmm3
paddq  %xmm9,%xmm3
movdqa %xmm4,%xmm6
paddq  %xmm9,%xmm6
pand   0xccd(%rip),%xmm6
pand   0xcc5(%rip),%xmm3
packuswb %xmm3,%xmm6
movdqa %xmm2,%xmm3
paddq  %xmm9,%xmm3
pand   0xcb0(%rip),%xmm3
pand   0xca8(%rip),%xmm0
packuswb %xmm0,%xmm3
movdqa %xmm13,%xmm0
paddq  %xmm9,%xmm0
packuswb %xmm3,%xmm6
movdqa %xmm8,%xmm3
paddq  %xmm9,%xmm3
pand   0xc84(%rip),%xmm3
pand   0xc7c(%rip),%xmm0
packuswb %xmm0,%xmm3
movdqa %xmm14,%xmm0
paddq  %xmm9,%xmm0
pand   0xc66(%rip),%xmm0
pand   0xc5e(%rip),%xmm1
packuswb %xmm1,%xmm0
packuswb %xmm0,%xmm3
packuswb %xmm3,%xmm6
movdqa %xmm6,0x10(%r15,%rsi,1)
movdqa %xmm11,%xmm1
movdqa 0xc5d(%rip),%xmm9
paddq  %xmm9,%xmm1
movdqa %xmm12,%xmm0
paddq  %xmm9,%xmm0
movdqa %xmm10,%xmm3
paddq  %xmm9,%xmm3
movdqa %xmm4,%xmm6
paddq  %xmm9,%xmm6
pand   0xc13(%rip),%xmm6
pand   0xc0b(%rip),%xmm3
packuswb %xmm3,%xmm6
movdqa %xmm2,%xmm3
paddq  %xmm9,%xmm3
pand   0xbf6(%rip),%xmm3
pand   0xbee(%rip),%xmm0
packuswb %xmm0,%xmm3
movdqa %xmm13,%xmm0
paddq  %xmm9,%xmm0
packuswb %xmm3,%xmm6
movdqa %xmm8,%xmm3
paddq  %xmm9,%xmm3
pand   0xbca(%rip),%xmm3
pand   0xbc2(%rip),%xmm0
packuswb %xmm0,%xmm3
movdqa %xmm14,%xmm0
paddq  %xmm9,%xmm0
pand   0xbac(%rip),%xmm0
pand   0xba4(%rip),%xmm1
packuswb %xmm1,%xmm0
packuswb %xmm0,%xmm3
packuswb %xmm3,%xmm6
movdqa %xmm6,0x20(%r15,%rsi,1)
movdqa 0xb88(%rip),%xmm11
movdqa 0xbb0(%rip),%xmm0
paddq  %xmm0,%xmm10
paddq  %xmm0,%xmm4
pand   %xmm11,%xmm4
pand   %xmm11,%xmm10
packuswb %xmm10,%xmm4
movdqa -0xb0(%rbp),%xmm15
ff ff
movdqa -0xc0(%rbp),%xmm9
ff ff
paddq  %xmm0,%xmm12
paddq  %xmm0,%xmm2
pand   %xmm11,%xmm2
pand   %xmm11,%xmm12
packuswb %xmm12,%xmm2
movdqa -0x80(%rbp),%xmm10
packuswb %xmm2,%xmm4
paddq  %xmm0,%xmm13
paddq  %xmm0,%xmm8
pand   %xmm11,%xmm8
pand   %xmm11,%xmm13
packuswb %xmm13,%xmm8
movdqa -0xa0(%rbp),%xmm1
ff
paddq  %xmm0,%xmm1
paddq  %xmm0,%xmm14
pand   %xmm11,%xmm14
pand   %xmm11,%xmm1
packuswb %xmm1,%xmm14
movdqa -0x60(%rbp),%xmm6
packuswb %xmm14,%xmm8
movdqa -0x70(%rbp),%xmm14
packuswb %xmm8,%xmm4
movdqa %xmm4,0x30(%r15,%rsi,1)
movdqa -0x90(%rbp),%xmm4
ff
movdqa 0xb0f(%rip),%xmm0
add    $0x40,%rsi
paddq  %xmm0,%xmm4
paddq  %xmm0,%xmm7
paddq  %xmm0,%xmm9
paddq  %xmm0,%xmm10
paddq  %xmm0,%xmm15
paddq  %xmm0,%xmm5
paddq  %xmm0,%xmm14
paddq  %xmm0,%xmm6
add    $0xfffffffffffffffc,%rdi
jne    1280 <check_ascii+0x150>
test   %rdx,%rdx
movdqa -0x50(%rbp),%xmm8
movdqa 0xa9b(%rip),%xmm12
je     16da <check_ascii+0x5aa>
add    %r15,%rsi
shl    $0x4,%rdx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm6,%xmm1
paddq  %xmm8,%xmm1
movdqa %xmm10,%xmm0
paddq  %xmm8,%xmm0
movdqa %xmm7,%xmm2
paddq  %xmm8,%xmm2
movdqa %xmm4,%xmm3
paddq  %xmm8,%xmm3
pand   %xmm11,%xmm3
pand   %xmm11,%xmm2
packuswb %xmm2,%xmm3
movdqa %xmm9,%xmm2
paddq  %xmm8,%xmm2
pand   %xmm11,%xmm2
pand   %xmm11,%xmm0
packuswb %xmm0,%xmm2
movdqa %xmm5,%xmm0
paddq  %xmm8,%xmm0
packuswb %xmm2,%xmm3
movdqa %xmm15,%xmm2
paddq  %xmm8,%xmm2
pand   %xmm11,%xmm2
pand   %xmm11,%xmm0
packuswb %xmm0,%xmm2
movdqa %xmm14,%xmm0
paddq  %xmm8,%xmm0
pand   %xmm11,%xmm0
pand   %xmm11,%xmm1
packuswb %xmm1,%xmm0
packuswb %xmm0,%xmm2
packuswb %xmm2,%xmm3
movdqa %xmm3,(%rsi,%rdi,1)
paddq  %xmm12,%xmm4
paddq  %xmm12,%xmm7
paddq  %xmm12,%xmm9
paddq  %xmm12,%xmm10
paddq  %xmm12,%xmm15
paddq  %xmm12,%xmm5
paddq  %xmm12,%xmm14
paddq  %xmm12,%xmm6
add    $0x10,%rdi
cmp    %rdi,%rdx
jne    1610 <check_ascii+0x4e0>
cmp    %rax,%rcx
je     16f1 <check_ascii+0x5c1>
nop
lea    (%rcx,%r13,1),%edx
mov    %dl,(%r15,%rcx,1)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    16e0 <check_ascii+0x5b0>
lea    -0x3c(%rbp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x28ed(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rdi
mov    %r15,%rsi
mov    %r14,%rcx
call   1030 <mbrtowc@plt>
cmp    $0xfffffffffffffffe,%rax
je     1740 <check_ascii+0x610>
cmp    $0xffffffffffffffff,%rax
jne    1750 <check_ascii+0x620>
lea    0x9b7(%rip),%rdi
jmp    1770 <check_ascii+0x640>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x9bb(%rip),%rdi
jmp    1770 <check_ascii+0x640>
nopl   0x0(%rax)
test   %rax,%rax
jne    17a1 <check_ascii+0x671>
test   %r13,%r13
je     17a1 <check_ascii+0x671>
lea    0x9c3(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
movdqa 0x8f5(%rip),%xmm11
mov    %rbx,%rsp
add    $0x1,%r13
cmp    $0x80,%r13
jne    1170 <check_ascii+0x40>
jmp    17ee <check_ascii+0x6be>
test   %rax,%rax
je     17ba <check_ascii+0x68a>
test   %r13,%r13
jne    17ba <check_ascii+0x68a>
lea    0x98a(%rip),%rdi
mov    -0x30(%rbp),%rsi
xor    %edx,%edx
jmp    1777 <check_ascii+0x647>
test   %r13,%r13
je     17ce <check_ascii+0x69e>
cmp    $0x1,%rax
je     17ce <check_ascii+0x69e>
lea    0x98c(%rip),%rdi
jmp    1770 <check_ascii+0x640>
cmp    %r13,-0x38(%rbp)
je     1782 <check_ascii+0x652>
lea    0x999(%rip),%rdi
mov    -0x30(%rbp),%rsi
mov    %r13d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    177e <check_ascii+0x64e>
cmp    $0x1,%r12d
lea    0x996(%rip),%rax
lea    0x999(%rip),%rdi
cmove  %rax,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
test   %r12d,%r12d
setne  %al
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Testing locale \22%s\22:\0A\00"
@MB_CUR_MAX = global i32 0
@.str.1 = [28 x i8] c"%s: '\\x%x': encoding error\0A\00"
@.str.2 = [34 x i8] c"%s: '\\x%x': incomplete character\0A\00"
@.str.3 = [24 x i8] c"%s: '\\x%x': 0 returned\0A\00"
@.str.4 = [28 x i8] c"%s: '\\x%x': not 0 returned\0A\00"
@.str.5 = [28 x i8] c"%s: '\\x%x': not 1 returned\0A\00"
@.str.6 = [27 x i8] c"%s: '\\x%x': wc != L'\\x%x'\0A\00"
@.str.7 = [10 x i8] c"%d error\0A\00"
@.str.8 = [11 x i8] c"%d errors\0A\00"
define i32 @check_ascii(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %4
%11 = load i8*, i8** %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 0, i32* %3
br label %13
13: ; preds = %113, %1
%14 = load i32, i32* %3
%15 = icmp sle i32 %14, 127
br i1 %15, label %16, label %116
16: ; preds = %13
%17 = load i32, i32* @MB_CUR_MAX
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %5
%20 = alloca i8, i64 %18
store i64 %18, i64* %6
store i64 4294967295, i64* %7
store i64 0, i64* %10
br label %21
21: ; preds = %34, %16
%22 = load i64, i64* %10
%23 = load i32, i32* @MB_CUR_MAX
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %22, %24
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = load i64, i64* %10
%30 = add i64 %28, %29
%31 = trunc i64 %30 to i8
%32 = load i64, i64* %10
%33 = getelementptr inbounds i8, i8* %20, i64 %32
store i8 %31, i8* %33
br label %34
34: ; preds = %26
%35 = load i64, i64* %10
%36 = add i64 %35, 1
store i64 %36, i64* %10
br label %21
37: ; preds = %21
%38 = call i32 @memset(i32* %8, i8 signext 0, i32 4)
%39 = load i32, i32* @MB_CUR_MAX
%40 = call i64 @mbrtowc(i64* %7, i8* %20, i32 %39, i32* %8)
store i64 %40, i64* %9
%41 = load i64, i64* %9
%42 = icmp eq i64 %41, -1
br i1 %42, label %43, label %49
43: ; preds = %37
%44 = load i8*, i8** %2
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %44, i32 %45)
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %111
49: ; preds = %37
%50 = load i64, i64* %9
%51 = icmp eq i64 %50, -2
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = load i8*, i8** %2
%54 = load i32, i32* %3
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %53, i32 %54)
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %110
58: ; preds = %49
%59 = load i64, i64* %9
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %70
61: ; preds = %58
%62 = load i32, i32* %3
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i8*, i8** %2
%66 = load i32, i32* %3
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %65, i32 %66)
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %109
70: ; preds = %61, %58
%71 = load i64, i64* %9
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %82
73: ; preds = %70
%74 = load i32, i32* %3
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %82
76: ; preds = %73
%77 = load i8*, i8** %2
%78 = load i32, i32* %3
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %77, i32 %78)
%80 = load i32, i32* %4
%81 = add nsw i32 %80, 1
store i32 %81, i32* %4
br label %108
82: ; preds = %73, %70
%83 = load i32, i32* %3
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %94
85: ; preds = %82
%86 = load i64, i64* %9
%87 = icmp ne i64 %86, 1
br i1 %87, label %88, label %94
88: ; preds = %85
%89 = load i8*, i8** %2
%90 = load i32, i32* %3
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %89, i32 %90)
%92 = load i32, i32* %4
%93 = add nsw i32 %92, 1
store i32 %93, i32* %4
br label %107
94: ; preds = %85, %82
%95 = load i64, i64* %7
%96 = load i32, i32* %3
%97 = sext i32 %96 to i64
%98 = icmp ne i64 %95, %97
br i1 %98, label %99, label %106
99: ; preds = %94
%100 = load i8*, i8** %2
%101 = load i32, i32* %3
%102 = load i32, i32* %3
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %100, i32 %101, i32 %102)
%104 = load i32, i32* %4
%105 = add nsw i32 %104, 1
store i32 %105, i32* %4
br label %106
106: ; preds = %99, %94
br label %107
107: ; preds = %106, %88
br label %108
108: ; preds = %107, %76
br label %109
109: ; preds = %108, %64
br label %110
110: ; preds = %109, %52
br label %111
111: ; preds = %110, %43
%112 = load i8*, i8** %5
br label %113
113: ; preds = %111
%114 = load i32, i32* %3
%115 = add nsw i32 %114, 1
store i32 %115, i32* %3
br label %13
116: ; preds = %13
%117 = load i32, i32* %4
%118 = icmp eq i32 %117, 1
%119 = zext i1 %118 to i64
%120 = select i1 %118, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0)
%121 = load i32, i32* %4
%122 = call i32 (i8*, ...) @printf(i8* %120, i32 %121)
%123 = load i32, i32* %4
%124 = icmp ne i32 %123, 0
%125 = zext i1 %124 to i32
ret i32 %125
}

LLVM IR (-O2):
@.str = [22 x i8] c"Testing locale \22%s\22:\0A\00"
@MB_CUR_MAX = global i32 0
@.str.1 = [28 x i8] c"%s: '\\x%x': encoding error\0A\00"
@.str.2 = [34 x i8] c"%s: '\\x%x': incomplete character\0A\00"
@.str.3 = [24 x i8] c"%s: '\\x%x': 0 returned\0A\00"
@.str.4 = [28 x i8] c"%s: '\\x%x': not 0 returned\0A\00"
@.str.5 = [28 x i8] c"%s: '\\x%x': not 1 returned\0A\00"
@.str.6 = [27 x i8] c"%s: '\\x%x': wc != L'\\x%x'\0A\00"
@.str.7 = [10 x i8] c"%d error\0A\00"
@.str.8 = [11 x i8] c"%d errors\0A\00"
define i32 @check_ascii(i8* %0) {
%2 = alloca i64
%3 = alloca i32
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = bitcast i64* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %1, %128
%8 = phi i64 [ 0, %1 ], [ %130, %128 ]
%9 = phi i32 [ 0, %1 ], [ %129, %128 ]
%10 = load i32, i32* @MB_CUR_MAX
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
%13 = alloca i8, i64 %11
store i64 4294967295, i64* %2
%14 = load i32, i32* @MB_CUR_MAX
%15 = icmp eq i32 %14, 0
br i1 %15, label %87, label %16
16: ; preds = %7
%17 = sext i32 %14 to i64
%18 = icmp ult i32 %14, 16
br i1 %18, label %78, label %19
19: ; preds = %16
%20 = and i64 %17, -16
%21 = insertelement <16 x i64> poison, i64 %8, i64 0
%22 = shufflevector <16 x i64> %21, <16 x i64> poison, <16 x i32> zeroinitializer
%23 = add nsw i64 %20, -16
%24 = lshr exact i64 %23, 4
%25 = add nuw nsw i64 %24, 1
%26 = and i64 %25, 3
%27 = icmp ult i64 %23, 48
br i1 %27, label %60, label %28
28: ; preds = %19
%29 = and i64 %25, 2305843009213693948
br label %30
30: ; preds = %30, %28
%31 = phi i64 [ 0, %28 ], [ %56, %30 ]
%32 = phi <16 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, %28 ], [ %57, %30 ]
%33 = phi i64 [ 0, %28 ], [ %58, %30 ]
%34 = add <16 x i64> %32, %22
%35 = trunc <16 x i64> %34 to <16 x i8>
%36 = getelementptr inbounds i8, i8* %13, i64 %31
%37 = bitcast i8* %36 to <16 x i8>*
store <16 x i8> %35, <16 x i8>* %37
%38 = or i64 %31, 16
%39 = add <16 x i64> %32, <i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16>
%40 = add <16 x i64> %39, %22
%41 = trunc <16 x i64> %40 to <16 x i8>
%42 = getelementptr inbounds i8, i8* %13, i64 %38
%43 = bitcast i8* %42 to <16 x i8>*
store <16 x i8> %41, <16 x i8>* %43
%44 = or i64 %31, 32
%45 = add <16 x i64> %32, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32>
%46 = add <16 x i64> %45, %22
%47 = trunc <16 x i64> %46 to <16 x i8>
%48 = getelementptr inbounds i8, i8* %13, i64 %44
%49 = bitcast i8* %48 to <16 x i8>*
store <16 x i8> %47, <16 x i8>* %49
%50 = or i64 %31, 48
%51 = add <16 x i64> %32, <i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48, i64 48>
%52 = add <16 x i64> %51, %22
%53 = trunc <16 x i64> %52 to <16 x i8>
%54 = getelementptr inbounds i8, i8* %13, i64 %50
%55 = bitcast i8* %54 to <16 x i8>*
store <16 x i8> %53, <16 x i8>* %55
%56 = add nuw i64 %31, 64
%57 = add <16 x i64> %32, <i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64>
%58 = add i64 %33, 4
%59 = icmp eq i64 %58, %29
br i1 %59, label %60, label %30
60: ; preds = %30, %19
%61 = phi i64 [ 0, %19 ], [ %56, %30 ]
%62 = phi <16 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, %19 ], [ %57, %30 ]
%63 = icmp eq i64 %26, 0
br i1 %63, label %76, label %64
64: ; preds = %60, %64
%65 = phi i64 [ %72, %64 ], [ %61, %60 ]
%66 = phi <16 x i64> [ %73, %64 ], [ %62, %60 ]
%67 = phi i64 [ %74, %64 ], [ 0, %60 ]
%68 = add <16 x i64> %66, %22
%69 = trunc <16 x i64> %68 to <16 x i8>
%70 = getelementptr inbounds i8, i8* %13, i64 %65
%71 = bitcast i8* %70 to <16 x i8>*
store <16 x i8> %69, <16 x i8>* %71
%72 = add nuw i64 %65, 16
%73 = add <16 x i64> %66, <i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16>
%74 = add i64 %67, 1
%75 = icmp eq i64 %74, %26
br i1 %75, label %76, label %64
76: ; preds = %64, %60
%77 = icmp eq i64 %20, %17
br i1 %77, label %87, label %78
78: ; preds = %16, %76
%79 = phi i64 [ 0, %16 ], [ %20, %76 ]
br label %80
80: ; preds = %78, %80
%81 = phi i64 [ %85, %80 ], [ %79, %78 ]
%82 = add i64 %81, %8
%83 = trunc i64 %82 to i8
%84 = getelementptr inbounds i8, i8* %13, i64 %81
store i8 %83, i8* %84
%85 = add nuw i64 %81, 1
%86 = icmp eq i64 %85, %17
br i1 %86, label %87, label %80
87: ; preds = %80, %76, %7
%88 = call i32 @memset(i32* %3, i8 signext 0, i32 4)
%89 = load i32, i32* @MB_CUR_MAX
%90 = call i64 @mbrtowc(i64* %2, i8* %13, i32 %89, i32* %3)
switch i64 %90, label %99 [
i64 -1, label %91
i64 -2, label %95
]
91: ; preds = %87
%92 = trunc i64 %8 to i32
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %92)
%94 = add nsw i32 %9, 1
br label %128
95: ; preds = %87
%96 = trunc i64 %8 to i32
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %96)
%98 = add nsw i32 %9, 1
br label %128
99: ; preds = %87
%100 = icmp eq i64 %90, 0
%101 = icmp ne i64 %8, 0
%102 = select i1 %100, i1 %101, i1 false
br i1 %102, label %103, label %107
103: ; preds = %99
%104 = trunc i64 %8 to i32
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %104)
%106 = add nsw i32 %9, 1
br label %128
107: ; preds = %99
%108 = icmp ne i64 %90, 0
%109 = icmp eq i64 %8, 0
%110 = select i1 %108, i1 %109, i1 false
br i1 %110, label %111, label %114
111: ; preds = %107
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 0)
%113 = add nsw i32 %9, 1
br label %128
114: ; preds = %107
%115 = icmp ne i64 %90, 1
%116 = select i1 %101, i1 %115, i1 false
br i1 %116, label %117, label %121
117: ; preds = %114
%118 = trunc i64 %8 to i32
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %118)
%120 = add nsw i32 %9, 1
br label %128
121: ; preds = %114
%122 = load i64, i64* %2
%123 = icmp eq i64 %122, %8
br i1 %123, label %128, label %124
124: ; preds = %121
%125 = trunc i64 %8 to i32
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 %125, i32 %125)
%127 = add nsw i32 %9, 1
br label %128
128: ; preds = %95, %111, %121, %124, %117, %103, %91
%129 = phi i32 [ %94, %91 ], [ %98, %95 ], [ %106, %103 ], [ %113, %111 ], [ %120, %117 ], [ %127, %124 ], [ %9, %121 ]
%130 = add nuw nsw i64 %8, 1
%131 = icmp eq i64 %130, 128
br i1 %131, label %132, label %7
132: ; preds = %128
%133 = icmp eq i32 %129, 1
%134 = select i1 %133, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0)
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %134, i32 %129)
%136 = icmp ne i32 %129, 0
%137 = zext i1 %136 to i32
ret i32 %137
}