#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*/ Menu();
int /*<<< orphan*/ MostrarFuncionamiento();
int /*<<< orphan*/ Preguntas(char *);
scalar_t__ amigoConectado(char *, char *);
int /*<<< orphan*/ cerrarSesion();
int /*<<< orphan*/ enviarMsj(char *);
int /*<<< orphan*/ exit(int);
char *ingresarMensaje();
int /*<<< orphan*/ iniciarServicio(char *);
int /*<<< orphan*/ mostrar(char *);
int /*<<< orphan*/ printf(char *);
char *recibirMsj();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *amigo;
  char *mensaje;
  char *puerto;
  if (argc < 3 || argc > 3) {
    printf(
        "Cantidad de parametros invalido, debe ingresar <IP AMIGO,PUERTO> -\n");
    exit(1);
  }
  amigo = argv[1];
  puerto = argv[2];
  MostrarFuncionamiento();
  if (amigoConectado(amigo, puerto)) {
    while (1) {
      Menu();
      mensaje = ingresarMensaje();
      if (strcmp(mensaje, "5\n") == 0) {
        enviarMsj(mensaje);
        break;
      }
      enviarMsj(mensaje);
      mensaje = recibirMsj();
      mostrar(mensaje);
      mensaje = recibirMsj();
      if (strcmp(mensaje, "5\n") == 0)
        break;
      Preguntas(mensaje);
      enviarMsj(mensaje);
    }
    cerrarSesion();
  } else {
    iniciarServicio(puerto);
    while (1) {
      mensaje = recibirMsj();
      if (strcmp(mensaje, "5\n") == 0)
        break;
      Preguntas(mensaje);
      enviarMsj(mensaje);
      Menu();
      mensaje = ingresarMensaje();
      if (strcmp(mensaje, "5\n") == 0) {
        enviarMsj(mensaje);
        break;
      }
      enviarMsj(mensaje);
      mensaje = recibirMsj();
      mostrar(mensaje);
    }
    cerrarSesion();
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11fa <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jle    1210 <main+0x40>
lea    0xdff(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   10a0 <MostrarFuncionamiento@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <amigoConectado@plt>
cmp    $0x0,%rax
je     12ef <main+0x11f>
jmp    124b <main+0x7b>
mov    $0x0,%al
call   1090 <Menu@plt>
mov    $0x0,%al
call   10b0 <ingresarMensaje@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1285 <main+0xb5>
mov    -0x20(%rbp),%rdi
call   1050 <enviarMsj@plt>
jmp    12e3 <main+0x113>
mov    -0x20(%rbp),%rdi
call   1050 <enviarMsj@plt>
mov    $0x0,%al
call   1060 <recibirMsj@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10e0 <mostrar@plt>
mov    $0x0,%al
call   1060 <recibirMsj@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12cc <main+0xfc>
jmp    12e3 <main+0x113>
mov    -0x20(%rbp),%rdi
call   10c0 <Preguntas@plt>
mov    -0x20(%rbp),%rdi
call   1050 <enviarMsj@plt>
jmp    124b <main+0x7b>
mov    $0x0,%al
call   1030 <cerrarSesion@plt>
jmp    1397 <main+0x1c7>
mov    -0x28(%rbp),%rdi
call   10f0 <iniciarServicio@plt>
mov    $0x0,%al
call   1060 <recibirMsj@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd36(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1322 <main+0x152>
jmp    1390 <main+0x1c0>
mov    -0x20(%rbp),%rdi
call   10c0 <Preguntas@plt>
mov    -0x20(%rbp),%rdi
call   1050 <enviarMsj@plt>
mov    $0x0,%al
call   1090 <Menu@plt>
mov    $0x0,%al
call   10b0 <ingresarMensaje@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xcf3(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    136e <main+0x19e>
mov    -0x20(%rbp),%rdi
call   1050 <enviarMsj@plt>
jmp    1390 <main+0x1c0>
mov    -0x20(%rbp),%rdi
call   1050 <enviarMsj@plt>
mov    $0x0,%al
call   1060 <recibirMsj@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10e0 <mostrar@plt>
jmp    12f8 <main+0x128>
mov    $0x0,%al
call   1030 <cerrarSesion@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    12ab <main+0xdb>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
xor    %eax,%eax
call   10a0 <MostrarFuncionamiento@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <amigoConectado@plt>
test   %rax,%rax
jne    12c1 <main+0xf1>
mov    %r14,%rdi
call   10f0 <iniciarServicio@plt>
xor    %eax,%eax
call   1070 <recibirMsj@plt>
mov    %rax,%rbx
lea    0xde7(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     135a <main+0x18a>
lea    0xdcf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10c0 <Preguntas@plt>
mov    %rbx,%rdi
call   1060 <enviarMsj@plt>
xor    %eax,%eax
call   1090 <Menu@plt>
xor    %eax,%eax
call   10b0 <ingresarMensaje@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1352 <main+0x182>
mov    %rbx,%rdi
call   1060 <enviarMsj@plt>
xor    %eax,%eax
call   1070 <recibirMsj@plt>
mov    %rax,%rdi
call   10e0 <mostrar@plt>
xor    %eax,%eax
call   1070 <recibirMsj@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1240 <main+0x70>
jmp    135a <main+0x18a>
lea    0xd51(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %eax,%eax
call   1090 <Menu@plt>
xor    %eax,%eax
call   10b0 <ingresarMensaje@plt>
mov    %rax,%rbx
lea    0xd27(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1352 <main+0x182>
lea    0xd13(%rip),%r14
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <enviarMsj@plt>
xor    %eax,%eax
call   1070 <recibirMsj@plt>
mov    %rax,%rdi
call   10e0 <mostrar@plt>
xor    %eax,%eax
call   1070 <recibirMsj@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     135a <main+0x18a>
mov    %rbx,%rdi
call   10c0 <Preguntas@plt>
mov    %rbx,%rdi
call   1060 <enviarMsj@plt>
xor    %eax,%eax
call   1090 <Menu@plt>
xor    %eax,%eax
call   10b0 <ingresarMensaje@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12f0 <main+0x120>
mov    %rbx,%rdi
call   1060 <enviarMsj@plt>
xor    %eax,%eax
call   1030 <cerrarSesion@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [68 x i8] c"Cantidad de parametros invalido, debe ingresar <IP AMIGO,PUERTO> -\0A\00"
@.str.1 = [3 x i8] c"5\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %11, %2
%15 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = call i32 (...) @MostrarFuncionamiento()
%25 = load i8*, i8** %6
%26 = load i8*, i8** %8
%27 = call i64 @amigoConectado(i8* %25, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %57
29: ; preds = %17
br label %30
30: ; preds = %29, %50
%31 = call i32 (...) @Menu()
%32 = call i8* (...) @ingresarMensaje()
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i8*, i8** %7
%38 = call i32 @enviarMsj(i8* %37)
br label %55
39: ; preds = %30
%40 = load i8*, i8** %7
%41 = call i32 @enviarMsj(i8* %40)
%42 = call i8* (...) @recibirMsj()
store i8* %42, i8** %7
%43 = load i8*, i8** %7
%44 = call i32 @mostrar(i8* %43)
%45 = call i8* (...) @recibirMsj()
store i8* %45, i8** %7
%46 = load i8*, i8** %7
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %39
br label %55
50: ; preds = %39
%51 = load i8*, i8** %7
%52 = call i32 @Preguntas(i8* %51)
%53 = load i8*, i8** %7
%54 = call i32 @enviarMsj(i8* %53)
br label %30
55: ; preds = %49, %36
%56 = call i32 (...) @cerrarSesion()
br label %87
57: ; preds = %17
%58 = load i8*, i8** %8
%59 = call i32 @iniciarServicio(i8* %58)
br label %60
60: ; preds = %57, %79
%61 = call i8* (...) @recibirMsj()
store i8* %61, i8** %7
%62 = load i8*, i8** %7
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %60
br label %85
66: ; preds = %60
%67 = load i8*, i8** %7
%68 = call i32 @Preguntas(i8* %67)
%69 = load i8*, i8** %7
%70 = call i32 @enviarMsj(i8* %69)
%71 = call i32 (...) @Menu()
%72 = call i8* (...) @ingresarMensaje()
store i8* %72, i8** %7
%73 = load i8*, i8** %7
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %66
%77 = load i8*, i8** %7
%78 = call i32 @enviarMsj(i8* %77)
br label %85
79: ; preds = %66
%80 = load i8*, i8** %7
%81 = call i32 @enviarMsj(i8* %80)
%82 = call i8* (...) @recibirMsj()
store i8* %82, i8** %7
%83 = load i8*, i8** %7
%84 = call i32 @mostrar(i8* %83)
br label %60
85: ; preds = %76, %65
%86 = call i32 (...) @cerrarSesion()
br label %87
87: ; preds = %85, %55
%88 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"5\0A\00"
@str = [67 x i8] c"Cantidad de parametros invalido, debe ingresar <IP AMIGO,PUERTO> -\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 (...) @MostrarFuncionamiento()
%13 = tail call i64 @amigoConectado(i8* %9, i8* %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %7
%16 = tail call i32 (...) @Menu()
%17 = tail call i8* (...) @ingresarMensaje()
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %55, label %20
20: ; preds = %15, %28
%21 = phi i8* [ %32, %28 ], [ %17, %15 ]
%22 = tail call i32 @enviarMsj(i8* %21)
%23 = tail call i8* (...) @recibirMsj()
%24 = tail call i32 @mostrar(i8* %23)
%25 = tail call i8* (...) @recibirMsj()
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %58, label %28
28: ; preds = %20
%29 = tail call i32 @Preguntas(i8* %25)
%30 = tail call i32 @enviarMsj(i8* %25)
%31 = tail call i32 (...) @Menu()
%32 = tail call i8* (...) @ingresarMensaje()
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %55, label %20
35: ; preds = %7
%36 = tail call i32 @iniciarServicio(i8* %11)
%37 = tail call i8* (...) @recibirMsj()
%38 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %58, label %40
40: ; preds = %35, %48
%41 = phi i8* [ %52, %48 ], [ %37, %35 ]
%42 = tail call i32 @Preguntas(i8* %41)
%43 = tail call i32 @enviarMsj(i8* %41)
%44 = tail call i32 (...) @Menu()
%45 = tail call i8* (...) @ingresarMensaje()
%46 = tail call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %55, label %48
48: ; preds = %40
%49 = tail call i32 @enviarMsj(i8* %45)
%50 = tail call i8* (...) @recibirMsj()
%51 = tail call i32 @mostrar(i8* %50)
%52 = tail call i8* (...) @recibirMsj()
%53 = tail call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %58, label %40
55: ; preds = %28, %40, %15
%56 = phi i8* [ %17, %15 ], [ %45, %40 ], [ %32, %28 ]
%57 = tail call i32 @enviarMsj(i8* %56)
br label %58
58: ; preds = %20, %48, %55, %35
%59 = tail call i32 (...) @cerrarSesion()
%60 = tail call i32 @exit(i32 0)
unreachable
}