#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 mbrtowc(int *, char const *, 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) {
  const unsigned char buf[6] = {0x25, 0xe2, 0x82, 0xac, 0xce, 0xbb};
  mbstate_t state;
  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));
  n = mbrtowc(&wc, (const char *)buf + 0, 1, &state);
  printf("mbrtowc (&wc, (const char *) buf + 0, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu", (unsigned long int)wc);
  if (n != (size_t)1 || wc != 37) {
    printf(", expected %Zd and %lu", 1, (unsigned long int)37);
    result = 1;
  }
  putc('\n', stdout);
  n = mbrtowc(&wc, (const char *)buf + 1, 1, &state);
  printf("mbrtowc (&wc, (const char *) buf + 1, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu", (unsigned long int)wc);
  if (n != (size_t)-2 || wc != 37) {
    printf(", expected %Zd and %lu", -2, (unsigned long int)37);
    result = 1;
  }
  putc('\n', stdout);
  n = mbrtowc(&wc, (const char *)buf + 2, 3, &state);
  printf("mbrtowc (&wc, (const char *) buf + 2, 3, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu", (unsigned long int)wc);
  if (n != (size_t)2 || wc != 8364) {
    printf(", expected %Zd and %lu", 2, (unsigned long int)8364);
    result = 1;
  }
  putc('\n', stdout);
  n = mbrtowc(&wc, (const char *)buf + 4, 1, &state);
  printf("mbrtowc (&wc, (const char *) buf + 4, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu", (unsigned long int)wc);
  if (n != (size_t)-2 || wc != 8364) {
    printf(", expected %Zd and %lu", -2, (unsigned long int)8364);
    result = 1;
  }
  putc('\n', stdout);
  n = mbrtowc(&wc, (const char *)buf + 5, 1, &state);
  printf("mbrtowc (&wc, (const char *) buf + 5, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu", (unsigned long int)wc);
  if (n != (size_t)1 || wc != 955) {
    printf(", expected %Zd and %lu", 1, (unsigned long int)955);
    result = 1;
  }
  putc('\n', stdout);
  n = mbrtowc(&wc, (const char *)buf + 5, 1, &state);
  printf("mbrtowc (&wc, (const char *) buf + 5, 1, &state)"
         " -> %Zd",
         n);
  printf(", wc = %lu", (unsigned long int)wc);
  if (n != (size_t)-1 || wc != 955) {
    printf(", expected %Zd and %lu", -1, (unsigned long int)955);
    result = 1;
  }
  putc('\n', stdout);
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe85(%rip),%ax
mov    %ax,-0x6(%rbp)
movl   $0x2a,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1080 <setlocale@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <setlocale@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x24(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    -0xa(%rbp),%rsi
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
lea    -0x10(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rsi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x1,-0x20(%rbp)
jne    1244 <main+0xe4>
cmpl   $0x25,-0x14(%rbp)
je     1263 <main+0x103>
lea    0xe1d(%rip),%rdi
mov    $0x1,%esi
mov    $0x25,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    -0xa(%rbp),%rsi
add    $0x1,%rsi
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
lea    -0x10(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rsi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0xfffffffffffffffe,-0x20(%rbp)
jne    12cd <main+0x16d>
cmpl   $0x25,-0x14(%rbp)
je     12ec <main+0x18c>
lea    0xd94(%rip),%rdi
mov    $0xfffffffe,%esi
mov    $0x25,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    0x2ce5(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    -0xa(%rbp),%rsi
add    $0x2,%rsi
lea    -0x14(%rbp),%rdi
mov    $0x3,%edx
lea    -0x10(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rsi
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x2,-0x20(%rbp)
jne    1359 <main+0x1f9>
cmpl   $0x20ac,-0x14(%rbp)
je     1378 <main+0x218>
lea    0xd08(%rip),%rdi
mov    $0x2,%esi
mov    $0x20ac,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    0x2c59(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    -0xa(%rbp),%rsi
add    $0x4,%rsi
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
lea    -0x10(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rsi
lea    0xc97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0xfffffffffffffffe,-0x20(%rbp)
jne    13e5 <main+0x285>
cmpl   $0x20ac,-0x14(%rbp)
je     1404 <main+0x2a4>
lea    0xc7c(%rip),%rdi
mov    $0xfffffffe,%esi
mov    $0x20ac,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    0x2bcd(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    -0xa(%rbp),%rsi
add    $0x5,%rsi
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
lea    -0x10(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rsi
lea    0xc0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x1,-0x20(%rbp)
jne    1471 <main+0x311>
cmpl   $0x3bb,-0x14(%rbp)
je     1490 <main+0x330>
lea    0xbf0(%rip),%rdi
mov    $0x1,%esi
mov    $0x3bb,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    0x2b41(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    -0xa(%rbp),%rsi
add    $0x5,%rsi
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
lea    -0x10(%rbp),%rcx
call   1030 <mbrtowc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rsi
lea    0xb7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    14fd <main+0x39d>
cmpl   $0x3bb,-0x14(%rbp)
je     151c <main+0x3bc>
lea    0xb64(%rip),%rdi
mov    $0xffffffff,%esi
mov    $0x3bb,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    0x2ab5(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movw   $0xbbce,0x14(%rsp)
movl   $0xac82e225,0x10(%rsp)
ac
movl   $0x2a,0x8(%rsp)
mov    0x2e60(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe74(%rip),%rbx
mov    %rbx,%rsi
call   1080 <setlocale@plt>
mov    0x0(%rbp),%edi
xor    %esi,%esi
call   1080 <setlocale@plt>
mov    %rax,%rbp
lea    0xe64(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
mov    %eax,%r14d
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <mbrtowc@plt>
mov    %rax,%rbx
lea    0xe2a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%rbx
jne    1225 <main+0xc5>
cmpl   $0x25,0x8(%rsp)
je     1243 <main+0xe3>
lea    0xe3c(%rip),%rdi
mov    $0x25,%edx
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    0x2d8e(%rip),%r15
mov    (%r15),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    0x11(%rsp),%rsi
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    $0x1,%edx
call   1030 <mbrtowc@plt>
mov    %rax,%rbx
lea    0xe05(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xfffffffffffffffe,%rbx
jne    12a4 <main+0x144>
cmpl   $0x25,0x8(%rsp)
je     12c2 <main+0x162>
lea    0xdbd(%rip),%rdi
mov    $0x25,%edx
mov    $0xfffffffe,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    (%r15),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    0x12(%rsp),%rsi
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    $0x3,%edx
call   1030 <mbrtowc@plt>
mov    %rax,%rbx
lea    0xdc5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
lea    0xd55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%rbx
jne    131f <main+0x1bf>
cmpl   $0x20ac,0x8(%rsp)
je     133d <main+0x1dd>
lea    0xd42(%rip),%rdi
mov    $0x20ac,%edx
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    (%r15),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    0x14(%rsp),%rsi
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    $0x1,%edx
call   1030 <mbrtowc@plt>
mov    %rax,%rbx
lea    0xd82(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
lea    0xcda(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xfffffffffffffffe,%rbx
jne    139a <main+0x23a>
cmpl   $0x20ac,0x8(%rsp)
je     13b8 <main+0x258>
lea    0xcc7(%rip),%rdi
mov    $0x20ac,%edx
mov    $0xfffffffe,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    (%r15),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    0x15(%rsp),%rbx
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <mbrtowc@plt>
mov    %rax,%rbp
lea    0xd3c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
lea    0xc5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%rbp
jne    1418 <main+0x2b8>
cmpl   $0x3bb,0x8(%rsp)
je     1436 <main+0x2d6>
lea    0xc49(%rip),%rdi
mov    $0x3bb,%edx
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    (%r15),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <mbrtowc@plt>
mov    %rax,%rbx
lea    0xcc3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rsi
lea    0xbe3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xffffffffffffffff,%rbx
jne    1491 <main+0x331>
cmpl   $0x3bb,0x8(%rsp)
je     14af <main+0x34f>
lea    0xbd0(%rip),%rdi
mov    $0x3bb,%edx
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    (%r15),%esi
mov    $0xa,%edi
call   1070 <putc@plt>
mov    %r14d,%eax
add    $0x18,%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 = [56 x i8] c"mbrtowc (&wc, (const char *) buf + 0, 1, &state) -> %Zd\00"
@.str.3 = [11 x i8] c", wc = %lu\00"
@.str.4 = [23 x i8] c", expected %Zd and %lu\00"
@stdout = global i32 0
@.str.5 = [56 x i8] c"mbrtowc (&wc, (const char *) buf + 1, 1, &state) -> %Zd\00"
@.str.6 = [56 x i8] c"mbrtowc (&wc, (const char *) buf + 2, 3, &state) -> %Zd\00"
@.str.7 = [56 x i8] c"mbrtowc (&wc, (const char *) buf + 4, 1, &state) -> %Zd\00"
@.str.8 = [56 x i8] c"mbrtowc (&wc, (const char *) buf + 5, 1, &state) -> %Zd\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %1
%8 = bitcast [6 x i8]* %2 to i8*
store i32 42, i32* %4
store i32 0, i32* %6
%9 = load i32, i32* @LC_CTYPE
%10 = 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 = call i8* @setlocale(i32 %11, i8* null)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %7
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %6
%17 = call i32 @memset(i32* %3, i8 signext 0, i32 4)
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = call i64 @mbrtowc(i32* %4, i8* %19, i32 1, i32* %3)
store i64 %20, i64* %5
%21 = load i64, i64* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i64 %21)
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %24)
%26 = load i64, i64* %5
%27 = icmp ne i64 %26, 1
br i1 %27, label %31, label %28
28: ; preds = %0
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 37
br i1 %30, label %31, label %33
31: ; preds = %28, %0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 37)
store i32 1, i32* %6
br label %33
33: ; preds = %31, %28
%34 = load i32, i32* @stdout
%35 = call i32 @putc(i8 signext 10, i32 %34)
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = call i64 @mbrtowc(i32* %4, i8* %37, i32 1, i32* %3)
store i64 %38, i64* %5
%39 = load i64, i64* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i64 %39)
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %42)
%44 = load i64, i64* %5
%45 = icmp ne i64 %44, -2
br i1 %45, label %49, label %46
46: ; preds = %33
%47 = load i32, i32* %4
%48 = icmp ne i32 %47, 37
br i1 %48, label %49, label %51
49: ; preds = %46, %33
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 -2, i64 37)
store i32 1, i32* %6
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* @stdout
%53 = call i32 @putc(i8 signext 10, i32 %52)
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%55 = getelementptr inbounds i8, i8* %54, i64 2
%56 = call i64 @mbrtowc(i32* %4, i8* %55, i32 3, i32* %3)
store i64 %56, i64* %5
%57 = load i64, i64* %5
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i64 %57)
%59 = load i32, i32* %4
%60 = sext i32 %59 to i64
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %60)
%62 = load i64, i64* %5
%63 = icmp ne i64 %62, 2
br i1 %63, label %67, label %64
64: ; preds = %51
%65 = load i32, i32* %4
%66 = icmp ne i32 %65, 8364
br i1 %66, label %67, label %69
67: ; preds = %64, %51
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 2, i64 8364)
store i32 1, i32* %6
br label %69
69: ; preds = %67, %64
%70 = load i32, i32* @stdout
%71 = call i32 @putc(i8 signext 10, i32 %70)
%72 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%73 = getelementptr inbounds i8, i8* %72, i64 4
%74 = call i64 @mbrtowc(i32* %4, i8* %73, i32 1, i32* %3)
store i64 %74, i64* %5
%75 = load i64, i64* %5
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i64 %75)
%77 = load i32, i32* %4
%78 = sext i32 %77 to i64
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %78)
%80 = load i64, i64* %5
%81 = icmp ne i64 %80, -2
br i1 %81, label %85, label %82
82: ; preds = %69
%83 = load i32, i32* %4
%84 = icmp ne i32 %83, 8364
br i1 %84, label %85, label %87
85: ; preds = %82, %69
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 -2, i64 8364)
store i32 1, i32* %6
br label %87
87: ; preds = %85, %82
%88 = load i32, i32* @stdout
%89 = call i32 @putc(i8 signext 10, i32 %88)
%90 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%91 = getelementptr inbounds i8, i8* %90, i64 5
%92 = call i64 @mbrtowc(i32* %4, i8* %91, i32 1, i32* %3)
store i64 %92, i64* %5
%93 = load i64, i64* %5
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i64 %93)
%95 = load i32, i32* %4
%96 = sext i32 %95 to i64
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %96)
%98 = load i64, i64* %5
%99 = icmp ne i64 %98, 1
br i1 %99, label %103, label %100
100: ; preds = %87
%101 = load i32, i32* %4
%102 = icmp ne i32 %101, 955
br i1 %102, label %103, label %105
103: ; preds = %100, %87
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 1, i64 955)
store i32 1, i32* %6
br label %105
105: ; preds = %103, %100
%106 = load i32, i32* @stdout
%107 = call i32 @putc(i8 signext 10, i32 %106)
%108 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%109 = getelementptr inbounds i8, i8* %108, i64 5
%110 = call i64 @mbrtowc(i32* %4, i8* %109, i32 1, i32* %3)
store i64 %110, i64* %5
%111 = load i64, i64* %5
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i64 %111)
%113 = load i32, i32* %4
%114 = sext i32 %113 to i64
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %114)
%116 = load i64, i64* %5
%117 = icmp ne i64 %116, -1
br i1 %117, label %121, label %118
118: ; preds = %105
%119 = load i32, i32* %4
%120 = icmp ne i32 %119, 955
br i1 %120, label %121, label %123
121: ; preds = %118, %105
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 -1, i64 955)
store i32 1, i32* %6
br label %123
123: ; preds = %121, %118
%124 = load i32, i32* @stdout
%125 = call i32 @putc(i8 signext 10, i32 %124)
%126 = load i32, i32* %6
ret i32 %126
}

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