#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 main() {
  int num;
  char i;
  char final;
  printf("Enter an abitrarily long string, ending with carriage return > ");
  scanf("%c", &i);
  num = i;
  while (i != '\n') {
    if (num != i && i != '\n') {
      num += i;
    }
    scanf("%c", &i);
  }
  final = num % 64;
  final += ' ';
  printf("Check sum is %c\n", final);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x9(%rbp),%eax
mov    %eax,-0x8(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     119c <main+0x7c>
mov    -0x8(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     1187 <main+0x67>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     1187 <main+0x67>
movsbl -0x9(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xeb2(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1154 <main+0x34>
mov    -0x8(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xa(%rbp)
movsbl -0xa(%rbp),%eax
add    $0x20,%eax
mov    %al,-0xa(%rbp)
movsbl -0xa(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%ebp
mov    $0x2a,%esi
cmp    $0xa,%ebp
je     11a4 <main+0x84>
lea    0xee1(%rip),%r14
lea    0x7(%rsp),%rbx
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%ecx
movsbl %al,%ebp
cmp    %ebp,%ecx
cmove  %r15d,%ebp
add    %ecx,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0xa,%al
jne    1170 <main+0x50>
lea    0x3f(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xffffffc0,%eax
neg    %eax
lea    (%rax,%rbp,1),%esi
add    $0x20,%esi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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"%c\00"
@.str.2 = [17 x i8] c"Check sum is %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
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 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
store i32 %8, i32* %2
br label %9
9: ; preds = %27, %0
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i32, i32* %2
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %14, %16
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = load i32, i32* %2
%26 = add nsw i32 %25, %24
store i32 %26, i32* %2
br label %27
27: ; preds = %22, %18, %13
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %9
29: ; preds = %9
%30 = load i32, i32* %2
%31 = srem i32 %30, 64
%32 = trunc i32 %31 to i8
store i8 %32, i8* %4
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = add nsw i32 %34, 32
%36 = trunc i32 %35 to i8
store i8 %36, i8* %4
%37 = load i8, i8* %4
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %38)
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"%c\00"
@.str.2 = [17 x i8] c"Check sum is %c\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 10
br i1 %5, label %21, label %6
6: ; preds = %0
%7 = sext i8 %4 to i32
br label %8
8: ; preds = %6, %8
%9 = phi i8 [ %16, %8 ], [ %4, %6 ]
%10 = phi i32 [ %14, %8 ], [ %7, %6 ]
%11 = sext i8 %9 to i32
%12 = icmp eq i32 %10, %11
%13 = select i1 %12, i32 0, i32 %11
%14 = add nsw i32 %13, %10
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%16 = load i8, i8* %1
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %8
18: ; preds = %8
%19 = srem i32 %14, 64
%20 = add nsw i32 %19, 32
br label %21
21: ; preds = %18, %0
%22 = phi i32 [ 42, %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
}