#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  int i = 0, l = 40;
  char c, s[55];
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while ((c = getc(fp)) != EOF) {
    if (c == '\n') {
      s[i] = '\0';
      puts(s);
      i = 0;
      l = 40;
    } else if (i == 55) {
      s[l] = '\0';
      printf("%s", s);
      puts("... <Read More>");
      i = 0;
      l = 40;
      while (c != '\n' && c != EOF)
        c = getc(fp);
    } else {
      if (i < 40 && c == ' ')
        l = i;
      s[i++] = c;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x28,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118d <main+0x4d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d0 <main+0x190>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe6b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2e22(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12c9 <main+0x189>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
jne    1203 <main+0xc3>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x28,-0x20(%rbp)
jmp    12c4 <main+0x184>
cmpl   $0x37,-0x1c(%rbp)
jne    128e <main+0x14e>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xdf3(%rip),%rdi
call   1040 <printf@plt>
lea    0xdea(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x28,-0x20(%rbp)
movsbl -0x21(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x61(%rbp)
je     1268 <main+0x128>
movsbl -0x21(%rbp),%eax
mov    0x2d8b(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    1278 <main+0x138>
jmp    1289 <main+0x149>
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x21(%rbp)
jmp    1240 <main+0x100>
jmp    12bf <main+0x17f>
cmpl   $0x28,-0x1c(%rbp)
jge    12ab <main+0x16b>
movsbl -0x21(%rbp),%eax
cmp    $0x20,%eax
jne    12ab <main+0x16b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x21(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
jmp    12c4 <main+0x184>
jmp    11b0 <main+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jne    124a <main+0x10a>
mov    0x8(%rsi),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <getc@plt>
mov    %eax,%ebx
mov    0x2e6d(%rip),%rbp
xor    %eax,%eax
cmp    0x0(%rbp),%bl
je     1262 <main+0x122>
xor    %r12d,%r12d
mov    $0x28,%r15d
mov    %rsp,%r14
jmp    11cb <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %r12d,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x28,%r15d
xor    %r12d,%r12d
mov    %r13,%rdi
call   1060 <getc@plt>
mov    %eax,%ebx
cmp    0x0(%rbp),%al
je     1260 <main+0x120>
cmp    $0xa,%bl
je     11a0 <main+0x60>
cmp    $0x37,%r12d
je     11f4 <main+0xb4>
cmp    $0x20,%bl
mov    %r15d,%eax
cmove  %r12d,%eax
cmp    $0x28,%r12d
cmovl  %eax,%r15d
movslq %r12d,%rax
add    $0x1,%r12d
mov    %bl,(%rsp,%rax,1)
jmp    11b8 <main+0x78>
movslq %r15d,%rax
movb   $0x0,(%rsp,%rax,1)
lea    0xe12(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
mov    $0x28,%r15d
xor    %r12d,%r12d
cmp    0x0(%rbp),%bl
je     11b8 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   1060 <getc@plt>
cmp    $0xa,%al
je     11b8 <main+0x78>
cmp    0x0(%rbp),%al
jne    1230 <main+0xf0>
jmp    11b8 <main+0x78>
mov    (%rsi),%rsi
lea    0xdac(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    1262 <main+0x122>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [16 x i8] c"... <Read More>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca [55 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 40, i32* %8
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %84
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
br label %23
23: ; preds = %82, %18
%24 = load i32*, i32** %6
%25 = call signext i8 @getc(i32* %24)
store i8 %25, i8* %9
%26 = sext i8 %25 to i32
%27 = load i8, i8* @EOF
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %26, %28
br i1 %29, label %30, label %83
30: ; preds = %23
%31 = load i8, i8* %9
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [55 x i8], [55 x i8]* %10, i64 0, i64 %36
store i8 0, i8* %37
%38 = getelementptr inbounds [55 x i8], [55 x i8]* %10, i64 0, i64 0
%39 = call i32 @puts(i8* %38)
store i32 0, i32* %7
store i32 40, i32* %8
br label %82
40: ; preds = %30
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 55
br i1 %42, label %43, label %66
43: ; preds = %40
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [55 x i8], [55 x i8]* %10, i64 0, i64 %45
store i8 0, i8* %46
%47 = getelementptr inbounds [55 x i8], [55 x i8]* %10, i64 0, i64 0
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
store i32 40, i32* %8
br label %50
50: ; preds = %62, %43
%51 = load i8, i8* %9
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 10
br i1 %53, label %54, label %60
54: ; preds = %50
%55 = load i8, i8* %9
%56 = sext i8 %55 to i32
%57 = load i8, i8* @EOF
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %56, %58
br label %60
60: ; preds = %54, %50
%61 = phi i1 [ false, %50 ], [ %59, %54 ]
br i1 %61, label %62, label %65
62: ; preds = %60
%63 = load i32*, i32** %6
%64 = call signext i8 @getc(i32* %63)
store i8 %64, i8* %9
br label %50
65: ; preds = %60
br label %81
66: ; preds = %40
%67 = load i32, i32* %7
%68 = icmp slt i32 %67, 40
br i1 %68, label %69, label %75
69: ; preds = %66
%70 = load i8, i8* %9
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 32
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = load i32, i32* %7
store i32 %74, i32* %8
br label %75
75: ; preds = %73, %69, %66
%76 = load i8, i8* %9
%77 = load i32, i32* %7
%78 = add nsw i32 %77, 1
store i32 %78, i32* %7
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds [55 x i8], [55 x i8]* %10, i64 0, i64 %79
store i8 %76, i8* %80
br label %81
81: ; preds = %75, %65
br label %82
82: ; preds = %81, %34
br label %23
83: ; preds = %23
store i32 0, i32* %3
br label %84
84: ; preds = %83, %13
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [16 x i8] c"... <Read More>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [55 x i8]
%4 = getelementptr inbounds [55 x i8], [55 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %54
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call signext i8 @getc(i32* %12)
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %13, %14
br i1 %15, label %54, label %16
16: ; preds = %9, %48
%17 = phi i8 [ %51, %48 ], [ %13, %9 ]
%18 = phi i32 [ %50, %48 ], [ 40, %9 ]
%19 = phi i32 [ %49, %48 ], [ 0, %9 ]
%20 = icmp eq i8 %17, 10
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = sext i32 %19 to i64
%23 = getelementptr inbounds [55 x i8], [55 x i8]* %3, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @puts(i8* %4)
br label %48
25: ; preds = %16
%26 = icmp eq i32 %19, 55
br i1 %26, label %27, label %40
27: ; preds = %25
%28 = sext i32 %18 to i64
%29 = getelementptr inbounds [55 x i8], [55 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%32 = load i8, i8* @EOF
%33 = icmp eq i8 %17, %32
br i1 %33, label %48, label %34
34: ; preds = %27, %34
%35 = call signext i8 @getc(i32* %12)
%36 = icmp ne i8 %35, 10
%37 = load i8, i8* @EOF
%38 = icmp ne i8 %35, %37
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %34, label %48
40: ; preds = %25
%41 = icmp slt i32 %19, 40
%42 = icmp eq i8 %17, 32
%43 = and i1 %41, %42
%44 = select i1 %43, i32 %19, i32 %18
%45 = add nsw i32 %19, 1
%46 = sext i32 %19 to i64
%47 = getelementptr inbounds [55 x i8], [55 x i8]* %3, i64 0, i64 %46
store i8 %17, i8* %47
br label %48
48: ; preds = %34, %27, %40, %21
%49 = phi i32 [ 0, %21 ], [ %45, %40 ], [ 0, %27 ], [ 0, %34 ]
%50 = phi i32 [ 40, %21 ], [ %44, %40 ], [ 40, %27 ], [ 40, %34 ]
%51 = call signext i8 @getc(i32* %12)
%52 = load i8, i8* @EOF
%53 = icmp eq i8 %51, %52
br i1 %53, label %54, label %16
54: ; preds = %48, %9, %6
%55 = phi i32 [ 1, %6 ], [ 0, %9 ], [ 0, %48 ]
ret i32 %55
}