#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*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char tolower(char);
char *tolostr(char *InputString) {
  register int i;
  int Length;
  static char OutputString[1024];
  strcpy(OutputString, InputString);
  Length = (int)strlen(OutputString);
  for (i = 0; i < Length; i++)
    OutputString[i] = tolower(OutputString[i]);
  return (OutputString);
}


x86 assembly (clang, -O0):
<tolostr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f09(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2efd(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a0 <tolostr+0x70>
movslq -0xc(%rbp),%rcx
lea    0x2ed7(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1050 <tolower@plt>
mov    %al,%dl
movslq -0xc(%rbp),%rcx
lea    0x2ec1(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <tolostr+0x32>
lea    0x2ea9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tolostr>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rsi
lea    0x2f11(%rip),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1177 <tolostr+0x47>
mov    %eax,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%r14,1),%edi
call   1050 <tolower@plt>
mov    %al,(%rbx,%r14,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <tolostr+0x30>
lea    0x2ed2(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@tolostr.OutputString = internal global [1024 x i8] zeroinitializer
define i8* @tolostr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 0), i8* %5)
%7 = call i64 @strlen(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 0))
%8 = trunc i64 %7 to i32
store i32 %8, i32* %4
store i32 0, i32* %3
br label %9
9: ; preds = %22, %1
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call signext i8 @tolower(i8 signext %17)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %13
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %9
25: ; preds = %9
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 0)
}

LLVM IR (-O2):
@tolostr.OutputString = internal global [1024 x i8] zeroinitializer
define i8* @tolostr(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 0), i8* %0)
%3 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 0))
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = and i64 %3, 4294967295
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %13, %8 ]
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = tail call signext i8 @tolower(i8 signext %11)
store i8 %12, i8* %10
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %7
br i1 %14, label %15, label %8
15: ; preds = %8, %1
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @tolostr.OutputString, i64 0, i64 0)
}