#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 */
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, char);
int tolower(char);
int to_lower(char *line) {
  while (*line) {
    if (isupper(*line))
      printf("%c", tolower(*line));
    else
      printf("%c", *line);
    line++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<to_lower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a3 <to_lower+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     117f <to_lower+0x4f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
lea    0xe8e(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
jmp    1192 <to_lower+0x62>
mov    -0x8(%rbp),%rax
lea    0xe76(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113c <to_lower+0xc>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_lower>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1184 <to_lower+0x54>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xeb8(%rip),%r14
jmp    1166 <to_lower+0x36>
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1184 <to_lower+0x54>
movsbl %al,%edi
call   1050 <isupper@plt>
mov    %rax,%rcx
movzbl -0x1(%rbx),%eax
test   %rcx,%rcx
je     1150 <to_lower+0x20>
movsbl %al,%edi
call   1040 <tolower@plt>
jmp    1150 <to_lower+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @to_lower(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %17, %13 ], [ %2, %1 ]
%6 = phi i8* [ %16, %13 ], [ %0, %1 ]
%7 = tail call i64 @isupper(i8 signext %5)
%8 = icmp eq i64 %7, 0
%9 = load i8, i8* %6
br i1 %8, label %13, label %10
10: ; preds = %4
%11 = tail call i32 @tolower(i8 signext %9)
%12 = trunc i32 %11 to i8
br label %13
13: ; preds = %4, %10
%14 = phi i8 [ %12, %10 ], [ %9, %4 ]
%15 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %14)
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %4
19: ; preds = %13, %1
ret i32 0
}