#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*/ errno;
int /*<<< orphan*/ internal_logit(char *, int, char *, char *,
                                  int /*<<< orphan*/);
int recv(int, int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int get_int(int sock, int *i) {
  int res;
  res = recv(sock, i, sizeof(int), 0);
  if (res == -1)
    internal_logit("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/ecthiender/mocp-git/refs/"
                   "heads/master/protocol.c",
                   63, "UNKNOWN_FUNC", "recv() failed when getting int: %s",
                   strerror(errno));
  return res == sizeof(int) ? 1 : 0;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    118f <get_int+0x5f>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
mov    %eax,%r8d
lea    0xe89(%rip),%rdi
mov    $0x3f,%esi
lea    0xf08(%rip),%rdx
lea    0xf0e(%rip),%rcx
call   1050 <internal_logit@plt>
movslq -0x14(%rbp),%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x4,%rdx
cmove  %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %rbx
mov    $0x4,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1174 <get_int+0x44>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
lea    0xea7(%rip),%rdi
lea    0xf2b(%rip),%rdx
lea    0xf31(%rip),%rcx
mov    $0x3f,%esi
mov    %eax,%r8d
call   1050 <internal_logit@plt>
xor    %eax,%eax
cmp    $0x4,%ebx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ecthiender/mocp-git/refs/heads/master/protocol.c\00"
@.str.1 = [13 x i8] c"UNKNOWN_FUNC\00"
@.str.2 = [35 x i8] c"recv() failed when getting int: %s\00"
@errno = global i32 0
define i32 @get_int(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%6 = load i32, i32* %3
%7 = load i32*, i32** %4
%8 = call i32 @recv(i32 %6, i32* %7, i32 4, i32 0)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @internal_logit(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11, %2
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = icmp eq i64 %17, 4
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 1, i32 0
ret i32 %20
}

LLVM IR (-O2):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ecthiender/mocp-git/refs/heads/master/protocol.c\00"
@.str.1 = [13 x i8] c"UNKNOWN_FUNC\00"
@.str.2 = [35 x i8] c"recv() failed when getting int: %s\00"
@errno = global i32 0
define i32 @get_int(i32 %0, i32* %1) {
%3 = tail call i32 @recv(i32 %0, i32* %1, i32 4, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @internal_logit(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %5, %2
%10 = icmp eq i32 %3, 4
%11 = zext i1 %10 to i32
ret i32 %11
}