#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 main(void) {
  char test[] = "SomeThinGs aRe writtEN wrONG";
  int i = 0;
  while (test[i]) {
    printf("%c", lower(test[i]));
    i++;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xebd(%rip),%al
mov    %al,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmpb   $0x0,-0x30(%rbp,%rax,1)
je     11a4 <main+0x84>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1040 <lower@plt>
mov    %eax,%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1169 <main+0x49>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0xed3(%rip),%r14
nopl   (%rax)
movsbl (%rbx,%r14,1),%edi
call   1040 <lower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x1c,%rbx
jne    1130 <main+0x10>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.test = [29 x i8] c"SomeThinGs aRe writtEN wrONG\00"
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [29 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [29 x i8]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %11, %0
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [29 x i8], [29 x i8]* %2, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %5
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [29 x i8], [29 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @lower(i8 signext %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.test = [29 x i8] c"SomeThinGs aRe writtEN wrONG\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %7, %1 ]
%3 = getelementptr inbounds [29 x i8], [29 x i8]* @__const.main.test, i64 0, i64 %2
%4 = load i8, i8* %3
%5 = tail call i32 @lower(i8 signext %4)
%6 = tail call i32 @putchar(i32 %5)
%7 = add nuw nsw i64 %2, 1
%8 = icmp eq i64 %7, 28
br i1 %8, label %9, label %1
9: ; preds = %1
%10 = tail call i32 @putchar(i32 10)
ret i32 0
}