#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  char *sin_zero;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int main() {
  int clientSocket, port;
  char buffer[1024];
  struct sockaddr_in serverAddr;
  socklen_t addr_size;
  port = 4040;
  clientSocket = socket(AF_INET, SOCK_STREAM, 0);
  if (clientSocket < 0) {
    printf("Error abriendo el socket...\n");
    exit(1);
  }
  serverAddr.sin_port = htons(port);
  serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
  memset(serverAddr.sin_zero, '\0', sizeof serverAddr.sin_zero);
  addr_size = sizeof serverAddr;
  if (connect(clientSocket, (struct sockaddr *)&serverAddr, addr_size) < 0) {
    printf("Error no se encontro el servidor...\n");
    exit(1);
  }
  while (1) {
    printf("Ingrese sus datos:\n");
    printf("Recuerde que el formato es "
           "CustomerID|TransactionID|CardNumber|Value \n");
    memset(buffer, '\0', 1024);
    fgets(buffer, 1023, stdin);
    if (connect(clientSocket, (struct sockaddr *)&serverAddr, addr_size) < 0) {
      printf("Error no se encontro el servidor...\n");
      exit(1);
    }
    send(clientSocket, buffer, strlen(buffer), 0);
    recv(clientSocket, buffer, 1024, 0);
    if (buffer == "202") {
      printf("Datos Recibidos!\n");
    } else {
      printf("Los datos no cumplian los requisitos");
    }
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xfc8,-0xc(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1205 <main+0x55>
lea    0xe0a(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0xc(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x414(%rbp)
lea    0xe03(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x418(%rbp)
mov    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1080 <memset@plt>
movl   $0x10,-0x424(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   10c0 <connect@plt>
cmp    $0x0,%rax
jge    1277 <main+0xc7>
lea    0xdbf(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    127c <main+0xcc>
lea    0xdc9(%rip),%rdi
call   1070 <printf@plt>
lea    0xdd1(%rip),%rdi
call   1070 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    0x2d2b(%rip),%rax
mov    (%rax),%edx
mov    $0x3ff,%esi
call   1090 <fgets@plt>
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   10c0 <connect@plt>
cmp    $0x0,%rax
jge    12f6 <main+0x146>
lea    0xd40(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x434(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    -0x410(%rbp),%rax
lea    0xd54(%rip),%rcx
cmp    %rcx,%rax
jne    136d <main+0x1bd>
lea    0xd48(%rip),%rdi
call   1070 <printf@plt>
jmp    1379 <main+0x1c9>
lea    0xd49(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
test   %eax,%eax
js     12d3 <main+0x113>
mov    %eax,%ebx
mov    $0xfc8,%edi
call   1060 <htons@plt>
mov    %eax,0xc(%rsp)
lea    0xdfe(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,0x8(%rsp)
xor    %esi,%esi
mov    $0x8,%edx
call   1090 <memset@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10d0 <connect@plt>
test   %rax,%rax
js     12ca <main+0x10a>
lea    0xdf9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x3ff,%esi
call   10a0 <fgets@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10d0 <connect@plt>
test   %rax,%rax
js     12ca <main+0x10a>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xd52(%rip),%rdi
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdb7(%rip),%rdi
jmp    12da <main+0x11a>
lea    0xdd2(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [29 x i8] c"Error abriendo el socket...\0A\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [37 x i8] c"Error no se encontro el servidor...\0A\00"
@.str.3 = [20 x i8] c"Ingrese sus datos:\0A\00"
@.str.4 = [71 x i8] c"Recuerde que el formato es CustomerID|TransactionID|CardNumber|Value \0A\00"
@stdin = global i32 0
@.str.5 = [4 x i8] c"202\00"
@.str.6 = [18 x i8] c"Datos Recibidos!\0A\00"
@.str.7 = [37 x i8] c"Los datos no cumplian los requisitos\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
store i32 0, i32* %1
store i32 4040, i32* %3
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_STREAM
%9 = call i32 @socket(i32 %7, i32 %8, i32 0)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32, i32* %3
%17 = call i32 @htons(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %17, i32* %18
%19 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 @memset(i8* %23, i8 signext 0, i32 8)
store i32 16, i32* %6
%25 = load i32, i32* %2
%26 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%27 = load i32, i32* %6
%28 = call i64 @connect(i32 %25, %struct.sockaddr* %26, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %15
%31 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %15
br label %34
34: ; preds = %33
%35 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0))
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%38 = call i32 @memset(i8* %37, i8 signext 0, i32 1024)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%40 = load i32, i32* @stdin
%41 = call i32 @fgets(i8* %39, i32 1023, i32 %40)
%42 = load i32, i32* %2
%43 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%44 = load i32, i32* %6
%45 = call i64 @connect(i32 %42, %struct.sockaddr* %43, i32 %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %34
%48 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %34
%51 = load i32, i32* %2
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%54 = call i32 @strlen(i8* %53)
%55 = call i32 @send(i32 %51, i8* %52, i32 %54, i32 0)
%56 = load i32, i32* %2
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%58 = call i32 @recv(i32 %56, i8* %57, i32 1024, i32 0)
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%60 = icmp eq i8* %59, getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
br i1 %60, label %61, label %63
61: ; preds = %50
%62 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %65
63: ; preds = %50
%64 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [10 x i8] c"127.0.0.1\00"
@stdin = global i32 0
@.str.7 = [37 x i8] c"Los datos no cumplian los requisitos\00"
@str = [19 x i8] c"Ingrese sus datos:\00"
@str.8 = [70 x i8] c"Recuerde que el formato es CustomerID|TransactionID|CardNumber|Value \00"
@str.10 = [36 x i8] c"Error no se encontro el servidor...\00"
@str.11 = [28 x i8] c"Error abriendo el socket...\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca %struct.sockaddr_in
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = tail call i32 @htons(i32 4040)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %13, i32* %14
%15 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i32 %15, i32* %16
%17 = tail call i32 @memset(i8* undef, i8 signext 0, i32 8)
%18 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%19 = call i64 @connect(i32 %7, %struct.sockaddr* %18, i32 16)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.10, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %12
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.8, i64 0, i64 0))
%27 = call i32 @memset(i8* %3, i8 signext 0, i32 1024)
%28 = load i32, i32* @stdin
%29 = call i32 @fgets(i8* %3, i32 1023, i32 %28)
%30 = call i64 @connect(i32 %7, %struct.sockaddr* %18, i32 16)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.10, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %24
%36 = call i32 @strlen(i8* %3)
%37 = call i32 @send(i32 %7, i8* %3, i32 %36, i32 0)
%38 = call i32 @recv(i32 %7, i8* %3, i32 1024, i32 0)
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}