#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*/ wchar_t;

/* Variables and functions */
int /*<<< orphan*/ fatwstochar(char *, int /*<<< orphan*/ *, int,
                               int /*<<< orphan*/ *);
unsigned char toupper(unsigned char);
void _fatwcstoupper(unsigned char *dst, wchar_t *src, int len) {
  int i;
  fatwstochar((char *)dst, src, len, NULL);
  for (i = 0; i < len; i++)
    dst[i] = toupper(dst[i]);
}


x86 assembly (clang, -O0):
<_fatwcstoupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <fatwstochar@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1186 <_fatwcstoupper+0x66>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <_fatwcstoupper+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_fatwcstoupper>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rdi,%rbx
xor    %ecx,%ecx
call   1040 <fatwstochar@plt>
test   %ebp,%ebp
jle    1155 <_fatwcstoupper+0x35>
mov    %ebp,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%edi
call   1030 <toupper@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1140 <_fatwcstoupper+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @_fatwcstoupper(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i32*, i32** %5
%10 = load i32, i32* %6
%11 = call i32 @fatwstochar(i8* %8, i32* %9, i32 %10, i32* null)
store i32 0, i32* %7
br label %12
12: ; preds = %27, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call zeroext i8 @toupper(i8 zeroext %21)
%23 = load i8*, i8** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
br label %27
27: ; preds = %16
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @_fatwcstoupper(i8* %0, i32* %1, i32 %2) {
%4 = tail call i32 @fatwstochar(i8* %0, i32* %1, i32 %2, i32* null)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %13, %8 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call zeroext i8 @toupper(i8 zeroext %11)
store i8 %12, i8* %10
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %7
br i1 %14, label %15, label %8
15: ; preds = %8, %3
ret void
}