#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*/ copy_line(char *, char *);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int cur_length;
  int max_length;
  char cur_line[200];
  char max_line[200];
  max_length = 0;
  while ((cur_length = getline(cur_line, 200)) != 0) {
    if (cur_length > max_length) {
      copy_line(cur_line, max_line);
      max_length = cur_length;
    }
  }
  printf("Max line is:\n");
  printf("%s\n", max_line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0xe0(%rbp),%rdi
mov    $0xc8,%esi
call   1040 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1190 <main+0x60>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    118b <main+0x5b>
lea    -0xe0(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
call   1050 <copy_line@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <main+0x19>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1b0(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x198,%rsp
lea    0xd0(%rsp),%rdi
mov    $0xc8,%esi
call   1040 <getline@plt>
test   %eax,%eax
je     1196 <main+0x66>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0xd0(%rsp),%r15
mov    %rsp,%r14
jmp    1183 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0xc8,%esi
call   1040 <getline@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1196 <main+0x66>
cmp    %ebx,%ebp
jle    1170 <main+0x40>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <copy_line@plt>
mov    %ebp,%ebx
jmp    1170 <main+0x40>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Max line is:\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [200 x i8]
%5 = alloca [200 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %19, %0
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%8 = call i32 @getline(i8* %7, i32 200)
store i32 %8, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%17 = call i32 @copy_line(i8* %15, i8* %16)
%18 = load i32, i32* %2
store i32 %18, i32* %3
br label %19
19: ; preds = %14, %10
br label %6
20: ; preds = %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
ret i32 0
}

LLVM IR (-O2):
@str = [13 x i8] c"Max line is:\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 200)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %0, %13
%8 = phi i32 [ %15, %13 ], [ %5, %0 ]
%9 = phi i32 [ %14, %13 ], [ 0, %0 ]
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @copy_line(i8* %3, i8* %4)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %8, %11 ], [ %9, %7 ]
%15 = call i32 @getline(i8* %3, i32 200)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %13, %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%19 = call i32 @puts(i8* %4)
ret i32 0
}