#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*/ 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;
  }
  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    1191 <main+0x51>
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    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf(%rsp),%r14
lea    0x14(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <scan_data@plt>
movsbl 0xf(%rsp),%edi
mov    %rbx,%rsi
call   1030 <sum_data@plt>
cmpb   $0xa,0xf(%rsp)
jne    1170 <main+0x30>
mov    0x14(%rsp),%edi
lea    0x10(%rsp),%rsi
call   1050 <conversion@plt>
mov    0x10(%rsp),%eax
add    $0x16,%eax
mov    %eax,0x10(%rsp)
mov    %al,0xf(%rsp)
movsbl %al,%esi
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Enter an abitrarily long string, ending with carriage return > \00"
@.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, %14
%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 %15
14: ; preds = %6
br label %6
15: ; preds = %13
%16 = load i32, i32* %2
%17 = call i32 @conversion(i32 %16, i32* %3)
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 22
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = trunc i32 %20 to i8
store i8 %21, i8* %4
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [64 x i8] c"Enter an abitrarily long string, ending with carriage return > \00"
@.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 = %7, %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 %13, label %7
13: ; preds = %7
%14 = load i32, i32* %1
%15 = call i32 @conversion(i32 %14, i32* %2)
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 22
store i32 %17, i32* %2
%18 = trunc i32 %17 to i8
store i8 %18, i8* %3
%19 = shl i32 %17, 24
%20 = ashr exact i32 %19, 24
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %20)
ret i32 0
}