#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__ isalpha(int);
scalar_t__ isupper(int);
int string_to_char(char const **);
int dlg_button_to_char(const char *label) {
  int cmp = -1;
  while (*label != 0) {
    cmp = string_to_char(&label);
    if ((isalpha(cmp) && isupper(cmp))) {
      break;
    }
  }
  return cmp;
}


x86 assembly (clang, -O0):
<dlg_button_to_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118d <dlg_button_to_char+0x5d>
lea    -0x8(%rbp),%rdi
call   1030 <string_to_char@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     1188 <dlg_button_to_char+0x58>
mov    -0xc(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     1188 <dlg_button_to_char+0x58>
jmp    118d <dlg_button_to_char+0x5d>
jmp    1143 <dlg_button_to_char+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dlg_button_to_char>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,(%rsp)
cmpb   $0x0,(%rdi)
je     117d <dlg_button_to_char+0x4d>
mov    %rsp,%r14
jmp    1159 <dlg_button_to_char+0x29>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1182 <dlg_button_to_char+0x52>
mov    %r14,%rdi
call   1030 <string_to_char@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
je     1150 <dlg_button_to_char+0x20>
mov    %ebx,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     1150 <dlg_button_to_char+0x20>
jmp    1182 <dlg_button_to_char+0x52>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @dlg_button_to_char(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 -1, i32* %3
br label %4
4: ; preds = %19, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %4
%10 = call i32 @string_to_char(i8** %2)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i64 @isalpha(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* %3
%16 = call i64 @isupper(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %20
19: ; preds = %14, %9
br label %4
20: ; preds = %18, %4
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
define i32 @dlg_button_to_char(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %1, %12
%6 = call i32 @string_to_char(i8** %2)
%7 = call i64 @isalpha(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = call i64 @isupper(i32 %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9, %5
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %12, %9, %1
%17 = phi i32 [ -1, %1 ], [ %6, %9 ], [ %6, %12 ]
ret i32 %17
}