#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 *);
char tolower(char);
char *str_tolower(char *str) {
  int i;
  char newstr[100];
  strcpy(newstr, str);
  for (i = 0; newstr[i] != '\0'; i++) {
    newstr[i] = tolower(newstr[i]);
  }
  return newstr;
}


x86 assembly (clang, -O0):
<str_tolower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1178 <str_tolower+0x58>
movslq -0xc(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1040 <tolower@plt>
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <str_tolower+0x20>
lea    -0x70(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_tolower>:
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    (%rsp),%al
test   %al,%al
je     1156 <str_tolower+0x36>
lea    0x1(%rsp),%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <str_tolower+0x20>
mov    %rsp,%rax
add    $0x70,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @str_tolower(i8* %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %12, %7 ], [ 0, %1 ]
%9 = phi i8 [ %14, %7 ], [ %5, %1 ]
%10 = phi i8* [ %13, %7 ], [ %3, %1 ]
%11 = call signext i8 @tolower(i8 signext %9)
store i8 %11, i8* %10
%12 = add nuw i64 %8, 1
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7, %1
ret i8* %3
}