#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__ isdigit(unsigned char const);
scalar_t__ islower(unsigned char const);
scalar_t__ isupper(unsigned char const);
int find_if_alien(const unsigned char *ship_name) {
  if (isupper(*ship_name)) {
    const unsigned char *s;
    for (s = ship_name + 1; islower(*s); s++)
      ;
    if (s > ship_name + 1 && *s == ' ') {
      for (s++; isdigit(*s); s++)
        ;
      if (*s == '\0') {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<find_if_alien>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     120d <find_if_alien+0xdd>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     118a <find_if_alien+0x5a>
jmp    1179 <find_if_alien+0x49>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115e <find_if_alien+0x2e>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jbe    1208 <find_if_alien+0xd8>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jne    1208 <find_if_alien+0xd8>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11e7 <find_if_alien+0xb7>
jmp    11d6 <find_if_alien+0xa6>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11bb <find_if_alien+0x8b>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1203 <find_if_alien+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    1214 <find_if_alien+0xe4>
jmp    1208 <find_if_alien+0xd8>
jmp    120d <find_if_alien+0xdd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_if_alien>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movzbl (%rdi),%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     1197 <find_if_alien+0x67>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl 0x1(%r14,%rbx,1),%edi
call   1040 <islower@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <find_if_alien+0x20>
cmp    $0x2,%rbx
jb     1197 <find_if_alien+0x67>
cmpb   $0x20,(%r14,%rbx,1)
jne    1197 <find_if_alien+0x67>
add    %r14,%rbx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1180 <find_if_alien+0x50>
cmpb   $0x0,-0x1(%rbx)
je     11a1 <find_if_alien+0x71>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%eax
jmp    1199 <find_if_alien+0x69>

LLVM IR (-O0):
define i32 @find_if_alien(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = call i64 @isupper(i8 zeroext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %51
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %11, i8** %4
br label %12
12: ; preds = %18, %9
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = call i64 @islower(i8 zeroext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
br label %18
18: ; preds = %17
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
br label %12
21: ; preds = %12
%22 = load i8*, i8** %4
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = icmp ugt i8* %22, %24
br i1 %25, label %26, label %50
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %50
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
br label %34
34: ; preds = %40, %31
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = call i64 @isdigit(i8 zeroext %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %34
br label %40
40: ; preds = %39
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %4
br label %34
43: ; preds = %34
%44 = load i8*, i8** %4
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %43
store i32 1, i32* %2
br label %52
49: ; preds = %43
br label %50
50: ; preds = %49, %26, %21
br label %51
51: ; preds = %50, %1
store i32 0, i32* %2
br label %52
52: ; preds = %51, %48
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
define i32 @find_if_alien(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isupper(i8 zeroext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %11, %5 ], [ 1, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i64 @islower(i8 zeroext %8)
%10 = icmp eq i64 %9, 0
%11 = add nuw nsw i64 %6, 1
br i1 %10, label %12, label %5
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %0, i64 %6
%14 = icmp ugt i64 %6, 1
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 32
br i1 %17, label %18, label %27
18: ; preds = %15, %18
%19 = phi i8* [ %20, %18 ], [ %13, %15 ]
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = tail call i64 @isdigit(i8 zeroext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %18
24: ; preds = %18
%25 = load i8, i8* %20
%26 = icmp eq i8 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %12, %15, %24
br label %28
28: ; preds = %1, %27, %24
%29 = phi i32 [ 1, %24 ], [ 0, %27 ], [ 0, %1 ]
ret i32 %29
}