#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*/ copia();
int obtenlinea();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int longitud;
  extern int max;
  extern char linea_max[1000];
  max = 0;
  printf(" --- Ejercio 2.d modificando el codigo de  2.a---- ");
  while ((longitud = obtenlinea()) > 0)
    if (longitud > 80) {
      copia();
      printf("%s", linea_max);
    }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
movl   $0x0,(%rax)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <obtenlinea@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1198 <main+0x68>
cmpl   $0x50,-0x8(%rbp)
jle    1193 <main+0x63>
mov    $0x0,%al
call   1040 <copia@plt>
lea    0xeaf(%rip),%rdi
mov    0x2e54(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    115a <main+0x2a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e9d(%rip),%rax
movl   $0x0,(%rax)
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <obtenlinea@plt>
test   %eax,%eax
jle    1196 <main+0x66>
lea    0xed3(%rip),%r14
mov    0x2e78(%rip),%rbx
jmp    117b <main+0x4b>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <obtenlinea@plt>
test   %eax,%eax
jle    1196 <main+0x66>
cmp    $0x51,%eax
jb     1170 <main+0x40>
xor    %eax,%eax
call   1040 <copia@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@max = external global i32
@.str = [52 x i8] c" --- Ejercio 2.d modificando el codigo de 2.a---- \00"
@.str.1 = [3 x i8] c"%s\00"
@linea_max = external global [1000 x i8]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* @max
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %13, %0
%5 = call i32 (...) @obtenlinea()
store i32 %5, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 80
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32 (...) @copia()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @linea_max, i64 0, i64 0))
br label %13
13: ; preds = %10, %7
br label %4
14: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@max = external global i32
@.str = [52 x i8] c" --- Ejercio 2.d modificando el codigo de 2.a---- \00"
@.str.1 = [3 x i8] c"%s\00"
@linea_max = external global [1000 x i8]
define i32 @main() {
store i32 0, i32* @max
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @obtenlinea()
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %0, %10
%5 = phi i32 [ %11, %10 ], [ %2, %0 ]
%6 = icmp ugt i32 %5, 80
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32 (...) @copia()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @linea_max, i64 0, i64 0))
br label %10
10: ; preds = %7, %4
%11 = tail call i32 (...) @obtenlinea()
%12 = icmp sgt i32 %11, 0
br i1 %12, label %4, label %13
13: ; preds = %10, %0
ret i32 0
}