#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;

/* Variables and functions */
int /*<<< orphan*/ free(int *const);
scalar_t__ iswupper(int const);
int *to_wide(char const *);
int has_uppercase_letters(const char str[]) {
  int has_uppercase = 0;
  wchar_t *const wstring = to_wide(str);
  if (wstring != NULL) {
    const wchar_t *p = wstring - 1;
    while (*++p != L'\0') {
      if (iswupper(*p)) {
        has_uppercase = 1;
        break;
      }
    }
    free(wstring);
  }
  return has_uppercase;
}


x86 assembly (clang, -O0):
<has_uppercase_letters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <to_wide@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11af <has_uppercase_letters+0x7f>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,0x4(%rax)
je     11a6 <has_uppercase_letters+0x76>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1050 <iswupper@plt>
cmp    $0x0,%rax
je     11a1 <has_uppercase_letters+0x71>
movl   $0x1,-0xc(%rbp)
jmp    11a6 <has_uppercase_letters+0x76>
jmp    1167 <has_uppercase_letters+0x37>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_uppercase_letters>:
push   %rbp
push   %rbx
push   %rax
call   1040 <to_wide@plt>
test   %rax,%rax
je     116b <has_uppercase_letters+0x3b>
mov    %rax,%rbp
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%edi
test   %edi,%edi
je     116f <has_uppercase_letters+0x3f>
call   1050 <iswupper@plt>
add    $0x4,%rbx
test   %rax,%rax
je     1150 <has_uppercase_letters+0x20>
mov    $0x1,%ebx
jmp    1171 <has_uppercase_letters+0x41>
xor    %ebx,%ebx
jmp    1179 <has_uppercase_letters+0x49>
xor    %ebx,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @has_uppercase_letters(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = load i8*, i8** %2
%7 = call i32* @to_wide(i8* %6)
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %28
10: ; preds = %1
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 -1
store i32* %12, i32** %5
br label %13
13: ; preds = %24, %10
%14 = load i32*, i32** %5
%15 = getelementptr inbounds i32, i32* %14, i32 1
store i32* %15, i32** %5
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = call i64 @iswupper(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %3
br label %25
24: ; preds = %18
br label %13
25: ; preds = %23, %13
%26 = load i32*, i32** %4
%27 = call i32 @free(i32* %26)
br label %28
28: ; preds = %25, %1
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @has_uppercase_letters(i8* %0) {
%2 = tail call i32* @to_wide(i8* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = getelementptr inbounds i32, i32* %2, i64 -1
br label %6
6: ; preds = %11, %4
%7 = phi i32* [ %5, %4 ], [ %8, %11 ]
%8 = getelementptr inbounds i32, i32* %7, i64 1
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i64 @iswupper(i32 %9)
%13 = icmp eq i64 %12, 0
br i1 %13, label %6, label %14
14: ; preds = %11, %6
%15 = phi i32 [ 0, %6 ], [ 1, %11 ]
%16 = tail call i32 @free(i32* %2)
br label %17
17: ; preds = %14, %1
%18 = phi i32 [ %15, %14 ], [ 0, %1 ]
ret i32 %18
}