#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 /*<<< orphan*/ stderr;
int strlen(char *);
int check_name(char *object_name, int is_sprite_name) {
  int err_code = 0;
  int length = strlen(object_name);
  int char_idx;
  if (length > 50)
    err_code = 1;
  if (!((object_name[0] >= 'a' && object_name[0] <= 'z') ||
        (object_name[0] >= 'A' && object_name[0] <= 'Z')) &&
      is_sprite_name == 1)
    err_code = 2;
  for (char_idx = 1; char_idx < length; char_idx++) {
    if (!((object_name[char_idx] >= 'a' && object_name[char_idx] <= 'z') ||
          (object_name[char_idx] >= 'A' && object_name[char_idx] <= 'Z') ||
          (object_name[char_idx] >= '0' && object_name[char_idx] <= '9') ||
          (object_name[char_idx] >= '_'))) {
      err_code = 3;
      break;
    }
  }
  if (err_code) {
    fprintf(stderr,
            " WARNING: Name \"%s\" has invalid format. Skipping it. Reason: ",
            object_name);
    switch (err_code) {
    case 1:
      fprintf(stderr, "name is too long.\n");
      break;
    case 2:
      fprintf(stderr,
              "first name character of sprite is not an allowed letter.\n");
      break;
    case 3:
      fprintf(stderr, "some characters in name are not allowed.\n");
      break;
    default:
      fprintf(stderr, "unknown.\n");
      break;
    }
  }
  return err_code;
}


