#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 read_line(char *, int);
int /*<<< orphan*/ swap(char **, char **);
int main() {
  char a[100 + 1], b[100 + 1];
  char *longest = a;
  char *current = b;
  int longest_len = 0;
  int current_len = 0;
  do {
    current_len = read_line(current, 100);
    if (current_len > longest_len) {
      swap(&current, &longest);
      longest_len = current_len;
    }
  } while (current_len > 0);
  printf("%s", longest);
  if (longest_len >= 100) {
    printf("...\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
mov    -0xf0(%rbp),%rdi
mov    $0x64,%esi
call   1040 <read_line@plt>
mov    %eax,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
cmp    -0xf4(%rbp),%eax
jle    11b7 <main+0x87>
lea    -0xf0(%rbp),%rdi
lea    -0xe8(%rbp),%rsi
call   1050 <swap@plt>
mov    -0xf8(%rbp),%eax
mov    %eax,-0xf4(%rbp)
jmp    11bc <main+0x8c>
cmpl   $0x0,-0xf8(%rbp)
jg     116f <main+0x3f>
mov    -0xe8(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x64,-0xf4(%rbp)
jl     11f9 <main+0xc9>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xe8,%rsp
lea    0x10(%rsp),%rdi
lea    0x80(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %rdi,(%rsp)
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x8(%rsp),%r15
nopl   (%rax)
mov    $0x64,%esi
call   1050 <read_line@plt>
mov    %eax,%ebp
cmp    %ebx,%eax
jle    118d <main+0x4d>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <swap@plt>
mov    %ebp,%ebx
test   %ebp,%ebp
jle    1197 <main+0x57>
mov    (%rsp),%rdi
jmp    1170 <main+0x30>
mov    0x8(%rsp),%rsi
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x64,%ebx
jl     11bb <main+0x7b>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [101 x i8]
%3 = alloca [101 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
store i8* %8, i8** %4
%9 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
store i8* %9, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %20, %0
%11 = load i8*, i8** %5
%12 = call i32 @read_line(i8* %11, i32 100)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = call i32 @swap(i8** %5, i8** %4)
%18 = load i32, i32* %7
store i32 %18, i32* %6
br label %19
19: ; preds = %16, %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %7
%22 = icmp sgt i32 %21, 0
br i1 %22, label %10, label %23
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %6
%27 = icmp sge i32 %26, 100
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %23
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@str = [4 x i8] c"...\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = alloca [101 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%7 = bitcast i8** %3 to i8*
store i8* %5, i8** %3
%8 = bitcast i8** %4 to i8*
store i8* %6, i8** %4
br label %9
9: ; preds = %19, %0
%10 = phi i8* [ %6, %0 ], [ %20, %19 ]
%11 = phi i32 [ 0, %0 ], [ %17, %19 ]
%12 = call i32 @read_line(i8* %10, i32 100)
%13 = icmp sgt i32 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @swap(i8** %4, i8** %3)
br label %16
16: ; preds = %9, %14
%17 = phi i32 [ %12, %14 ], [ %11, %9 ]
%18 = icmp sgt i32 %12, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i8*, i8** %4
br label %9
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = icmp sgt i32 %17, 99
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
ret i32 0
}