#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 */
scalar_t__ ECONNREFUSED;
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
void get_response(int sock, char *buf) {
  int n;
  n = read(sock, buf, 625);
  if (n < 0) {
    if (errno == EINTR)
      return;
    if (errno == ECONNREFUSED) {
      fprintf(stderr, "Connection refused - server not running\n");
      exit(1);
    }
  }
  buf[n] = '\0';
}


x86 assembly (clang, -O0):
<get_response>:
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    $0x271,%edx
call   1030 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ba <get_response+0x8a>
mov    0x2e6c(%rip),%rax
mov    (%rax),%rax
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%rax
jne    117c <get_response+0x4c>
jmp    11c6 <get_response+0x96>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <get_response+0x85>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11ba <get_response+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_response>:
push   %rbx
mov    %rsi,%rbx
mov    $0x271,%edx
call   1030 <read@plt>
test   %eax,%eax
jns    1164 <get_response+0x34>
mov    0x2e87(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e75(%rip),%rdx
cmp    (%rdx),%rcx
je     116a <get_response+0x3a>
mov    0x2e89(%rip),%rdx
cmp    (%rdx),%rcx
je     116c <get_response+0x3c>
cltq
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@EINTR = global i64 0
@ECONNREFUSED = global i64 0
@stderr = global i32 0
@.str = [41 x i8] c"Connection refused - server not running\0A\00"
define void @get_response(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = load i8*, i8** %4
%8 = call i32 @read(i32 %6, i8* %7, i32 625)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = load i64, i64* @errno
%13 = load i64, i64* @EINTR
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11
br label %30
16: ; preds = %11
%17 = load i64, i64* @errno
%18 = load i64, i64* @ECONNREFUSED
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %16
br label %25
25: ; preds = %24, %2
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %25, %15
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EINTR = global i64 0
@ECONNREFUSED = global i64 0
@stderr = global i32 0
@.str = [41 x i8] c"Connection refused - server not running\0A\00"
define void @get_response(i32 %0, i8* nocapture %1) {
%3 = tail call i32 @read(i32 %0, i8* %1, i32 625)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = load i64, i64* @errno
%7 = load i64, i64* @EINTR
%8 = icmp eq i64 %6, %7
br i1 %8, label %19, label %9
9: ; preds = %5
%10 = load i64, i64* @ECONNREFUSED
%11 = icmp eq i64 %6, %10
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %2
%17 = sext i32 %3 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 0, i8* %18
br label %19
19: ; preds = %5, %16
ret void
}