#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*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ tolower(int);
char *strlwc(const char *s) {
  static char l[(1024) + 1];
  int i;
  memset(l, 0, (1024) + 1);
  i = 0;
  while (s[i] && i < (1024)) {
    l[i] = (char)tolower((int)s[i]);
    i++;
  }
  l[(1024)] = (char)0;
  return l;
}


x86 assembly (clang, -O0):
<strlwc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1030 <memset@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     116d <strlwc+0x4d>
cmpl   $0x400,-0xc(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    117d <strlwc+0x5d>
jmp    11ac <strlwc+0x8c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
movslq -0xc(%rbp),%rcx
lea    0x2ea5(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <strlwc+0x26>
movb   $0x0,0x328d(%rip)
lea    0x2e86(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlwc>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0x2f11(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1030 <memset@plt>
mov    (%r15),%al
test   %al,%al
je     1176 <strlwc+0x56>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,(%rbx,%r14,1)
movzbl 0x1(%r15,%rbx,1),%eax
test   %al,%al
je     1176 <strlwc+0x56>
lea    0x1(%rbx),%rcx
cmp    $0x3ff,%rbx
mov    %rcx,%rbx
jb     1150 <strlwc+0x30>
movb   $0x0,0x32c3(%rip)
lea    0x2ebc(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@strlwc.l = internal global [1025 x i8] zeroinitializer
define i8* @strlwc(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @memset(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 0), i32 0, i32 1025)
store i32 0, i32* %3
br label %5
5: ; preds = %18, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 1024
br label %16
16: ; preds = %13, %5
%17 = phi i1 [ false, %5 ], [ %15, %13 ]
br i1 %17, label %18, label %32
18: ; preds = %16
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i64 @tolower(i32 %24)
%26 = trunc i64 %25 to i8
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 %28
store i8 %26, i8* %29
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %5
32: ; preds = %16
store i8 0, i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 1024)
ret i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 0)
}

LLVM IR (-O2):
@strlwc.l = internal global [1025 x i8] zeroinitializer
define i8* @strlwc(i8* nocapture %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 0), i32 0, i32 1025)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %12, %5 ], [ 0, %1 ]
%7 = phi i8 [ %14, %5 ], [ %3, %1 ]
%8 = sext i8 %7 to i32
%9 = tail call i64 @tolower(i32 %8)
%10 = trunc i64 %9 to i8
%11 = getelementptr inbounds [1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 %6
store i8 %10, i8* %11
%12 = add nuw nsw i64 %6, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
%16 = icmp ult i64 %6, 1023
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %5, label %18
18: ; preds = %5, %1
store i8 0, i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 1024)
ret i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strlwc.l, i64 0, i64 0)
}