#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*/ die(char *);
int /*<<< orphan*/ exec_char(char);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ initialize();
int /*<<< orphan*/ *memchr(char *, char, int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int main() {
  int i;
  char tangle[10000];
  char line[10000];
  initialize();
  tangle[0] = '\0';
  line[0] = '\0';
  i = 0;
  while (memchr(line, '.', strlen(line)) == NULL) {
    fgets(line, 10000, stdin);
    if (strlen(tangle) + strlen(line) >= 10000) {
      die("input string too long - please end with a period.");
    }
    if (i++ == 1000) {
      die("too many lines - please end with a period.");
    }
    strcat(tangle, line);
  }
  for (i = 0; i < strlen(tangle); i++) {
    exec_char(tangle[i]);
  }
  die("somehow ran of the end of the input.");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initialize@plt>
movb   $0x0,-0x2720(%rbp)
movb   $0x0,-0x4e30(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x4e30(%rbp),%rax
mov    %rax,-0x4e38(%rbp)
lea    -0x4e30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4e38(%rbp),%rdi
mov    %eax,%edx
mov    $0x2e,%esi
call   1050 <memchr@plt>
cmp    $0x0,%rax
jne    1268 <main+0xf8>
lea    -0x4e30(%rbp),%rdi
mov    0x2e05(%rip),%rax
mov    (%rax),%edx
mov    $0x2710,%esi
call   1060 <fgets@plt>
lea    -0x2720(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4e3c(%rbp)
lea    -0x4e30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4e3c(%rbp),%eax
add    %ecx,%eax
cmp    $0x2710,%eax
jl     122e <main+0xbe>
lea    0xdd7(%rip),%rdi
call   1080 <die@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x3e8,%eax
jne    1250 <main+0xe0>
lea    0xde7(%rip),%rdi
call   1080 <die@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
call   1090 <strcat@plt>
jmp    119e <main+0x2e>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4e40(%rbp)
lea    -0x2720(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4e40(%rbp),%eax
cmp    %ecx,%eax
jge    12b3 <main+0x143>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%edi
ff
call   1070 <exec_char@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126f <main+0xff>
lea    0xda3(%rip),%rdi
call   1080 <die@plt>
mov    -0x4(%rbp),%eax
add    $0x4e40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e28,%rsp
xor    %eax,%eax
call   1040 <initialize@plt>
movb   $0x0,(%rsp)
movb   $0x0,0x2710(%rsp)
lea    0x2710(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
mov    %eax,%edx
call   1050 <memchr@plt>
test   %rax,%rax
je     120c <main+0x9c>
mov    %rsp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11ec <main+0x7c>
xor    %ebp,%ebp
mov    %rsp,%rbx
nopl   0x0(%rax)
movsbl (%rsp,%rbp,1),%edi
call   1070 <exec_char@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     11d0 <main+0x60>
lea    0xe6a(%rip),%rdi
call   1080 <die@plt>
xor    %eax,%eax
add    $0x4e28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3e8,%r13d
mov    0x2dcf(%rip),%r15
lea    0x2710(%rsp),%rbx
mov    %rsp,%r14
lea    0xe07(%rip),%r12
jmp    125b <main+0xeb>
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
mov    %eax,%edx
call   1050 <memchr@plt>
test   %rax,%rax
jne    11b8 <main+0x48>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x2710,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cmp    $0x2710,%eax
jl     1292 <main+0x122>
lea    0xd73(%rip),%rdi
call   1080 <die@plt>
sub    $0x1,%r13d
jae    1230 <main+0xc0>
mov    %r12,%rdi
call   1080 <die@plt>
jmp    1230 <main+0xc0>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [50 x i8] c"input string too long - please end with a period.\00"
@.str.1 = [43 x i8] c"too many lines - please end with a period.\00"
@.str.2 = [37 x i8] c"somehow ran of the end of the input.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
store i32 0, i32* %1
%5 = call i32 (...) @initialize()
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
store i8 0, i8* %6
%7 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
store i8 0, i8* %7
store i32 0, i32* %2
br label %8
8: ; preds = %32, %0
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = call i32* @memchr(i8* %9, i8 signext 46, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %36
14: ; preds = %8
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 10000, i32 %16)
%18 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %19, %21
%23 = icmp sge i32 %22, 10000
br i1 %23, label %24, label %26
24: ; preds = %14
%25 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %14
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
%29 = icmp eq i32 %27, 1000
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
%33 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%34 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%35 = call i32 @strcat(i8* %33, i8* %34)
br label %8
36: ; preds = %8
store i32 0, i32* %2
br label %37
37: ; preds = %48, %36
%38 = load i32, i32* %2
%39 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = call i32 @exec_char(i8 signext %46)
br label %48
48: ; preds = %42
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %37
51: ; preds = %37
%52 = call i32 @die(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [50 x i8] c"input string too long - please end with a period.\00"
@.str.1 = [43 x i8] c"too many lines - please end with a period.\00"
@.str.2 = [37 x i8] c"somehow ran of the end of the input.\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = alloca [10000 x i8]
%3 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @initialize()
store i8 0, i8* %3
store i8 0, i8* %4
%6 = call i32 @strlen(i8* %4)
%7 = call i32* @memchr(i8* %4, i8 signext 46, i32 %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %27, %0
%10 = call i32 @strlen(i8* %3)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %32, label %41
12: ; preds = %0, %27
%13 = phi i32 [ %23, %27 ], [ 0, %0 ]
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %4, i32 10000, i32 %14)
%16 = call i32 @strlen(i8* %3)
%17 = call i32 @strlen(i8* %4)
%18 = add nsw i32 %17, %16
%19 = icmp sgt i32 %18, 9999
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %12
%23 = add nuw nsw i32 %13, 1
%24 = icmp eq i32 %13, 1000
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = call i32 @strcat(i8* %3, i8* %4)
%29 = call i32 @strlen(i8* %4)
%30 = call i32* @memchr(i8* %4, i8 signext 46, i32 %29)
%31 = icmp eq i32* %30, null
br i1 %31, label %12, label %9
32: ; preds = %9, %32
%33 = phi i64 [ %37, %32 ], [ 0, %9 ]
%34 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @exec_char(i8 signext %35)
%37 = add nuw nsw i64 %33, 1
%38 = call i32 @strlen(i8* %3)
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %37, %39
br i1 %40, label %32, label %41
41: ; preds = %32, %9
%42 = call i32 @die(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}