#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 */
int /*<<< orphan*/ assert(int);
int _isonlyx(char *str) {
  int c = 0;
  char *p = str;
  assert(str && "null string!");
  while (*p != '\0') {
    if (*p != 'x' && *p != 'X')
      return 0;
    ++p;
    ++c;
  }
  return c == 1 ? 1 : 0;
}


x86 assembly (clang, -O0):
<_isonlyx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
je     1145 <_isonlyx+0x35>
mov    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    1145 <_isonlyx+0x35>
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a8 <_isonlyx+0x98>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x78,%eax
je     118e <_isonlyx+0x7e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x58,%eax
je     118e <_isonlyx+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11bb <_isonlyx+0xab>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <_isonlyx+0x42>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_isonlyx>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %ecx,%ecx
jmp    1134 <_isonlyx+0x24>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rcx
movzbl (%rbx,%rcx,1),%eax
cmp    $0x58,%al
je     1130 <_isonlyx+0x20>
cmp    $0x78,%al
je     1130 <_isonlyx+0x20>
test   %al,%al
jne    114e <_isonlyx+0x3e>
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"null string!\00"
define i32 @_isonlyx(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
br label %10
10: ; preds = %9, %1
%11 = phi i1 [ false, %1 ], [ true, %9 ]
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
br label %14
14: ; preds = %30, %10
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %35
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 120
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 88
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %2
br label %40
30: ; preds = %24, %19
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %5
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %14
35: ; preds = %14
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 1
%38 = zext i1 %37 to i64
%39 = select i1 %37, i32 1, i32 0
store i32 %39, i32* %2
br label %40
40: ; preds = %35, %29
%41 = load i32, i32* %2
ret i32 %41
}

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