#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char string[1000000];
  int count, i;
  printf("Enter an abitrarily long string, ending with carriage return > ");
  scanf("%s", string);
  count = 0;
  for (i = 0; i != strlen(string); ++i) {
    count += (int)string[i];
  }
  count = count % 64 + ' ';
  printf("Check sum is %c\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4260,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf4250(%rbp),%rsi
lea    0xee2(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0xf4254(%rbp)
movl   $0x0,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
mov    %eax,-0xf425c(%rbp)
lea    -0xf4250(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xf425c(%rbp),%eax
cmp    %ecx,%eax
je     11ce <main+0x9e>
movslq -0xf4258(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
add    -0xf4254(%rbp),%eax
mov    %eax,-0xf4254(%rbp)
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    1177 <main+0x47>
mov    -0xf4254(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
add    $0x20,%edx
mov    %edx,-0xf4254(%rbp)
mov    -0xf4254(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf4240,%rsp
lea    0xebd(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     11a3 <main+0x73>
mov    %rsp,%r14
xor    %ebx,%ebx
movsbl (%rsp,%rbx,1),%eax
add    %eax,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jne    1170 <main+0x40>
lea    0x3f(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
and    $0xffffffc0,%eax
neg    %eax
lea    (%r15,%rax,1),%esi
add    $0x20,%esi
jmp    11a8 <main+0x78>
mov    $0x20,%esi
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4240,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Enter an abitrarily long string, ending with carriage return > \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"Check sum is %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000000 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %4
%10 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %24
13: ; preds = %8
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %18
store i32 %20, i32* %3
br label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %8
24: ; preds = %8
%25 = load i32, i32* %3
%26 = srem i32 %25, 64
%27 = add nsw i32 %26, 32
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [64 x i8] c"Enter an abitrarily long string, ending with carriage return > \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"Check sum is %c\0A\00"
define i32 @main() {
%1 = alloca [1000000 x i8]
%2 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %14, %7 ], [ 0, %0 ]
%9 = phi i32 [ %13, %7 ], [ 0, %0 ]
%10 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %1, i64 0, i64 %8
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = add nsw i32 %9, %12
%14 = add nuw i64 %8, 1
%15 = call i32 @strlen(i8* %2)
%16 = zext i32 %15 to i64
%17 = icmp eq i64 %14, %16
br i1 %17, label %18, label %7
18: ; preds = %7
%19 = srem i32 %13, 64
%20 = add nsw i32 %19, 32
br label %21
21: ; preds = %18, %0
%22 = phi i32 [ 32, %0 ], [ %20, %18 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}