#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 *, char *);
int /*<<< orphan*/ voltea();
int main(void) {
  int longitud;
  extern int max;
  extern char linea_max[1000];
  max = 0;
  while ((longitud = obtenlinea()) > 0) {
    max = longitud;
    copia();
    printf("Copia %s", linea_max);
    voltea();
    printf("Voltea %s", linea_max);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
movl   $0x0,(%rax)
mov    $0x0,%al
call   1030 <obtenlinea@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11b4 <main+0x74>
mov    -0x8(%rbp),%ecx
mov    0x2e5f(%rip),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1040 <copia@plt>
lea    0xe77(%rip),%rdi
mov    0x2e50(%rip),%rsi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <voltea@plt>
lea    0xe66(%rip),%rdi
mov    0x2e36(%rip),%rsi
call   1050 <printf@plt>
jmp    115c <main+0x1c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e89(%rip),%r12
movl   $0x0,(%r12)
xor    %eax,%eax
call   1030 <obtenlinea@plt>
test   %eax,%eax
jle    11b3 <main+0x73>
lea    0xe97(%rip),%r14
mov    0x2e70(%rip),%rbx
lea    0xe92(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %eax,(%r12)
xor    %eax,%eax
call   1040 <copia@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <voltea@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <obtenlinea@plt>
test   %eax,%eax
jg     1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@max = external global i32
@.str = [9 x i8] c"Copia %s\00"
@linea_max = external global [1000 x i8]
@.str.1 = [10 x i8] c"Voltea %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* @max
br label %3
3: ; preds = %6, %0
%4 = call i32 (...) @obtenlinea()
store i32 %4, i32* %2
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i32, i32* %2
store i32 %7, i32* @max
%8 = call i32 (...) @copia()
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @linea_max, i64 0, i64 0))
%10 = call i32 (...) @voltea()
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 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 %3
12: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@max = external global i32
@.str = [9 x i8] c"Copia %s\00"
@linea_max = external global [1000 x i8]
@.str.1 = [10 x i8] c"Voltea %s\00"
define i32 @main() {
store i32 0, i32* @max
%1 = tail call i32 (...) @obtenlinea()
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %11
3: ; preds = %0, %3
%4 = phi i32 [ %9, %3 ], [ %1, %0 ]
store i32 %4, i32* @max
%5 = tail call i32 (...) @copia()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @linea_max, i64 0, i64 0))
%7 = tail call i32 (...) @voltea()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @linea_max, i64 0, i64 0))
%9 = tail call i32 (...) @obtenlinea()
%10 = icmp sgt i32 %9, 0
br i1 %10, label %3, label %11
11: ; preds = %3, %0
ret i32 0
}