#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(char *, char *);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int maxline;
  int len;
  int max;
  printf("Cuantos caracteres desea ingresar como maximo?");
  scanf("%d", &maxline);
  char line[maxline];
  char longest[maxline];
  max = 0;
  while ((len = getline(line, maxline)) > 0) {
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0)
    printf("Linea mas larga: %sString de %d caracteres", longest, max + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <getline@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    11f5 <main+0xb5>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11f0 <main+0xb0>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
call   1040 <copy@plt>
jmp    11b9 <main+0x79>
cmpl   $0x0,-0x10(%rbp)
jle    1217 <main+0xd7>
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeab(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,%r13
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%esi
mov    %rsp,%r15
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r12,%rdi
call   1060 <getline@plt>
test   %eax,%eax
jle    11f3 <main+0xb3>
mov    %eax,%ebx
jmp    11c1 <main+0x81>
nopl   (%rax)
mov    -0x2c(%rbp),%esi
mov    %r12,%rdi
call   1060 <getline@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11d6 <main+0x96>
cmp    %r14d,%ebx
jle    11b0 <main+0x70>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <copy@plt>
mov    %ebx,%r14d
jmp    11b0 <main+0x70>
test   %r14d,%r14d
jle    11f3 <main+0xb3>
add    $0x1,%r14d
lea    0xe4c(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Cuantos caracteres desea ingresar como maximo?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Linea mas larga: %sString de %d caracteres\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca i8, i64 %11
store i64 %11, i64* %6
%14 = load i32, i32* %2
%15 = zext i32 %14 to i64
%16 = alloca i8, i64 %15
store i64 %15, i64* %7
store i32 0, i32* %4
br label %17
17: ; preds = %28, %0
%18 = load i32, i32* %2
%19 = call i32 @getline(i8* %13, i32 %18)
store i32 %19, i32* %3
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %3
store i32 %26, i32* %4
%27 = call i32 @copy(i8* %16, i8* %13)
br label %28
28: ; preds = %25, %21
br label %17
29: ; preds = %17
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %34)
br label %36
36: ; preds = %32, %29
store i32 0, i32* %1
%37 = load i8*, i8** %5
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [47 x i8] c"Cuantos caracteres desea ingresar como maximo?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Linea mas larga: %sString de %d caracteres\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = load i32, i32* %1
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = call i32 @getline(i8* %8, i32 %9)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %0, %20
%15 = phi i32 [ %23, %20 ], [ %12, %0 ]
%16 = phi i32 [ %21, %20 ], [ 0, %0 ]
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @copy(i8* %11, i8* %8)
br label %20
20: ; preds = %18, %14
%21 = phi i32 [ %15, %18 ], [ %16, %14 ]
%22 = load i32, i32* %1
%23 = call i32 @getline(i8* %8, i32 %22)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %14, label %25
25: ; preds = %20
%26 = icmp sgt i32 %21, 0
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = add nuw nsw i32 %21, 1
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %11, i32 %28)
br label %30
30: ; preds = %0, %27, %25
ret i32 0
}