x86 assembly (clang, -O0):
<check_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jle    1153 <check_name+0x33>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     1173 <check_name+0x53>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jle    11a4 <check_name+0x84>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     1193 <check_name+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jle    11a4 <check_name+0x84>
cmpl   $0x1,-0xc(%rbp)
jne    11a4 <check_name+0x84>
movl   $0x2,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1269 <check_name+0x149>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jl     11e1 <check_name+0xc1>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7a,%eax
jle    1256 <check_name+0x136>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x41,%eax
jl     120b <check_name+0xeb>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5a,%eax
jle    1256 <check_name+0x136>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1235 <check_name+0x115>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1256 <check_name+0x136>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
jge    1256 <check_name+0x136>
movl   $0x3,-0x10(%rbp)
jmp    1269 <check_name+0x149>
jmp    125b <check_name+0x13b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ab <check_name+0x8b>
cmpl   $0x0,-0x10(%rbp)
je     1334 <check_name+0x214>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd79(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     12c4 <check_name+0x1a4>
jmp    12a2 <check_name+0x182>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     12e0 <check_name+0x1c0>
jmp    12b3 <check_name+0x193>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     12fc <check_name+0x1dc>
jmp    1318 <check_name+0x1f8>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    132f <check_name+0x20f>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    132f <check_name+0x20f>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    132f <check_name+0x20f>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1334 <check_name+0x214>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_name>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%rbp
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    $0x33,%eax
setge  %r14b
mov    0x0(%rbp),%cl
lea    -0x61(%rcx),%edx
cmp    $0x1a,%dl
jb     115f <check_name+0x3f>
cmp    $0x41,%cl
jl     1154 <check_name+0x34>
cmp    $0x1,%ebx
jne    115f <check_name+0x3f>
cmp    $0x5a,%cl
ja     1159 <check_name+0x39>
jmp    115f <check_name+0x3f>
cmp    $0x1,%ebx
jne    115f <check_name+0x3f>
mov    $0x2,%r14d
cmp    $0x2,%eax
jl     11c1 <check_name+0xa1>
mov    %eax,%eax
mov    $0x1,%ecx
jmp    1179 <check_name+0x59>
nopl   (%rax)
add    $0x1,%rcx
cmp    %rcx,%rax
je     11c1 <check_name+0xa1>
movzbl 0x0(%rbp,%rcx,1),%ebx
mov    %ebx,%edx
and    $0xdf,%dl
add    $0xbf,%dl
cmp    $0x1a,%dl
jb     1170 <check_name+0x50>
cmp    $0x5e,%bl
jg     1170 <check_name+0x50>
add    $0xd0,%bl
cmp    $0xa,%bl
jb     1170 <check_name+0x50>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x3,%r14d
lea    0xecc(%rip),%rsi
jmp    1207 <check_name+0xe7>
test   %r14d,%r14d
je     11fb <check_name+0xdb>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x1(%r14),%eax
cmp    $0x2,%eax
ja     1200 <check_name+0xe0>
cltq
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1207 <check_name+0xe7>
xor    %r14d,%r14d
jmp    1217 <check_name+0xf7>
lea    0xeae(%rip),%rsi
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [62 x i8] c" WARNING: Name \22%s\22 has invalid format. Skipping it. Reason: \00"
@.str.1 = [19 x i8] c"name is too long.\0A\00"
@.str.2 = [58 x i8] c"first name character of sprite is not an allowed letter.\0A\00"
@.str.3 = [42 x i8] c"some characters in name are not allowed.\0A\00"
@.str.4 = [10 x i8] c"unknown.\0A\00"
define i32 @check_name(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 50
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %5
br label %13
13: ; preds = %12, %2
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 97
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 122
br i1 %24, label %41, label %25
25: ; preds = %19, %13
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sge i32 %29, 65
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sle i32 %35, 90
br i1 %36, label %41, label %37
37: ; preds = %31, %25
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 2, i32* %5
br label %41
41: ; preds = %40, %37, %31, %19
store i32 1, i32* %7
br label %42
42: ; preds = %104, %41
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %107
46: ; preds = %42
%47 = load i8*, i8** %3
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp sge i32 %52, 97
br i1 %53, label %54, label %62
54: ; preds = %46
%55 = load i8*, i8** %3
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp sle i32 %60, 122
br i1 %61, label %103, label %62
62: ; preds = %54, %46
%63 = load i8*, i8** %3
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp sge i32 %68, 65
br i1 %69, label %70, label %78
70: ; preds = %62
%71 = load i8*, i8** %3
%72 = load i32, i32* %7
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp sle i32 %76, 90
br i1 %77, label %103, label %78
78: ; preds = %70, %62
%79 = load i8*, i8** %3
%80 = load i32, i32* %7
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp sge i32 %84, 48
br i1 %85, label %86, label %94
86: ; preds = %78
%87 = load i8*, i8** %3
%88 = load i32, i32* %7
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp sle i32 %92, 57
br i1 %93, label %103, label %94
94: ; preds = %86, %78
%95 = load i8*, i8** %3
%96 = load i32, i32* %7
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %95, i64 %97
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp sge i32 %100, 95
br i1 %101, label %103, label %102
102: ; preds = %94
store i32 3, i32* %5
br label %107
103: ; preds = %94, %86, %70, %54
br label %104
104: ; preds = %103
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
store i32 %106, i32* %7
br label %42
107: ; preds = %102, %42
%108 = load i32, i32* %5
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %128
110: ; preds = %107
%111 = load i32, i32* @stderr
%112 = load i8*, i8** %3
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* %112)
%114 = load i32, i32* %5
switch i32 %114, label %124 [
i32 1, label %115
i32 2, label %118
i32 3, label %121
]
115: ; preds = %110
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %127
118: ; preds = %110
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
br label %127
121: ; preds = %110
%122 = load i32, i32* @stderr
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
br label %127
124: ; preds = %110
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %127
127: ; preds = %124, %121, %118, %115
br label %128
128: ; preds = %127, %107
%129 = load i32, i32* %5
ret i32 %129
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [62 x i8] c" WARNING: Name \22%s\22 has invalid format. Skipping it. Reason: \00"
@.str.1 = [19 x i8] c"name is too long.\0A\00"
@.str.2 = [58 x i8] c"first name character of sprite is not an allowed letter.\0A\00"
@.str.3 = [42 x i8] c"some characters in name are not allowed.\0A\00"
@.str.4 = [10 x i8] c"unknown.\0A\00"
@reltable.check_name = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.check_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([58 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.check_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([42 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.check_name to i64)) to i32)]
define i32 @check_name(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 50
%5 = zext i1 %4 to i32
%6 = load i8, i8* %0
%7 = add i8 %6, -97
%8 = icmp ult i8 %7, 26
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = icmp sgt i8 %6, 64
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = icmp ugt i8 %6, 90
%13 = icmp eq i32 %1, 1
%14 = and i1 %13, %12
br i1 %14, label %17, label %18
15: ; preds = %9
%16 = icmp eq i32 %1, 1
br i1 %16, label %17, label %18
17: ; preds = %11, %15
br label %18
18: ; preds = %2, %17, %15, %11
%19 = phi i32 [ 2, %17 ], [ %5, %11 ], [ %5, %15 ], [ %5, %2 ]
%20 = icmp sgt i32 %3, 1
br i1 %20, label %21, label %41
21: ; preds = %18
%22 = zext i32 %3 to i64
br label %23
23: ; preds = %21, %38
%24 = phi i64 [ 1, %21 ], [ %39, %38 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = and i8 %26, -33
%28 = add i8 %27, -65
%29 = icmp ult i8 %28, 26
br i1 %29, label %38, label %30
30: ; preds = %23
%31 = add i8 %26, -48
%32 = icmp ult i8 %31, 10
%33 = icmp sgt i8 %26, 94
%34 = or i1 %33, %32
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %52
38: ; preds = %30, %23
%39 = add nuw nsw i64 %24, 1
%40 = icmp eq i64 %39, %22
br i1 %40, label %41, label %23
41: ; preds = %38, %18
%42 = icmp eq i32 %19, 0
br i1 %42, label %57, label %43
43: ; preds = %41
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* %0)
%46 = add nsw i32 %19, -1
%47 = icmp ult i32 %46, 3
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = sext i32 %46 to i64
%50 = shl i64 %49, 2
%51 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.check_name to i8*), i64 %50)
br label %52
52: ; preds = %43, %48, %35
%53 = phi i8* [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), %35 ], [ %51, %48 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %43 ]
%54 = phi i32 [ 3, %35 ], [ %19, %48 ], [ %19, %43 ]
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* %53)
br label %57
57: ; preds = %52, %41
%58 = phi i32 [ 0, %41 ], [ %54, %52 ]
ret i32 %58
}