#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 */
typedef int /*<<< orphan*/ fullname;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *,
                            char *);
int sscanf(char const *, char *, char *, char *, char *, char *);
int strcmp(char const *, char *);
int strlen(char const *);
int check_wikiname(const char *name) {
  if (strlen(name) == 0)
    return -1;
  char part1[80], part2[80], part3[80], part4[80];
  int r = sscanf(name, "%[A-Z]%[a-z]%[A-Z]%[a-z]", part1, part2, part3, part4);
  if (r != 4)
    return -1;
  if (strlen(part1) > 1 || strlen(part3) > 1)
    return -1;
  char fullname[80];
  snprintf(fullname, sizeof(fullname), "%s%s%s%s", part1, part2, part3, part4);
  return strcmp(name, fullname);
}


x86 assembly (clang, -O0):
<check_wikiname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    116d <check_wikiname+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1230 <check_wikiname+0xf0>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
lea    -0x100(%rbp),%r8
lea    -0x150(%rbp),%r9
lea    0xe6f(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,-0x154(%rbp)
cmpl   $0x4,-0x154(%rbp)
je     11b5 <check_wikiname+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    1230 <check_wikiname+0xf0>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jg     11dc <check_wikiname+0x9c>
lea    -0x100(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    11e8 <check_wikiname+0xa8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1230 <check_wikiname+0xf0>
lea    -0x1b0(%rbp),%rdi
lea    -0x60(%rbp),%rcx
lea    -0xb0(%rbp),%r8
lea    -0x100(%rbp),%r9
lea    -0x150(%rbp),%rax
mov    $0x50,%esi
lea    0xe05(%rip),%rdx
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_wikiname>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1a0,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     11f0 <check_wikiname+0xb0>
lea    0xe9e(%rip),%rsi
lea    0x60(%rsp),%rdx
lea    0xb0(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0x150(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%r9
call   1060 <sscanf@plt>
mov    $0xffffffff,%ebp
cmp    $0x4,%eax
jne    11f5 <check_wikiname+0xb5>
lea    0x60(%rsp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jg     11f5 <check_wikiname+0xb5>
lea    0x10(%rsp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jg     11f5 <check_wikiname+0xb5>
mov    %r14,(%rsp)
lea    0xe5f(%rip),%rdx
lea    0x100(%rsp),%rbp
lea    0x60(%rsp),%rcx
lea    0xb0(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rbp,%rdi
mov    $0x50,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
mov    %eax,%ebp
jmp    11f5 <check_wikiname+0xb5>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%[A-Z]%[a-z]%[A-Z]%[a-z]\00"
@.str.1 = [9 x i8] c"%s%s%s%s\00"
define i32 @check_wikiname(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = alloca i32
%9 = alloca [80 x i8]
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %43
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%20 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %18, i8* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 4
br i1 %22, label %23, label %24
23: ; preds = %14
store i32 -1, i32* %2
br label %43
24: ; preds = %14
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = icmp sgt i32 %26, 1
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %28, %24
store i32 -1, i32* %2
br label %43
33: ; preds = %28
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%39 = call i32 @snprintf(i8* %34, i32 80, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %36, i8* %37, i8* %38)
%40 = load i8*, i8** %3
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%42 = call i32 @strcmp(i8* %40, i8* %41)
store i32 %42, i32* %2
br label %43
43: ; preds = %33, %32, %23, %13
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@.str = [25 x i8] c"%[A-Z]%[a-z]%[A-Z]%[a-z]\00"
@.str.1 = [9 x i8] c"%s%s%s%s\00"
define i32 @check_wikiname(i8* %0) {
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %1
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%14 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i8* %12, i8* %13)
%15 = icmp eq i32 %14, 4
br i1 %15, label %16, label %26
16: ; preds = %9
%17 = call i32 @strlen(i8* %10)
%18 = icmp sgt i32 %17, 1
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = call i32 @strlen(i8* %12)
%21 = icmp sgt i32 %20, 1
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%24 = call i32 @snprintf(i8* %23, i32 80, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11, i8* %12, i8* %13)
%25 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* %23)
br label %26
26: ; preds = %16, %19, %9, %22
%27 = phi i32 [ %25, %22 ], [ -1, %9 ], [ -1, %19 ], [ -1, %16 ]
br label %28
28: ; preds = %1, %26
%29 = phi i32 [ %27, %26 ], [ -1, %1 ]
ret i32 %29
}