#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(void) {
  int remainder, intsum = 0, i;
  char userinput[2000];
  printf("Enter an abitrarily long string, ending with carriage return > ");
  scanf("%s", &userinput);
  for (i = 0; userinput[i] != 0; i++) {
    intsum = intsum + userinput[i];
  }
  remainder = intsum % 64;
  remainder = remainder + 32;
  printf("Check sum is %c\n", remainder);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xeeb(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
movsbl -0x7e0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1198 <main+0x78>
mov    -0xc(%rbp),%eax
movslq -0x10(%rbp),%rcx
movsbl -0x7e0(%rbp,%rcx,1),%ecx
ff
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1161 <main+0x41>
mov    -0xc(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x7d0,%rsp
lea    0xed1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     1185 <main+0x65>
lea    0x1(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%eax
add    %eax,%ebx
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    1160 <main+0x40>
lea    0x3f(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xffffffc0,%eax
neg    %eax
lea    (%rbx,%rax,1),%esi
add    $0x20,%esi
jmp    118a <main+0x6a>
mov    $0x20,%esi
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7d0,%rsp
pop    %rbx
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 i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2000 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [2000 x i8]* %5 to i8**
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7)
store i32 0, i32* %4
br label %9
9: ; preds = %24, %0
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %9
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = add nsw i32 %17, %22
store i32 %23, i32* %3
br label %24
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %9
27: ; preds = %9
%28 = load i32, i32* %3
%29 = srem i32 %28, 64
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 32
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %32)
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 [2000 x i8]
%2 = getelementptr inbounds [2000 x i8], [2000 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 = bitcast [2000 x i8]* %1 to i8**
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %14, %8 ], [ 0, %0 ]
%10 = phi i8 [ %16, %8 ], [ %6, %0 ]
%11 = phi i32 [ %13, %8 ], [ 0, %0 ]
%12 = sext i8 %10 to i32
%13 = add nsw i32 %11, %12
%14 = add nuw nsw i64 %9, 1
%15 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %8
18: ; preds = %8
%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
}