#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*/ bzero(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int write(int, char *, int);
void procesar(int sock, int *numero) {
  int n;
  char buffer[256];
  bzero(buffer, 256);
  n = read(sock, buffer, 255);
  if (n < 0) {
    perror("Error al leer del socket");
    (*numero)--;
    exit(1);
  }
  printf("Mensaje del socket: %s\n", buffer);
  n = write(sock, "Respuesta a socket", 18);
  if (n < 0) {
    perror("Error al escribir en el socket");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<procesar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   1070 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0xff,%edx
call   1050 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11c5 <procesar+0x65>
lea    0xe55(%rip),%rdi
call   1060 <perror@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x120(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    0xe4f(%rip),%rsi
mov    $0x12,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    120f <procesar+0xaf>
lea    0xe44(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<procesar>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x100,%esi
call   1070 <bzero@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xff,%edx
call   1050 <read@plt>
test   %eax,%eax
js     11c7 <procesar+0x67>
lea    0xe7e(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
lea    0xe87(%rip),%rsi
mov    %ebx,%edi
mov    $0x12,%edx
call   1030 <write@plt>
test   %eax,%eax
js     11e1 <procesar+0x81>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe32(%rip),%rdi
call   1060 <perror@plt>
addl   $0xffffffff,(%r14)
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe5c(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Error al leer del socket\00"
@.str.1 = [24 x i8] c"Mensaje del socket: %s\0A\00"
@.str.2 = [19 x i8] c"Respuesta a socket\00"
@.str.3 = [31 x i8] c"Error al escribir en el socket\00"
define void @procesar(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [256 x i8]
store i32 %0, i32* %3
store i32* %1, i32** %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = call i32 @bzero(i8* %7, i32 256)
%9 = load i32, i32* %3
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i32 @read(i32 %9, i8* %10, i32 255)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = add nsw i32 %17, -1
store i32 %18, i32* %16
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %3
%24 = call i32 @write(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 18)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Error al leer del socket\00"
@.str.1 = [24 x i8] c"Mensaje del socket: %s\0A\00"
@.str.2 = [19 x i8] c"Respuesta a socket\00"
@.str.3 = [31 x i8] c"Error al escribir en el socket\00"
define void @procesar(i32 %0, i32* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 256)
%6 = call i32 @read(i32 %0, i8* %4, i32 255)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
store i32 %11, i32* %1
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%15 = call i32 @write(i32 %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 18)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
ret void
}