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

/* Variables and functions */
int /*<<< orphan*/ LC_CTYPE;
size_t mbsnrtowcs(int *, char const **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
char *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
int strcmp(char const *, char *);
int main(void) {
  unsigned char buf[6] = {0x25, 0xe2, 0x82, 0xac, 0xce, 0xbb};
  mbstate_t state;
  const char *src;
  wchar_t wc = 42;
  size_t n;
  int result = 0;
  const char *used_locale;
  setlocale(LC_CTYPE, "de_DE.UTF-8");
  used_locale = setlocale(LC_CTYPE, NULL);
  printf("used locale: \"%s\"\n", used_locale);
  result = strcmp(used_locale, "de_DE.UTF-8");
  memset(&state, '\0', sizeof(state));
  src = (const char *)buf;
  n = mbsnrtowcs(&wc, &src, 1, 1, &state);
  printf("mbsnrtowcs (&wc, &src, 1, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu, src = buf+%d", (unsigned long int)wc,
         src - (const char *)buf);
  if (n != (size_t)1 || wc != 37 || src != (const char *)(buf + 1)) {
    printf(", expected %Zd and %lu and buf+%d", 1, (unsigned long int)37,
           (buf + 1) - buf);
    result = 1;
  }
  putc('\n', stdout);
  n = mbsnrtowcs(&wc, &src, 3, 1, &state);
  printf("mbsnrtowcs (&wc, &src, 3, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu, src = buf+%d", (unsigned long int)wc,
         src - (const char *)buf);
  if (n != (size_t)1 || wc != 8364 || src != (const char *)(buf + 4)) {
    printf(", expected %Zd and %lu and buf+%d", 1, (unsigned long int)8364,
           (buf + 4) - buf);
    result = 1;
  }
  putc('\n', stdout);
  n = mbsnrtowcs(&wc, &src, 1, 1, &state);
  printf("mbsnrtowcs (&wc, &src, 1, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu, src = buf+%d", (unsigned long int)wc,
         src - (const char *)buf);
  if (n != (size_t)0 || wc != 8364 || src != (const char *)(buf + 5)) {
    printf(", expected %Zd and %lu and buf+%d", 0, (unsigned long int)8364,
           (buf + 5) - buf);
    result = 1;
  }
  putc('\n', stdout);
  n = mbsnrtowcs(&wc, &src, 1, 1, &state);
  printf("mbsnrtowcs (&wc, &src, 1, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu, src = buf+%d", (unsigned long int)wc,
         src - (const char *)buf);
  if (n != (size_t)1 || wc != 955 || src != (const char *)(buf + 6)) {
    printf(", expected %Zd and %lu and buf+%d", 1, (unsigned long int)955,
           (buf + 6) - buf);
    result = 1;
  }
  putc('\n', stdout);
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe85(%rip),%ax
mov    %ax,-0x6(%rbp)
movl   $0x2a,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1070 <setlocale@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <setlocale@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    -0xa(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x1,%ecx
lea    -0x10(%rbp),%r8
mov    %ecx,%edx
call   1080 <mbsnrtowcs@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0xa(%rbp),%rax
sub    %rax,%rdx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x1,-0x28(%rbp)
jne    126e <main+0x10e>
cmpl   $0x25,-0x1c(%rbp)
jne    126e <main+0x10e>
mov    -0x18(%rbp),%rax
lea    -0xa(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
je     129c <main+0x13c>
lea    -0xa(%rbp),%rcx
add    $0x1,%rcx
lea    -0xa(%rbp),%rax
sub    %rax,%rcx
lea    0xde6(%rip),%rdi
mov    $0x1,%esi
mov    $0x25,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    0x2d35(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x3,%edx
mov    $0x1,%ecx
lea    -0x10(%rbp),%r8
call   1080 <mbsnrtowcs@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0xa(%rbp),%rax
sub    %rax,%rdx
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x1,-0x28(%rbp)
jne    132a <main+0x1ca>
cmpl   $0x20ac,-0x1c(%rbp)
jne    132a <main+0x1ca>
mov    -0x18(%rbp),%rax
lea    -0xa(%rbp),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
je     1358 <main+0x1f8>
lea    -0xa(%rbp),%rcx
add    $0x4,%rcx
lea    -0xa(%rbp),%rax
sub    %rax,%rcx
lea    0xd2a(%rip),%rdi
mov    $0x1,%esi
mov    $0x20ac,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    0x2c79(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x1,%ecx
lea    -0x10(%rbp),%r8
mov    %ecx,%edx
call   1080 <mbsnrtowcs@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0xa(%rbp),%rax
sub    %rax,%rdx
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
jne    13e3 <main+0x283>
cmpl   $0x20ac,-0x1c(%rbp)
jne    13e3 <main+0x283>
mov    -0x18(%rbp),%rax
lea    -0xa(%rbp),%rcx
add    $0x5,%rcx
cmp    %rcx,%rax
je     140e <main+0x2ae>
lea    -0xa(%rbp),%rcx
add    $0x5,%rcx
lea    -0xa(%rbp),%rax
sub    %rax,%rcx
lea    0xc71(%rip),%rdi
xor    %esi,%esi
mov    $0x20ac,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    0x2bc3(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x1,%ecx
lea    -0x10(%rbp),%r8
mov    %ecx,%edx
call   1080 <mbsnrtowcs@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xbdd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0xa(%rbp),%rax
sub    %rax,%rdx
lea    0xbec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x1,-0x28(%rbp)
jne    1499 <main+0x339>
cmpl   $0x3bb,-0x1c(%rbp)
jne    1499 <main+0x339>
mov    -0x18(%rbp),%rax
lea    -0xa(%rbp),%rcx
add    $0x6,%rcx
cmp    %rcx,%rax
je     14c7 <main+0x367>
lea    -0xa(%rbp),%rcx
add    $0x6,%rcx
lea    -0xa(%rbp),%rax
sub    %rax,%rcx
lea    0xbbb(%rip),%rdi
mov    $0x1,%esi
mov    $0x3bb,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    0x2b0a(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
movw   $0xbbce,0x20(%rsp)
movl   $0xac82e225,0x1c(%rsp)
ac
movl   $0x2a,0xc(%rsp)
mov    0x2e60(%rip),%rbx
mov    (%rbx),%edi
lea    0xe75(%rip),%r14
mov    %r14,%rsi
call   1070 <setlocale@plt>
mov    (%rbx),%edi
xor    %esi,%esi
call   1070 <setlocale@plt>
mov    %rax,%rbx
lea    0xe66(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    %eax,%ebp
lea    0x24(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0x1c(%rsp),%r14
mov    %r14,0x10(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    %rbx,%r8
call   1080 <mbsnrtowcs@plt>
mov    %rax,%rbx
lea    0xe1e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rsi
mov    0x10(%rsp),%rdx
sub    %r14,%rdx
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%rbx
jne    1245 <main+0xe5>
cmpl   $0x25,0xc(%rsp)
jne    1245 <main+0xe5>
lea    0x1d(%rsp),%rax
cmp    %rax,0x10(%rsp)
je     1267 <main+0x107>
lea    0xe1e(%rip),%rdi
mov    $0x25,%edx
mov    $0x1,%ecx
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    0x2d6a(%rip),%r15
mov    (%r15),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x24(%rsp),%r8
mov    $0x3,%edx
mov    $0x1,%ecx
call   1080 <mbsnrtowcs@plt>
mov    %rax,%rbx
lea    0xde9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rsi
mov    0x10(%rsp),%rdx
sub    %r14,%rdx
lea    0xd90(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%rbx
jne    12e4 <main+0x184>
cmpl   $0x20ac,0xc(%rsp)
jne    12e4 <main+0x184>
lea    0x20(%rsp),%rax
cmp    %rax,0x10(%rsp)
je     1306 <main+0x1a6>
lea    0xd7f(%rip),%rdi
mov    $0x20ac,%edx
mov    $0x4,%ecx
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    (%r15),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x24(%rsp),%r8
mov    $0x1,%edx
mov    $0x1,%ecx
call   1080 <mbsnrtowcs@plt>
mov    %rax,%rbx
lea    0xcea(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rsi
mov    0x10(%rsp),%rdx
sub    %r14,%rdx
lea    0xcf8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %rbx,%rbx
jne    137b <main+0x21b>
cmpl   $0x20ac,0xc(%rsp)
jne    137b <main+0x21b>
lea    0x21(%rsp),%rax
cmp    %rax,0x10(%rsp)
je     139a <main+0x23a>
lea    0xce8(%rip),%rdi
mov    $0x20ac,%edx
mov    $0x5,%ecx
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    (%r15),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x24(%rsp),%r8
mov    $0x1,%edx
mov    $0x1,%ecx
call   1080 <mbsnrtowcs@plt>
mov    %rax,%rbx
lea    0xc56(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rsi
mov    0x10(%rsp),%rdx
sub    %r14,%rdx
lea    0xc64(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%rbx
jne    1410 <main+0x2b0>
cmpl   $0x3bb,0xc(%rsp)
jne    1410 <main+0x2b0>
lea    0x22(%rsp),%rax
cmp    %rax,0x10(%rsp)
je     1432 <main+0x2d2>
lea    0xc53(%rip),%rdi
mov    $0x3bb,%edx
mov    $0x6,%ecx
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    (%r15),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.buf = [6 x i8] c"%\E2\82\AC\CE\BB"
@LC_CTYPE = global i32 0
@.str = [12 x i8] c"de_DE.UTF-8\00"
@.str.1 = [19 x i8] c"used locale: \22%s\22\0A\00"
@.str.2 = [44 x i8] c"mbsnrtowcs (&wc, &src, 1, 1, &state) -> %Zd\00"
@.str.3 = [25 x i8] c", wc = %lu, src = buf+%d\00"
@.str.4 = [34 x i8] c", expected %Zd and %lu and buf+%d\00"
@stdout = global i32 0
@.str.5 = [44 x i8] c"mbsnrtowcs (&wc, &src, 3, 1, &state) -> %Zd\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %1
%9 = bitcast [6 x i8]* %2 to i8*
store i32 42, i32* %5
store i32 0, i32* %7
%10 = load i32, i32* @LC_CTYPE
%11 = call i8* @setlocale(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @LC_CTYPE
%13 = call i8* @setlocale(i32 %12, i8* null)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %8
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %7
%18 = call i32 @memset(i32* %3, i8 signext 0, i32 4)
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
store i8* %19, i8** %4
%20 = call i64 @mbsnrtowcs(i32* %5, i8** %4, i32 1, i32 1, i32* %3)
store i64 %20, i64* %6
%21 = load i64, i64* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %21)
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = load i8*, i8** %4
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%27 = ptrtoint i8* %25 to i64
%28 = ptrtoint i8* %26 to i64
%29 = sub i64 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %24, i64 %29)
%31 = load i64, i64* %6
%32 = icmp ne i64 %31, 1
br i1 %32, label %41, label %33
33: ; preds = %0
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 37
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = load i8*, i8** %4
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = icmp ne i8* %37, %39
br i1 %40, label %41, label %49
41: ; preds = %36, %33, %0
%42 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%45 = ptrtoint i8* %43 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 37, i64 %47)
store i32 1, i32* %7
br label %49
49: ; preds = %41, %36
%50 = load i32, i32* @stdout
%51 = call i32 @putc(i8 signext 10, i32 %50)
%52 = call i64 @mbsnrtowcs(i32* %5, i8** %4, i32 3, i32 1, i32* %3)
store i64 %52, i64* %6
%53 = load i64, i64* %6
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i64 %53)
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = load i8*, i8** %4
%58 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%59 = ptrtoint i8* %57 to i64
%60 = ptrtoint i8* %58 to i64
%61 = sub i64 %59, %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %56, i64 %61)
%63 = load i64, i64* %6
%64 = icmp ne i64 %63, 1
br i1 %64, label %73, label %65
65: ; preds = %49
%66 = load i32, i32* %5
%67 = icmp ne i32 %66, 8364
br i1 %67, label %73, label %68
68: ; preds = %65
%69 = load i8*, i8** %4
%70 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%71 = getelementptr inbounds i8, i8* %70, i64 4
%72 = icmp ne i8* %69, %71
br i1 %72, label %73, label %81
73: ; preds = %68, %65, %49
%74 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%75 = getelementptr inbounds i8, i8* %74, i64 4
%76 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%77 = ptrtoint i8* %75 to i64
%78 = ptrtoint i8* %76 to i64
%79 = sub i64 %77, %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 8364, i64 %79)
store i32 1, i32* %7
br label %81
81: ; preds = %73, %68
%82 = load i32, i32* @stdout
%83 = call i32 @putc(i8 signext 10, i32 %82)
%84 = call i64 @mbsnrtowcs(i32* %5, i8** %4, i32 1, i32 1, i32* %3)
store i64 %84, i64* %6
%85 = load i64, i64* %6
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %85)
%87 = load i32, i32* %5
%88 = sext i32 %87 to i64
%89 = load i8*, i8** %4
%90 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%91 = ptrtoint i8* %89 to i64
%92 = ptrtoint i8* %90 to i64
%93 = sub i64 %91, %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %88, i64 %93)
%95 = load i64, i64* %6
%96 = icmp ne i64 %95, 0
br i1 %96, label %105, label %97
97: ; preds = %81
%98 = load i32, i32* %5
%99 = icmp ne i32 %98, 8364
br i1 %99, label %105, label %100
100: ; preds = %97
%101 = load i8*, i8** %4
%102 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%103 = getelementptr inbounds i8, i8* %102, i64 5
%104 = icmp ne i8* %101, %103
br i1 %104, label %105, label %113
105: ; preds = %100, %97, %81
%106 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%107 = getelementptr inbounds i8, i8* %106, i64 5
%108 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%109 = ptrtoint i8* %107 to i64
%110 = ptrtoint i8* %108 to i64
%111 = sub i64 %109, %110
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 0, i64 8364, i64 %111)
store i32 1, i32* %7
br label %113
113: ; preds = %105, %100
%114 = load i32, i32* @stdout
%115 = call i32 @putc(i8 signext 10, i32 %114)
%116 = call i64 @mbsnrtowcs(i32* %5, i8** %4, i32 1, i32 1, i32* %3)
store i64 %116, i64* %6
%117 = load i64, i64* %6
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %117)
%119 = load i32, i32* %5
%120 = sext i32 %119 to i64
%121 = load i8*, i8** %4
%122 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%123 = ptrtoint i8* %121 to i64
%124 = ptrtoint i8* %122 to i64
%125 = sub i64 %123, %124
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %120, i64 %125)
%127 = load i64, i64* %6
%128 = icmp ne i64 %127, 1
br i1 %128, label %137, label %129
129: ; preds = %113
%130 = load i32, i32* %5
%131 = icmp ne i32 %130, 955
br i1 %131, label %137, label %132
132: ; preds = %129
%133 = load i8*, i8** %4
%134 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%135 = getelementptr inbounds i8, i8* %134, i64 6
%136 = icmp ne i8* %133, %135
br i1 %136, label %137, label %145
137: ; preds = %132, %129, %113
%138 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%139 = getelementptr inbounds i8, i8* %138, i64 6
%140 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%141 = ptrtoint i8* %139 to i64
%142 = ptrtoint i8* %140 to i64
%143 = sub i64 %141, %142
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 955, i64 %143)
store i32 1, i32* %7
br label %145
145: ; preds = %137, %132
%146 = load i32, i32* @stdout
%147 = call i32 @putc(i8 signext 10, i32 %146)
%148 = load i32, i32* %7
ret i32 %148
}

LLVM IR (-O2):
@__const.main.buf = [6 x i8] c"%\E2\82\AC\CE\BB"
@LC_CTYPE = global i32 0
@.str = [12 x i8] c"de_DE.UTF-8\00"
@.str.1 = [19 x i8] c"used locale: \22%s\22\0A\00"
@.str.2 = [44 x i8] c"mbsnrtowcs (&wc, &src, 1, 1, &state) -> %Zd\00"
@.str.3 = [25 x i8] c", wc = %lu, src = buf+%d\00"
@.str.4 = [34 x i8] c", expected %Zd and %lu and buf+%d\00"
@stdout = global i32 0
@.str.5 = [44 x i8] c"mbsnrtowcs (&wc, &src, 3, 1, &state) -> %Zd\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
%7 = bitcast i8** %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 42, i32* %4
%9 = load i32, i32* @LC_CTYPE
%10 = tail call i8* @setlocale(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @LC_CTYPE
%12 = tail call i8* @setlocale(i32 %11, i8* null)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @memset(i32* %2, i8 signext 0, i32 4)
store i8* %5, i8** %3
%16 = call i64 @mbsnrtowcs(i32* %4, i8** %3, i32 1, i32 1, i32* %2)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %16)
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = load i8*, i8** %3
%21 = ptrtoint i8* %20 to i64
%22 = ptrtoint [6 x i8]* %1 to i64
%23 = sub i64 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %19, i64 %23)
%25 = icmp ne i64 %16, 1
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 37
%28 = select i1 %25, i1 true, i1 %27
%29 = load i8*, i8** %3
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 1
%31 = icmp ne i8* %29, %30
%32 = select i1 %28, i1 true, i1 %31
br i1 %32, label %33, label %35
33: ; preds = %0
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 37, i64 1)
br label %35
35: ; preds = %0, %33
%36 = phi i32 [ 1, %33 ], [ %14, %0 ]
%37 = load i32, i32* @stdout
%38 = call i32 @putc(i8 signext 10, i32 %37)
%39 = call i64 @mbsnrtowcs(i32* %4, i8** %3, i32 3, i32 1, i32* %2)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i64 %39)
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = load i8*, i8** %3
%44 = ptrtoint i8* %43 to i64
%45 = sub i64 %44, %22
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %42, i64 %45)
%47 = icmp ne i64 %39, 1
%48 = load i32, i32* %4
%49 = icmp ne i32 %48, 8364
%50 = select i1 %47, i1 true, i1 %49
%51 = load i8*, i8** %3
%52 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 4
%53 = icmp ne i8* %51, %52
%54 = select i1 %50, i1 true, i1 %53
br i1 %54, label %55, label %57
55: ; preds = %35
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 8364, i64 4)
br label %57
57: ; preds = %35, %55
%58 = phi i32 [ 1, %55 ], [ %36, %35 ]
%59 = load i32, i32* @stdout
%60 = call i32 @putc(i8 signext 10, i32 %59)
%61 = call i64 @mbsnrtowcs(i32* %4, i8** %3, i32 1, i32 1, i32* %2)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %61)
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = load i8*, i8** %3
%66 = ptrtoint i8* %65 to i64
%67 = sub i64 %66, %22
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %64, i64 %67)
%69 = icmp ne i64 %61, 0
%70 = load i32, i32* %4
%71 = icmp ne i32 %70, 8364
%72 = select i1 %69, i1 true, i1 %71
%73 = load i8*, i8** %3
%74 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 5
%75 = icmp ne i8* %73, %74
%76 = select i1 %72, i1 true, i1 %75
br i1 %76, label %77, label %79
77: ; preds = %57
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 0, i64 8364, i64 5)
br label %79
79: ; preds = %57, %77
%80 = phi i32 [ 1, %77 ], [ %58, %57 ]
%81 = load i32, i32* @stdout
%82 = call i32 @putc(i8 signext 10, i32 %81)
%83 = call i64 @mbsnrtowcs(i32* %4, i8** %3, i32 1, i32 1, i32* %2)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %83)
%85 = load i32, i32* %4
%86 = sext i32 %85 to i64
%87 = load i8*, i8** %3
%88 = ptrtoint i8* %87 to i64
%89 = sub i64 %88, %22
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %86, i64 %89)
%91 = icmp ne i64 %83, 1
%92 = load i32, i32* %4
%93 = icmp ne i32 %92, 955
%94 = select i1 %91, i1 true, i1 %93
%95 = load i8*, i8** %3
%96 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 6
%97 = icmp ne i8* %95, %96
%98 = select i1 %94, i1 true, i1 %97
br i1 %98, label %99, label %101
99: ; preds = %79
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 955, i64 6)
br label %101
101: ; preds = %79, %99
%102 = phi i32 [ 1, %99 ], [ %80, %79 ]
%103 = load i32, i32* @stdout
%104 = call i32 @putc(i8 signext 10, i32 %103)
ret i32 %102
}