#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 strlen(char *);
char tolower(char);
int isNameValid(char nameHold[], char nameDone[]) {
  int i;
  if (strlen(nameHold) > (20 - 1)) {
    return 0;
  }
  for (i = 0; nameHold[i] != '\0'; i++) {
    nameDone[i] = tolower(nameHold[i]);
  }
  nameDone[i] = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<isNameValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x13,%eax
jle    114e <isNameValid+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <isNameValid+0x89>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1196 <isNameValid+0x76>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1155 <isNameValid+0x35>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isNameValid>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x13,%ecx
jg     117a <isNameValid+0x5a>
mov    (%r15),%al
test   %al,%al
je     116e <isNameValid+0x4e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,(%r14,%rbx,1)
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <isNameValid+0x30>
mov    %ebx,%eax
jmp    1170 <isNameValid+0x50>
xor    %eax,%eax
movb   $0x0,(%r14,%rax,1)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @isNameValid(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 19
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %39
11: ; preds = %2
store i32 0, i32* %6
br label %12
12: ; preds = %31, %11
%13 = load i8*, i8** %4
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = call signext i8 @tolower(i8 signext %25)
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 %26, i8* %30
br label %31
31: ; preds = %20
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %12
34: ; preds = %12
%35 = load i8*, i8** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 0, i8* %38
store i32 1, i32* %3
br label %39
39: ; preds = %34, %10
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @isNameValid(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 19
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %5, %8
%9 = phi i64 [ %13, %8 ], [ 0, %5 ]
%10 = phi i8 [ %15, %8 ], [ %6, %5 ]
%11 = tail call signext i8 @tolower(i8 signext %10)
%12 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 %11, i8* %12
%13 = add nuw i64 %9, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = and i64 %13, 4294967295
br label %19
19: ; preds = %17, %5
%20 = phi i64 [ 0, %5 ], [ %18, %17 ]
%21 = getelementptr inbounds i8, i8* %1, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %2, %19
%23 = phi i32 [ 1, %19 ], [ 0, %2 ]
ret i32 %23
}