#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 */
unsigned short atoi(char *);
int /*<<< orphan*/ cerrarSocket_1();
int /*<<< orphan*/ cerrarSocket_2();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ init_1(unsigned short);
int /*<<< orphan*/ init_2(unsigned short);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char buffWrite[110];
  unsigned short port1, port2;
  if (argc != 3) {
    fprintf(stderr, "Uso: %s <Port1> <Port2>\n", argv[0]);
    exit(1);
  }
  port1 = atoi(argv[1]);
  port2 = atoi(argv[2]);
  init_1(port1);
  init_2(port2);
  while (1) {
    fflush(stdout);
    fgets(buffWrite, 110, stdin);
    buffWrite[strlen(buffWrite) - 1] = '\0';
    if (strcmp("FIN", buffWrite) == 0)
      break;
  }
  cerrarSocket_1();
  cerrarSocket_2();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11f9 <main+0x49>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe16(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %ax,-0x82(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %ax,-0x84(%rbp)
movzwl -0x82(%rbp),%edi
call   10c0 <init_1@plt>
movzwl -0x84(%rbp),%edi
call   1050 <init_2@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0x80(%rbp),%rdi
mov    0x2d96(%rip),%rax
mov    (%rax),%edx
mov    $0x6e,%esi
call   1060 <fgets@plt>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xd9d(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1290 <main+0xe0>
jmp    1295 <main+0xe5>
jmp    1239 <main+0x89>
mov    $0x0,%al
call   1040 <cerrarSocket_1@plt>
mov    $0x0,%al
call   10a0 <cerrarSocket_2@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1262 <main+0xb2>
mov    0x8(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebx
movzwl %bp,%edi
call   10c0 <init_1@plt>
movzwl %bx,%edi
call   1050 <init_2@plt>
mov    0x2ddd(%rip),%r15
mov    0x2dee(%rip),%rbp
mov    %rsp,%rbx
lea    0xe15(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
call   1090 <fflush@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x6e,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1210 <main+0x60>
xor    %eax,%eax
call   1040 <cerrarSocket_1@plt>
xor    %eax,%eax
call   10a0 <cerrarSocket_2@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd8b(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Uso: %s <Port1> <Port2>\0A\00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [4 x i8] c"FIN\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [110 x i8]
%7 = alloca i16
%8 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call zeroext i16 @atoi(i8* %21)
store i16 %22, i16* %7
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call zeroext i16 @atoi(i8* %25)
store i16 %26, i16* %8
%27 = load i16, i16* %7
%28 = call i32 @init_1(i16 zeroext %27)
%29 = load i16, i16* %8
%30 = call i32 @init_2(i16 zeroext %29)
br label %31
31: ; preds = %18, %46
%32 = load i32, i32* @stdout
%33 = call i32 @fflush(i32 %32)
%34 = getelementptr inbounds [110 x i8], [110 x i8]* %6, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %34, i32 110, i32 %35)
%37 = getelementptr inbounds [110 x i8], [110 x i8]* %6, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [110 x i8], [110 x i8]* %6, i64 0, i64 %40
store i8 0, i8* %41
%42 = getelementptr inbounds [110 x i8], [110 x i8]* %6, i64 0, i64 0
%43 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %31
br label %47
46: ; preds = %31
br label %31
47: ; preds = %45
%48 = call i32 (...) @cerrarSocket_1()
%49 = call i32 (...) @cerrarSocket_2()
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Uso: %s <Port1> <Port2>\0A\00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [4 x i8] c"FIN\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [110 x i8]
%4 = getelementptr inbounds [110 x i8], [110 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call zeroext i16 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call zeroext i16 @atoi(i8* %16)
%18 = tail call i32 @init_1(i16 zeroext %14)
%19 = tail call i32 @init_2(i16 zeroext %17)
br label %20
20: ; preds = %20, %11
%21 = load i32, i32* @stdout
%22 = call i32 @fflush(i32 %21)
%23 = load i32, i32* @stdin
%24 = call i32 @fgets(i8* %4, i32 110, i32 %23)
%25 = call i32 @strlen(i8* %4)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [110 x i8], [110 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %20
31: ; preds = %20
%32 = call i32 (...) @cerrarSocket_1()
%33 = call i32 (...) @cerrarSocket_2()
ret i32 0
}