#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 */
char EOF;
int /*<<< orphan*/ conversion(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scan_data(char *);
int /*<<< orphan*/ sum_data(char, int *);
int main() {
  int accumulator = 0;
  int remainder;
  char input;
  printf("Enter an abitrarily long string, ending with carriage return > ");
  while (1) {
    scan_data(&input);
    sum_data(input, &accumulator);
    if (input == '\n')
      break;
    if (input == EOF)
      return 0;
  }
  conversion(accumulator, &remainder);
  remainder = remainder + 22;
  input = (char)remainder;
  printf("Check sum is %c\n", input);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xd(%rbp),%rdi
call   1060 <scan_data@plt>
lea    -0x8(%rbp),%rsi
movsbl -0xd(%rbp),%edi
call   1030 <sum_data@plt>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
jne    118c <main+0x4c>
jmp    11b3 <main+0x73>
movsbl -0xd(%rbp),%eax
mov    0x2e51(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11ae <main+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <main+0xa7>
jmp    1164 <main+0x24>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1050 <conversion@plt>
mov    -0xc(%rbp),%eax
add    $0x16,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x7(%rsp),%r14
lea    0xc(%rsp),%rbx
mov    0x2e78(%rip),%r15
mov    %r14,%rdi
call   1060 <scan_data@plt>
movsbl 0x7(%rsp),%edi
mov    %rbx,%rsi
call   1030 <sum_data@plt>
movzbl 0x7(%rsp),%eax
cmp    $0xa,%al
je     1195 <main+0x55>
cmp    (%r15),%al
jne    1170 <main+0x30>
jmp    11c3 <main+0x83>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rsi
call   1050 <conversion@plt>
mov    0x8(%rsp),%eax
add    $0x16,%eax
mov    %eax,0x8(%rsp)
mov    %al,0x7(%rsp)
movsbl %al,%esi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%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"
@EOF = global i8 0
@.str.1 = [17 x i8] c"Check sum is %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %0, %21
%7 = call i32 @scan_data(i8* %4)
%8 = load i8, i8* %4
%9 = call i32 @sum_data(i8 signext %8, i32* %2)
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %14
13: ; preds = %6
br label %22
14: ; preds = %6
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %1
br label %32
21: ; preds = %14
br label %6
22: ; preds = %13
%23 = load i32, i32* %2
%24 = call i32 @conversion(i32 %23, i32* %3)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 22
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = trunc i32 %27 to i8
store i8 %28, i8* %4
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %30)
store i32 0, i32* %1
br label %32
32: ; preds = %22, %20
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [64 x i8] c"Enter an abitrarily long string, ending with carriage return > \00"
@EOF = global i8 0
@.str.1 = [17 x i8] c"Check sum is %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %13, %0
%8 = call i32 @scan_data(i8* %3)
%9 = load i8, i8* %3
%10 = call i32 @sum_data(i8 signext %9, i32* %1)
%11 = load i8, i8* %3
%12 = icmp eq i8 %11, 10
br i1 %12, label %16, label %13
13: ; preds = %7
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %11, %14
br i1 %15, label %25, label %7
16: ; preds = %7
%17 = load i32, i32* %1
%18 = call i32 @conversion(i32 %17, i32* %2)
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 22
store i32 %20, i32* %2
%21 = trunc i32 %20 to i8
store i8 %21, i8* %3
%22 = shl i32 %20, 24
%23 = ashr exact i32 %22, 24
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %13, %16
ret i32 0
}