#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 */
typedef int /*<<< orphan*/ value;
typedef int /*<<< orphan*/ time_str;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ s_value;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ SO_SNDTIMEO;
int /*<<< orphan*/ bcopy(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int ntohl(int);
scalar_t__ recv(int, int *, int, int /*<<< orphan*/);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              struct timeval *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char const *, char *);
int main(int argc, char const *argv[]) {
  struct hostent *hp;
  struct sockaddr_in sin;
  char *host = "127.0.0.1";
  int32_t value;
  char s_value[4], c;
  int s;
  if (argc < 2) {
    fprintf(stderr, "Falta argumento de entrada\n");
    exit(1);
  }
  if (strcmp(argv[1], "inc") == 0)
    c = '+';
  else if (strcmp(argv[1], "dec") == 0)
    c = '-';
  else {
    fprintf(stderr, "Erro de entrada: %s\n", argv[1]);
    exit(1);
  }
  hp = gethostbyname(host);
  if (!hp) {
    fprintf(stderr, "Host desconhecido: %s\n", host);
    exit(1);
  }
  bzero((char *)&sin, sizeof(sin));
  sin.sin_family = AF_INET;
  bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
  sin.sin_port = htons(51515);
  s = socket(PF_INET, SOCK_STREAM, 0);
  if (s < 0) {
    fprintf(stderr, "Erro ao criar socket.\n");
    exit(1);
  }
  struct timeval time_str;
  time_str.tv_sec = 2;
  time_str.tv_usec = 0;
  setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &time_str, sizeof(time_str));
  setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &time_str, sizeof(time_str));
  if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
    fprintf(stderr, "Erro ao conectar ao socket.\n");
    close(s);
    exit(1);
  }
  if (send(s, &c, 1, 0) < 0) {
    fprintf(stderr, "Erro de envio 1 %c\n", c);
    close(s);
    exit(1);
  }
  if (recv(s, &value, sizeof(value), 0) < 0) {
    fprintf(stderr, "Erro de recebimento %d\n", value);
    close(s);
    exit(1);
  }
  value = ntohl(value);
  fprintf(stdout, "%d\n", value);
  sprintf(s_value, "%03d", value);
  if (send(s, s_value, sizeof(s_value), 0) < 0) {
    fprintf(stderr, "erro de envio 2 %s\n", s_value);
    close(s);
    exit(1);
  }
  close(s);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdf3(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    123c <main+0x4c>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xddb(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1263 <main+0x73>
movb   $0x2b,-0x39(%rbp)
jmp    12b8 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb8(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    128a <main+0x9a>
movb   $0x2d,-0x39(%rbp)
jmp    12b3 <main+0xc3>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    12b8 <main+0xc8>
mov    -0x30(%rbp),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12f5 <main+0x105>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   10b0 <bcopy@plt>
mov    $0xc93b,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
mov    0x2c72(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    137d <main+0x18d>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
movl   $0x2,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2c4a(%rip),%rax
mov    (%rax),%esi
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rcx
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
mov    -0x40(%rbp),%edi
mov    0x2c26(%rip),%rax
mov    (%rax),%esi
mov    0x2c2d(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rcx
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
mov    -0x40(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    1418 <main+0x228>
mov    0x2bca(%rip),%rax
mov    (%rax),%edi
lea    0xc72(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x40(%rbp),%edi
lea    -0x39(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    1462 <main+0x272>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
movsbl -0x39(%rbp),%edx
lea    0xc45(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x40(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jge    14ab <main+0x2bb>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x34(%rbp),%edi
call   1100 <ntohl@plt>
mov    %eax,-0x34(%rbp)
mov    0x2aeb(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xbed(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    -0x38(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xbdc(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x40(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    152d <main+0x33d>
mov    0x2ab9(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rdx
lea    0xbab(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
cmp    $0x1,%edi
jg     121f <main+0x2f>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xdf9(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x2b,%cl
test   %rax,%rax
je     1254 <main+0x64>
mov    0x8(%rbx),%rdi
lea    0xde6(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x2d,%cl
test   %rax,%rax
jne    12f3 <main+0x103>
mov    %cl,0x7(%rsp)
lea    0xda1(%rip),%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
jne    1285 <main+0x95>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
lea    0xd80(%rip),%rdx
jmp    1307 <main+0x117>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    (%rbx),%edx
mov    0x4(%rbx),%edi
lea    0x14(%rsp),%rsi
call   10b0 <bcopy@plt>
mov    $0xc93b,%edi
call   1050 <htons@plt>
mov    %eax,0x10(%rsp)
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
mov    0x2ce7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
test   %eax,%eax
jns    1318 <main+0x128>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd6c(%rip),%rsi
jmp    120e <main+0x1e>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd27(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %eax,%ebx
movl   $0x2,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    0x2cae(%rip),%r15
mov    (%r15),%esi
mov    0x2c8c(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rcx
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
mov    (%r15),%esi
mov    0x2c93(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r14,%rcx
mov    $0x10,%r8d
call   1040 <setsockopt@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %rax,%rax
jns    139e <main+0x1ae>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xcdc(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1400 <main+0x210>
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
test   %rax,%rax
jns    13cd <main+0x1dd>
mov    0x2c03(%rip),%rax
mov    (%rax),%edi
movsbl 0x7(%rsp),%edx
lea    0xcc3(%rip),%rsi
jmp    13f9 <main+0x209>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jns    1411 <main+0x221>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%edx
lea    0xca9(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x8(%rsp),%edi
call   1100 <ntohl@plt>
mov    %eax,0x8(%rsp)
mov    0x2b83(%rip),%rcx
mov    (%rcx),%edi
lea    0xc88(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x8(%rsp),%edx
lea    0xc78(%rip),%rsi
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   10d0 <sprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
test   %rax,%rax
jns    1486 <main+0x296>
mov    0x2b54(%rip),%rax
mov    (%rax),%edi
lea    0xc4a(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1400 <main+0x210>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i32, i32 }
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Falta argumento de entrada\0A\00"
@.str.2 = [4 x i8] c"inc\00"
@.str.3 = [4 x i8] c"dec\00"
@.str.4 = [21 x i8] c"Erro de entrada: %s\0A\00"
@.str.5 = [23 x i8] c"Host desconhecido: %s\0A\00"
@AF_INET = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.6 = [23 x i8] c"Erro ao criar socket.\0A\00"
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.7 = [29 x i8] c"Erro ao conectar ao socket.\0A\00"
@.str.8 = [20 x i8] c"Erro de envio 1 %c\0A\00"
@.str.9 = [24 x i8] c"Erro de recebimento %d\0A\00"
@stdout = global i32 0
@.str.10 = [4 x i8] c"%d\0A\00"
@.str.11 = [5 x i8] c"%03d\00"
@.str.12 = [20 x i8] c"erro de envio 2 %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.hostent*
%7 = alloca %struct.sockaddr_in
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [4 x i8]
%11 = alloca i8
%12 = alloca i32
%13 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %8
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i8 43, i8* %11
br label %42
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i8 45, i8* %11
br label %41
34: ; preds = %27
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %33
br label %42
42: ; preds = %41, %26
%43 = load i8*, i8** %8
%44 = call %struct.hostent* @gethostbyname(i8* %43)
store %struct.hostent* %44, %struct.hostent** %6
%45 = load %struct.hostent*, %struct.hostent** %6
%46 = icmp ne %struct.hostent* %45, null
br i1 %46, label %52, label %47
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %8
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %42
%53 = bitcast %struct.sockaddr_in* %7 to i8*
%54 = call i32 @bzero(i8* %53, i32 12)
%55 = load i32, i32* @AF_INET
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %55, i32* %56
%57 = load %struct.hostent*, %struct.hostent** %6
%58 = getelementptr inbounds %struct.hostent, %struct.hostent* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%61 = bitcast i32* %60 to i8*
%62 = load %struct.hostent*, %struct.hostent** %6
%63 = getelementptr inbounds %struct.hostent, %struct.hostent* %62, i32 0, i32 0
%64 = load i32, i32* %63
%65 = call i32 @bcopy(i32 %59, i8* %61, i32 %64)
%66 = call i32 @htons(i32 51515)
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %66, i32* %67
%68 = load i32, i32* @PF_INET
%69 = load i32, i32* @SOCK_STREAM
%70 = call i32 @socket(i32 %68, i32 %69, i32 0)
store i32 %70, i32* %12
%71 = load i32, i32* %12
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %52
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %52
%78 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 2, i32* %78
%79 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store i64 0, i64* %79
%80 = load i32, i32* %12
%81 = load i32, i32* @SOL_SOCKET
%82 = load i32, i32* @SO_RCVTIMEO
%83 = call i32 @setsockopt(i32 %80, i32 %81, i32 %82, %struct.timeval* %13, i32 16)
%84 = load i32, i32* %12
%85 = load i32, i32* @SOL_SOCKET
%86 = load i32, i32* @SO_SNDTIMEO
%87 = call i32 @setsockopt(i32 %84, i32 %85, i32 %86, %struct.timeval* %13, i32 16)
%88 = load i32, i32* %12
%89 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%90 = call i64 @connect(i32 %88, %struct.sockaddr* %89, i32 12)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %77
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%95 = load i32, i32* %12
%96 = call i32 @close(i32 %95)
%97 = call i32 @exit(i32 1)
unreachable
98: ; preds = %77
%99 = load i32, i32* %12
%100 = call i64 @send(i32 %99, i8* %11, i32 1, i32 0)
%101 = icmp slt i64 %100, 0
br i1 %101, label %102, label %110
102: ; preds = %98
%103 = load i32, i32* @stderr
%104 = load i8, i8* %11
%105 = sext i8 %104 to i32
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %105)
%107 = load i32, i32* %12
%108 = call i32 @close(i32 %107)
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %98
%111 = load i32, i32* %12
%112 = call i64 @recv(i32 %111, i32* %9, i32 4, i32 0)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %121
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = load i32, i32* %9
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %116)
%118 = load i32, i32* %12
%119 = call i32 @close(i32 %118)
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %110
%122 = load i32, i32* %9
%123 = call i32 @ntohl(i32 %122)
store i32 %123, i32* %9
%124 = load i32, i32* @stdout
%125 = load i32, i32* %9
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %125)
%127 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%128 = load i32, i32* %9
%129 = call i32 @sprintf(i8* %127, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 %128)
%130 = load i32, i32* %12
%131 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%132 = call i64 @send(i32 %130, i8* %131, i32 4, i32 0)
%133 = icmp slt i64 %132, 0
br i1 %133, label %134, label %141
134: ; preds = %121
%135 = load i32, i32* @stderr
%136 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %136)
%138 = load i32, i32* %12
%139 = call i32 @close(i32 %138)
%140 = call i32 @exit(i32 1)
unreachable
141: ; preds = %121
%142 = load i32, i32* %12
%143 = call i32 @close(i32 %142)
%144 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i32, i64 }
%struct.hostent = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Falta argumento de entrada\0A\00"
@.str.2 = [4 x i8] c"inc\00"
@.str.3 = [4 x i8] c"dec\00"
@.str.4 = [21 x i8] c"Erro de entrada: %s\0A\00"
@.str.5 = [23 x i8] c"Host desconhecido: %s\0A\00"
@AF_INET = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.6 = [23 x i8] c"Erro ao criar socket.\0A\00"
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.7 = [29 x i8] c"Erro ao conectar ao socket.\0A\00"
@.str.8 = [20 x i8] c"Erro de envio 1 %c\0A\00"
@.str.9 = [24 x i8] c"Erro de recebimento %d\0A\00"
@stdout = global i32 0
@.str.10 = [4 x i8] c"%d\0A\00"
@.str.11 = [5 x i8] c"%03d\00"
@.str.12 = [20 x i8] c"erro de envio 2 %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [4 x i8]
%6 = alloca i8
%7 = alloca %struct.timeval
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%11 = icmp slt i32 %0, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %30, label %21
21: ; preds = %16
%22 = load i8*, i8** %17
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %17
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %21, %16
%31 = phi i8 [ 43, %16 ], [ 45, %21 ]
store i8 %31, i8* %6
%32 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq %struct.hostent* %32, null
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %30
%39 = call i32 @bzero(i8* %8, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %40, i32* %41
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %32, i64 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%45 = bitcast i32* %44 to i8*
%46 = getelementptr inbounds %struct.hostent, %struct.hostent* %32, i64 0, i32 0
%47 = load i32, i32* %46
%48 = call i32 @bcopy(i32 %43, i8* %45, i32 %47)
%49 = call i32 @htons(i32 51515)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %49, i32* %50
%51 = load i32, i32* @PF_INET
%52 = load i32, i32* @SOCK_STREAM
%53 = call i32 @socket(i32 %51, i32 %52, i32 0)
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %38
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %38
%60 = bitcast %struct.timeval* %7 to i8*
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
store i32 2, i32* %61
%62 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
store i64 0, i64* %62
%63 = load i32, i32* @SOL_SOCKET
%64 = load i32, i32* @SO_RCVTIMEO
%65 = call i32 @setsockopt(i32 %53, i32 %63, i32 %64, %struct.timeval* %7, i32 16)
%66 = load i32, i32* @SOL_SOCKET
%67 = load i32, i32* @SO_SNDTIMEO
%68 = call i32 @setsockopt(i32 %53, i32 %66, i32 %67, %struct.timeval* %7, i32 16)
%69 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%70 = call i64 @connect(i32 %53, %struct.sockaddr* %69, i32 12)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %77
72: ; preds = %59
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%75 = call i32 @close(i32 %53)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %59
%78 = call i64 @send(i32 %53, i8* %6, i32 1, i32 0)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %87
80: ; preds = %77
%81 = load i32, i32* @stderr
%82 = load i8, i8* %6
%83 = sext i8 %82 to i32
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %83)
%85 = call i32 @close(i32 %53)
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %77
%88 = call i64 @recv(i32 %53, i32* %4, i32 4, i32 0)
%89 = icmp slt i64 %88, 0
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = load i32, i32* @stderr
%92 = load i32, i32* %4
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %92)
%94 = call i32 @close(i32 %53)
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %87
%97 = load i32, i32* %4
%98 = call i32 @ntohl(i32 %97)
store i32 %98, i32* %4
%99 = load i32, i32* @stdout
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %98)
%101 = load i32, i32* %4
%102 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 %101)
%103 = call i64 @send(i32 %53, i8* %10, i32 4, i32 0)
%104 = icmp slt i64 %103, 0
br i1 %104, label %105, label %110
105: ; preds = %96
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %10)
%108 = call i32 @close(i32 %53)
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %96
%111 = call i32 @close(i32 %53)
%112 = call i32 @exit(i32 0)
unreachable
}