#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 *);
scalar_t__ tolower(int);
char *wPopString();
int /*<<< orphan*/ wPushString(char *);
void wBasLCase() {
  int len, i;
  char *string;
  string = wPopString();
  len = strlen(string);
  for (i = 0; i < len; i++) {
    string[i] = (char)tolower((int)string[i]);
  }
  wPushString(string);
}


x86 assembly (clang, -O0):
<wBasLCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <wPopString@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119e <wBasLCase+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <tolower@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1166 <wBasLCase+0x26>
mov    -0x10(%rbp),%rdi
call   1060 <wPushString@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wBasLCase>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <wPopString@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1177 <wBasLCase+0x37>
mov    %eax,%r14d
xor    %ebx,%ebx
movsbl (%r15,%rbx,1),%edi
call   1050 <tolower@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <wBasLCase+0x20>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <wPushString@plt>

LLVM IR (-O0):
define void @wBasLCase() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = call i8* (...) @wPopString()
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %1
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i64 @tolower(i32 %17)
%19 = trunc i64 %18 to i8
%20 = load i8*, i8** %3
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %11
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %7
27: ; preds = %7
%28 = load i8*, i8** %3
%29 = call i32 @wPushString(i8* %28)
ret void
}

LLVM IR (-O2):
define void @wBasLCase() {
%1 = tail call i8* (...) @wPopString()
%2 = tail call i32 @strlen(i8* %1)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %0
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %13, %6 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = tail call i64 @tolower(i32 %10)
%12 = trunc i64 %11 to i8
store i8 %12, i8* %8
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %15, label %6
15: ; preds = %6, %0
%16 = tail call i32 @wPushString(i8* %1)
ret void
}