#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 lower(char);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  char *Tests = "AaBbcCD3EdFGHgIJKLhM2NOjPQRkSTlUVWfXYf0Z1";
  char *p = Tests;
  int Result = 0;
  while ('\0' != *p) {
    Result = lower(*p);
    printf("[%c] gives [%c]\n", *p, Result);
    ++p;
  }
  Result = lower(0);
  printf("'\\0' gives %d\n", Result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1192 <main+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <lower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
mov    -0x1c(%rbp),%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1149 <main+0x29>
xor    %edi,%edi
call   1040 <lower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x41,%al
mov    $0x1,%ebx
lea    0xecd(%rip),%r15
lea    0xef0(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <lower@plt>
movsbl -0x1(%rbx,%r15,1),%esi
mov    %r14,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rbx,%r15,1),%eax
add    $0x1,%rbx
cmp    $0x2a,%rbx
jne    1140 <main+0x20>
xor    %edi,%edi
call   1040 <lower@plt>
lea    0xec4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"AaBbcCD3EdFGHgIJKLhM2NOjPQRkSTlUVWfXYf0Z1\00"
@.str.1 = [17 x i8] c"[%c] gives [%c]\0A\00"
@.str.2 = [15 x i8] c"'\\0' gives %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %11, %0
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 0, %9
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i32 @lower(i8 signext %13)
store i32 %14, i32* %4
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = load i32, i32* %4
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %6
22: ; preds = %6
%23 = call i32 @lower(i8 signext 0)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"AaBbcCD3EdFGHgIJKLhM2NOjPQRkSTlUVWfXYf0Z1\00"
@.str.1 = [17 x i8] c"[%c] gives [%c]\0A\00"
@.str.2 = [15 x i8] c"'\\0' gives %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i8 [ 65, %0 ], [ %9, %1 ]
%3 = phi i8* [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), %0 ], [ %8, %1 ]
%4 = tail call i32 @lower(i8 signext %2)
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %4)
%8 = getelementptr inbounds i8, i8* %3, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8* %8, getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 41)
br i1 %10, label %11, label %1
11: ; preds = %1
%12 = tail call i32 @lower(i8 signext 0)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %12)
ret i32 0
}