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

/* Variables and functions */
scalar_t__ isupper(unsigned char);
int hotkey(const char *s) {
  int c0 = *s;
  for (; *s; s++)
    if (isupper((unsigned char)*s))
      break;
  return *s ? *s : c0;
}


x86 assembly (clang, -O0):
<hotkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1164 <hotkey+0x54>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isupper@plt>
cmp    $0x0,%rax
je     114e <hotkey+0x3e>
jmp    1164 <hotkey+0x54>
jmp    1153 <hotkey+0x43>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1126 <hotkey+0x16>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1183 <hotkey+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1189 <hotkey+0x79>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hotkey>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%bpl
test   %bpl,%bpl
je     1151 <hotkey+0x41>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %al,%edi
call   1030 <isupper@plt>
test   %rax,%rax
jne    114a <hotkey+0x3a>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <hotkey+0x20>
jmp    1151 <hotkey+0x41>
mov    -0x1(%rbx),%al
test   %al,%al
jne    1153 <hotkey+0x43>
mov    %ebp,%eax
movsbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hotkey(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
store i32 %6, i32* %3
br label %7
7: ; preds = %18, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = call i64 @isupper(i8 zeroext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
br label %21
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
br label %7
21: ; preds = %16, %7
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i8*, i8** %2
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
br label %32
30: ; preds = %21
%31 = load i32, i32* %3
br label %32
32: ; preds = %30, %26
%33 = phi i32 [ %29, %26 ], [ %31, %30 ]
ret i32 %33
}

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