#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*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ isprint(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ stderr;
int is_variant(char *variant) {
  int i = 0;
  char c;
  int state;
  state = 0;
  while (state != 50 && state <= 99) {
    c = variant[i++];
    if (isupper(c)) {
      c = 'A';
    } else if (isprint(c) && c != ' ') {
      c = '@';
    }
    switch (state) {
    case 0:
      switch (c) {
      case '@':
        state = 0;
        continue;
      case '\0':
        state = 50;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    default:
      fprintf(stderr, "is_variant(): Illegal state=%d\n", state);
      return 0;
    }
  }
  if (state == 50) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<is_variant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
je     1163 <is_variant+0x33>
cmpl   $0x63,-0x1c(%rbp)
setle  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1173 <is_variant+0x43>
jmp    124f <is_variant+0x11f>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     11a7 <is_variant+0x77>
movb   $0x41,-0x15(%rbp)
jmp    11d0 <is_variant+0xa0>
movsbl -0x15(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     11cb <is_variant+0x9b>
movsbl -0x15(%rbp),%eax
cmp    $0x20,%eax
je     11cb <is_variant+0x9b>
movb   $0x40,-0x15(%rbp)
jmp    11d0 <is_variant+0xa0>
mov    -0x1c(%rbp),%eax
test   %eax,%eax
jne    122b <is_variant+0xfb>
jmp    11e0 <is_variant+0xb0>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     1211 <is_variant+0xe1>
jmp    11f4 <is_variant+0xc4>
mov    -0x24(%rbp),%eax
sub    $0x40,%eax
jne    121d <is_variant+0xed>
jmp    1205 <is_variant+0xd5>
movl   $0x0,-0x1c(%rbp)
jmp    114a <is_variant+0x1a>
movl   $0x32,-0x1c(%rbp)
jmp    114a <is_variant+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <is_variant+0x1a>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xdc2(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    126c <is_variant+0x13c>
cmpl   $0x32,-0x1c(%rbp)
jne    1265 <is_variant+0x135>
movl   $0x1,-0x4(%rbp)
jmp    126c <is_variant+0x13c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_variant>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
jmp    1143 <is_variant+0x23>
nopl   0x0(%rax)
cmp    $0x20,%r14b
cmovne %edx,%ecx
movsbl %cl,%eax
add    $0x1,%rbx
cmp    $0x40,%eax
jne    1172 <is_variant+0x52>
movzbl (%rbx),%r14d
movsbl %r14b,%ebp
mov    %ebp,%edi
call   1030 <isupper@plt>
mov    $0x41,%cl
test   %rax,%rax
jne    1137 <is_variant+0x17>
mov    %ebp,%edi
call   1040 <isprint@plt>
movzbl %bpl,%ecx
mov    $0x40,%edx
test   %rax,%rax
jne    1130 <is_variant+0x10>
mov    %ecx,%edx
jmp    1130 <is_variant+0x10>
test   %eax,%eax
jne    117d <is_variant+0x5d>
mov    $0x1,%eax
jmp    117f <is_variant+0x5f>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"is_variant(): Illegal state=%d\0A\00"
define i32 @is_variant(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %6
br label %7
7: ; preds = %43, %42, %41, %1
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 50
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 99
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ false, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %50
15: ; preds = %13
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %5
%22 = load i8, i8* %5
%23 = call i64 @isupper(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %15
store i8 65, i8* %5
br label %36
26: ; preds = %15
%27 = load i8, i8* %5
%28 = call i64 @isprint(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 32
br i1 %33, label %34, label %35
34: ; preds = %30
store i8 64, i8* %5
br label %35
35: ; preds = %34, %30, %26
br label %36
36: ; preds = %35, %25
%37 = load i32, i32* %6
switch i32 %37, label %46 [
i32 0, label %38
]
38: ; preds = %36
%39 = load i8, i8* %5
%40 = sext i8 %39 to i32
switch i32 %40, label %43 [
i32 64, label %41
i32 0, label %42
]
41: ; preds = %38
store i32 0, i32* %6
br label %7
42: ; preds = %38
store i32 50, i32* %6
br label %7
43: ; preds = %38
%44 = load i32, i32* %6
%45 = add nsw i32 100, %44
store i32 %45, i32* %6
br label %7
46: ; preds = %36
%47 = load i32, i32* @stderr
%48 = load i32, i32* %6
%49 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %48)
store i32 0, i32* %2
br label %55
50: ; preds = %13
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 50
br i1 %52, label %53, label %54
53: ; preds = %50
store i32 1, i32* %2
br label %55
54: ; preds = %50
store i32 0, i32* %2
br label %55
55: ; preds = %54, %53, %46
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @is_variant(i8* nocapture %0) {
br label %2
2: ; preds = %15, %1
%3 = phi i64 [ 0, %1 ], [ %4, %15 ]
%4 = add nuw i64 %3, 1
%5 = getelementptr inbounds i8, i8* %0, i64 %3
%6 = load i8, i8* %5
%7 = tail call i64 @isupper(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = tail call i64 @isprint(i8 signext %6)
%11 = icmp ne i64 %10, 0
%12 = icmp ne i8 %6, 32
%13 = and i1 %12, %11
%14 = select i1 %13, i8 64, i8 %6
br label %15
15: ; preds = %9, %2
%16 = phi i8 [ %14, %9 ], [ 65, %2 ]
%17 = sext i8 %16 to i32
switch i32 %17, label %18 [
i32 64, label %2
i32 0, label %19
]
18: ; preds = %15
br label %19
19: ; preds = %15, %18
%20 = phi i32 [ 0, %18 ], [ 1, %15 ]
ret i32 %20
}