#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 /*<<< orphan*/ q2;
typedef int /*<<< orphan*/ q;
typedef int /*<<< orphan*/ locale_t;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL_MASK;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ freelocale(int /*<<< orphan*/);
int /*<<< orphan*/ newlocale(int /*<<< orphan*/, char *, int /*<<< orphan*/);
size_t strxfrm(char *, char *, int);
size_t strxfrm_l(char *, char *, int, int /*<<< orphan*/);
int main(int argc, char **argv) {
  char q[10];
  size_t n = strxfrm(q, "abcdef", sizeof(q));
  assert(n < sizeof(q));
  char q2[10];
  locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
  n = strxfrm_l(q2, L"qwerty", sizeof(q), loc);
  assert(n < sizeof(q2));
  freelocale(loc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0xa,%edx
call   1060 <strxfrm@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0xa,-0x28(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
xor    %edx,%edx
call   1050 <newlocale@plt>
mov    %eax,-0x38(%rbp)
lea    -0x32(%rbp),%rdi
mov    -0x38(%rbp),%ecx
lea    0xe4f(%rip),%rsi
mov    $0xa,%edx
call   1040 <strxfrm_l@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0xa,-0x28(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x38(%rbp),%edi
call   1030 <freelocale@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xea4(%rip),%rsi
lea    0x16(%rsp),%rdi
mov    $0xa,%edx
call   1060 <strxfrm@plt>
xor    %edi,%edi
cmp    $0xa,%rax
setb   %dil
call   1070 <assert@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
xor    %edx,%edx
call   1050 <newlocale@plt>
mov    %eax,%ebx
lea    0xe6e(%rip),%rsi
lea    0xc(%rsp),%rdi
mov    $0xa,%edx
mov    %eax,%ecx
call   1040 <strxfrm_l@plt>
xor    %edi,%edi
cmp    $0xa,%rax
setb   %dil
call   1070 <assert@plt>
mov    %ebx,%edi
call   1030 <freelocale@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"abcdef\00"
@LC_ALL_MASK = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i32] [i32 113, i32 119, i32 101, i32 114, i32 116, i32 121, i32 0]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca i64
%8 = alloca [10 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%11 = call i64 @strxfrm(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 10)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp ult i64 %12, 10
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* @LC_ALL_MASK
%17 = call i32 @newlocale(i32 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 %17, i32* %9
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%19 = load i32, i32* %9
%20 = call i64 @strxfrm_l(i8* %18, i8* bitcast ([7 x i32]* @.str.2 to i8*), i32 10, i32 %19)
store i64 %20, i64* %7
%21 = load i64, i64* %7
%22 = icmp ult i64 %21, 10
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %9
%26 = call i32 @freelocale(i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"abcdef\00"
@LC_ALL_MASK = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i32] [i32 113, i32 119, i32 101, i32 114, i32 116, i32 121, i32 0]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i64 @strxfrm(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 10)
%7 = icmp ult i64 %6, 10
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* @LC_ALL_MASK
%12 = tail call i32 @newlocale(i32 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 0)
%13 = call i64 @strxfrm_l(i8* %10, i8* bitcast ([7 x i32]* @.str.2 to i8*), i32 10, i32 %12)
%14 = icmp ult i64 %13, 10
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @freelocale(i32 %12)
ret i32 0
}