#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 atol(char *);
int /*<<< orphan*/ error(char *);
int read(int, char *, int);
int getMessageLength(int connect_d) {
  int message_size_length = 13;
  char message_size[message_size_length];
  int n = read(connect_d, message_size, message_size_length - 1);
  if (n < 0)
    error("Can't reading size from socket");
  message_size[12] = '\0';
  return atol(message_size);
}


x86 assembly (clang, -O0):
<getMessageLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xd,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1030 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    118f <getMessageLength+0x5f>
lea    0xe76(%rip),%rdi
call   1040 <error@plt>
mov    -0x28(%rbp),%rdi
movb   $0x0,0xc(%rdi)
call   1050 <atol@plt>
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMessageLength>:
sub    $0x18,%rsp
mov    %rsp,%rsi
mov    $0xc,%edx
call   1030 <read@plt>
test   %eax,%eax
jns    1151 <getMessageLength+0x21>
lea    0xeb4(%rip),%rdi
call   1040 <error@plt>
movb   $0x0,0xc(%rsp)
mov    %rsp,%rdi
call   1050 <atol@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Can't reading size from socket\00"
define i32 @getMessageLength(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 %0, i32* %2
store i32 13, i32* %3
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i8, i64 %8
store i64 %8, i64* %5
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = call i32 @read(i32 %11, i8* %10, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i32 @error(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %1
%20 = getelementptr inbounds i8, i8* %10, i64 12
store i8 0, i8* %20
%21 = call i32 @atol(i8* %10)
%22 = load i8*, i8** %4
ret i32 %21
}

LLVM IR (-O2):
@.str = [31 x i8] c"Can't reading size from socket\00"
define i32 @getMessageLength(i32 %0) {
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 %0, i8* %3, i32 12)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @error(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 12
store i8 0, i8* %9
%10 = call i32 @atol(i8* %3)
ret i32 %10
}