#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*/ strnullchecks(char *, char *, char *);
scalar_t__ tolower(int);
char *strlower(char *x) {
  char *result;
  result = x;
  strnullchecks(x, "x", "strlower");
  for (; *x; x++)
    *x = (char)tolower((int)*x);
  return result;
}


x86 assembly (clang, -O0):
<strlower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec1(%rip),%rsi
lea    0xebc(%rip),%rdx
call   1040 <strnullchecks@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     117d <strlower+0x5d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114b <strlower+0x2b>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlower>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xed2(%rip),%rsi
lea    0xecd(%rip),%rdx
call   1040 <strnullchecks@plt>
mov    (%r14),%al
test   %al,%al
je     1166 <strlower+0x46>
lea    0x1(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <strlower+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
@.str.1 = [9 x i8] c"strlower\00"
define i8* @strlower(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %2
%6 = call i32 @strnullchecks(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %18, %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i64 @tolower(i32 %14)
%16 = trunc i64 %15 to i8
%17 = load i8*, i8** %2
store i8 %16, i8* %17
br label %18
18: ; preds = %11
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
br label %7
21: ; preds = %7
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
@.str.1 = [9 x i8] c"strlower\00"
define i8* @strlower(i8* returned %0) {
%2 = tail call i32 @strnullchecks(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %12, %5 ], [ %3, %1 ]
%7 = phi i8* [ %11, %5 ], [ %0, %1 ]
%8 = sext i8 %6 to i32
%9 = tail call i64 @tolower(i32 %8)
%10 = trunc i64 %9 to i8
store i8 %10, i8* %7
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %1
ret i8* %0
}