#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 */
char toupper(int /*<<< orphan*/);
char *find_validation_name(char *validation) {
  static char buf[100];
  int want = 1;
  while (*validation >= ' ') {
    if (want == 1) {
      if ((*validation == 'N') || (*validation == 'n')) {
        int i = 0;
        validation++;
        for (; *validation >= ' ' && *validation != ';';) {
          if (*validation == '\\')
            validation++;
          buf[i++] = toupper(*validation++);
        }
        buf[i] = '\0';
        return &buf[0];
      } else
        want = 0;
    } else {
      if (*validation == '\\')
        validation++;
      else if (*validation == ';')
        want = 1;
    }
    validation++;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_validation_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     1275 <find_validation_name+0x165>
cmpl   $0x1,-0x14(%rbp)
jne    1222 <find_validation_name+0x112>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
je     115d <find_validation_name+0x4d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    1216 <find_validation_name+0x106>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x19(%rbp)
jl     1195 <find_validation_name+0x85>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a5 <find_validation_name+0x95>
jmp    11f7 <find_validation_name+0xe7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11c1 <find_validation_name+0xb1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
movslq %eax,%rcx
lea    0x2e51(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1170 <find_validation_name+0x60>
movslq -0x18(%rbp),%rcx
lea    0x2e3e(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e33(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    127d <find_validation_name+0x16d>
movl   $0x0,-0x14(%rbp)
jmp    1264 <find_validation_name+0x154>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1243 <find_validation_name+0x133>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    125f <find_validation_name+0x14f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
jne    125a <find_validation_name+0x14a>
movl   $0x1,-0x14(%rbp)
jmp    125f <find_validation_name+0x14f>
jmp    1264 <find_validation_name+0x154>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <find_validation_name+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_validation_name>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%dl
cmp    $0x20,%dl
jl     1177 <find_validation_name+0x67>
mov    %rdi,%rbx
mov    $0x1,%ecx
xor    %eax,%eax
jmp    114b <find_validation_name+0x3b>
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
or     $0x20,%dl
cmp    $0x6e,%dl
je     117b <find_validation_name+0x6b>
movzbl 0x1(%rbx),%edx
add    $0x1,%rbx
cmp    $0x1f,%dl
jle    11e2 <find_validation_name+0xd2>
cmp    $0x1,%ecx
je     1130 <find_validation_name+0x20>
cmp    $0x3b,%dl
je     1170 <find_validation_name+0x60>
xor    %ecx,%ecx
cmp    $0x5c,%dl
jne    113a <find_validation_name+0x2a>
add    $0x1,%rbx
jmp    113a <find_validation_name+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%ecx
jmp    113a <find_validation_name+0x2a>
xor    %eax,%eax
jmp    11e2 <find_validation_name+0xd2>
mov    0x1(%rbx),%al
xor    %ecx,%ecx
cmp    $0x20,%al
jl     11d7 <find_validation_name+0xc7>
cmp    $0x3b,%al
je     11d7 <find_validation_name+0xc7>
lea    0x1(%rbx),%rcx
xor    %r14d,%r14d
lea    0x2eaa(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
cmp    $0x5c,%al
je     11b0 <find_validation_name+0xa0>
mov    %rcx,%rbx
jmp    11b4 <find_validation_name+0xa4>
nopl   0x0(%rax)
add    $0x2,%rbx
movsbl (%rbx),%edi
call   1030 <toupper@plt>
mov    %al,(%r14,%r15,1)
add    $0x1,%r14
movzbl 0x1(%rbx),%eax
cmp    $0x20,%al
jl     11d4 <find_validation_name+0xc4>
lea    0x1(%rbx),%rcx
cmp    $0x3b,%al
jne    11a0 <find_validation_name+0x90>
mov    %r14d,%ecx
lea    0x2e62(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@find_validation_name.buf = internal global [100 x i8] zeroinitializer
define i8* @find_validation_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 1, i32* %4
br label %6
6: ; preds = %79, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp sge i32 %9, 32
br i1 %10, label %11, label %82
11: ; preds = %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %63
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 78
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 110
br i1 %23, label %24, label %61
24: ; preds = %19, %14
store i32 0, i32* %5
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %27
27: ; preds = %47, %24
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp sge i32 %30, 32
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 59
br label %37
37: ; preds = %32, %27
%38 = phi i1 [ false, %27 ], [ %36, %32 ]
br i1 %38, label %39, label %57
39: ; preds = %37
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 92
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %3
br label %47
47: ; preds = %44, %39
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %3
%50 = load i8, i8* %48
%51 = sext i8 %50 to i32
%52 = call signext i8 @toupper(i32 %51)
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds [100 x i8], [100 x i8]* @find_validation_name.buf, i64 0, i64 %55
store i8 %52, i8* %56
br label %27
57: ; preds = %37
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i8], [100 x i8]* @find_validation_name.buf, i64 0, i64 %59
store i8 0, i8* %60
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @find_validation_name.buf, i64 0, i64 0), i8** %2
br label %83
61: ; preds = %19
store i32 0, i32* %4
br label %62
62: ; preds = %61
br label %79
63: ; preds = %11
%64 = load i8*, i8** %3
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 92
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load i8*, i8** %3
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %3
br label %78
71: ; preds = %63
%72 = load i8*, i8** %3
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 59
br i1 %75, label %76, label %77
76: ; preds = %71
store i32 1, i32* %4
br label %77
77: ; preds = %76, %71
br label %78
78: ; preds = %77, %68
br label %79
79: ; preds = %78, %62
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %3
br label %6
82: ; preds = %6
store i8* null, i8** %2
br label %83
83: ; preds = %82, %57
%84 = load i8*, i8** %2
ret i8* %84
}

LLVM IR (-O2):
@find_validation_name.buf = internal global [100 x i8] zeroinitializer
define i8* @find_validation_name(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp sgt i8 %2, 31
br i1 %3, label %4, label %49
4: ; preds = %1, %43
%5 = phi i8 [ %47, %43 ], [ %2, %1 ]
%6 = phi i32 [ %45, %43 ], [ 1, %1 ]
%7 = phi i8* [ %46, %43 ], [ %0, %1 ]
%8 = icmp eq i32 %6, 1
br i1 %8, label %9, label %39
9: ; preds = %4
switch i8 %5, label %43 [
i8 78, label %10
i8 110, label %10
]
10: ; preds = %9, %9
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp slt i8 %12, 32
%14 = icmp eq i8 %12, 59
%15 = or i1 %13, %14
br i1 %15, label %36, label %16
16: ; preds = %10, %16
%17 = phi i64 [ %27, %16 ], [ 0, %10 ]
%18 = phi i8 [ %30, %16 ], [ %12, %10 ]
%19 = phi i8* [ %29, %16 ], [ %11, %10 ]
%20 = phi i8* [ %23, %16 ], [ %7, %10 ]
%21 = icmp eq i8 %18, 92
%22 = getelementptr inbounds i8, i8* %20, i64 2
%23 = select i1 %21, i8* %22, i8* %19
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = tail call signext i8 @toupper(i32 %25)
%27 = add nuw i64 %17, 1
%28 = getelementptr inbounds [100 x i8], [100 x i8]* @find_validation_name.buf, i64 0, i64 %17
store i8 %26, i8* %28
%29 = getelementptr inbounds i8, i8* %23, i64 1
%30 = load i8, i8* %29
%31 = icmp slt i8 %30, 32
%32 = icmp eq i8 %30, 59
%33 = or i1 %31, %32
br i1 %33, label %34, label %16
34: ; preds = %16
%35 = and i64 %27, 4294967295
br label %36
36: ; preds = %34, %10
%37 = phi i64 [ 0, %10 ], [ %35, %34 ]
%38 = getelementptr inbounds [100 x i8], [100 x i8]* @find_validation_name.buf, i64 0, i64 %37
store i8 0, i8* %38
br label %49
39: ; preds = %4
switch i8 %5, label %43 [
i8 92, label %40
i8 59, label %42
]
40: ; preds = %39
%41 = getelementptr inbounds i8, i8* %7, i64 1
br label %43
42: ; preds = %39
br label %43
43: ; preds = %39, %9, %40, %42
%44 = phi i8* [ %41, %40 ], [ %7, %42 ], [ %7, %9 ], [ %7, %39 ]
%45 = phi i32 [ 0, %40 ], [ 1, %42 ], [ 0, %9 ], [ 0, %39 ]
%46 = getelementptr inbounds i8, i8* %44, i64 1
%47 = load i8, i8* %46
%48 = icmp sgt i8 %47, 31
br i1 %48, label %4, label %49
49: ; preds = %43, %1, %36
%50 = phi i8* [ getelementptr inbounds ([100 x i8], [100 x i8]* @find_validation_name.buf, i64 0, i64 0), %36 ], [ null, %1 ], [ null, %43 ]
ret i8* %50
}