#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*/ create_letter_distribution_diagram(int /*<<< orphan*/);
char getchar();
char *malloc(int);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ to_lower(char *);
int main() {
  unsigned int i = 0;
  char *sntc;
  sntc = malloc(sizeof(char));
  while ((sntc[i++] = getchar()) != '\n')
    sntc = (char *)realloc(sntc, sizeof(char) * (i + 1));
  sntc[i - 1] = '\0';
  create_letter_distribution_diagram(to_lower(sntc));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
mov    %edx,%edx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     11bb <main+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x0,%rax
mov    %eax,%esi
call   1070 <realloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1174 <main+0x24>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1030 <to_lower@plt>
mov    %eax,%edi
call   1040 <create_letter_distribution_diagram@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%r14)
cmp    $0xa,%al
je     11a4 <main+0x54>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%esi
lea    0x1(%rsi),%ebx
add    $0x2,%esi
mov    %r14,%rdi
call   1070 <realloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%r14,%rbx,1)
cmp    $0xa,%al
jne    1180 <main+0x30>
mov    %ebx,%ebx
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rdi
call   1030 <to_lower@plt>
mov    %eax,%edi
call   1040 <create_letter_distribution_diagram@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i8* @malloc(i32 1)
store i8* %4, i8** %3
br label %5
5: ; preds = %14, %0
%6 = call signext i8 (...) @getchar()
%7 = load i8*, i8** %3
%8 = load i32, i32* %2
%9 = add i32 %8, 1
store i32 %9, i32* %2
%10 = zext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
store i8 %6, i8* %11
%12 = sext i8 %6 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %23
14: ; preds = %5
%15 = load i8*, i8** %3
%16 = load i32, i32* %2
%17 = add i32 %16, 1
%18 = zext i32 %17 to i64
%19 = mul i64 1, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @realloc(i8* %15, i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %3
br label %5
23: ; preds = %5
%24 = load i8*, i8** %3
%25 = load i32, i32* %2
%26 = sub i32 %25, 1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 0, i8* %28
%29 = load i8*, i8** %3
%30 = call i32 @to_lower(i8* %29)
%31 = call i32 @create_letter_distribution_diagram(i32 %30)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%2 = tail call signext i8 (...) @getchar()
store i8 %2, i8* %1
%3 = icmp eq i8 %2, 10
br i1 %3, label %18, label %4
4: ; preds = %0, %4
%5 = phi i8* [ %10, %4 ], [ %1, %0 ]
%6 = phi i32 [ %7, %4 ], [ 0, %0 ]
%7 = add i32 %6, 1
%8 = add i32 %6, 2
%9 = tail call i64 @realloc(i8* %5, i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call signext i8 (...) @getchar()
%12 = zext i32 %7 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
store i8 %11, i8* %13
%14 = icmp eq i8 %11, 10
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = inttoptr i64 %9 to i8*
%17 = zext i32 %7 to i64
br label %18
18: ; preds = %15, %0
%19 = phi i64 [ 0, %0 ], [ %17, %15 ]
%20 = phi i8* [ %1, %0 ], [ %16, %15 ]
%21 = getelementptr inbounds i8, i8* %20, i64 %19
store i8 0, i8* %21
%22 = tail call i32 @to_lower(i8* %20)
%23 = tail call i32 @create_letter_distribution_diagram(i32 %22)
ret i32 0
}