#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 */
struct SSH_VERSION_STRING {
  int dummy;
};
struct SSH_BUFFER {
  int dummy;
};

/* Variables and functions */
scalar_t__ parse_line(struct SSH_VERSION_STRING *);
scalar_t__ read_line(int, struct SSH_VERSION_STRING *, struct SSH_BUFFER *);
int ssh_version_string_read(struct SSH_VERSION_STRING *ver_str, int sock,
                            struct SSH_BUFFER *rest) {
  if (read_line(sock, ver_str, rest) < 0 || parse_line(ver_str) < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<ssh_version_string_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <read_line@plt>
cmp    $0x0,%rax
jl     1160 <ssh_version_string_read+0x40>
mov    -0x10(%rbp),%rdi
call   1030 <parse_line@plt>
cmp    $0x0,%rax
jge    116c <ssh_version_string_read+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1173 <ssh_version_string_read+0x53>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssh_version_string_read>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
mov    %rbx,%rsi
call   1040 <read_line@plt>
test   %rax,%rax
js     1141 <ssh_version_string_read+0x21>
mov    %rbx,%rdi
call   1030 <parse_line@plt>
sar    $0x3f,%rax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.SSH_VERSION_STRING = type { i32 }
%struct.SSH_BUFFER = type { i32 }
define i32 @ssh_version_string_read(%struct.SSH_VERSION_STRING* %0, i32 %1, %struct.SSH_BUFFER* %2) {
%4 = alloca i32
%5 = alloca %struct.SSH_VERSION_STRING*
%6 = alloca i32
%7 = alloca %struct.SSH_BUFFER*
store %struct.SSH_VERSION_STRING* %0, %struct.SSH_VERSION_STRING** %5
store i32 %1, i32* %6
store %struct.SSH_BUFFER* %2, %struct.SSH_BUFFER** %7
%8 = load i32, i32* %6
%9 = load %struct.SSH_VERSION_STRING*, %struct.SSH_VERSION_STRING** %5
%10 = load %struct.SSH_BUFFER*, %struct.SSH_BUFFER** %7
%11 = call i64 @read_line(i32 %8, %struct.SSH_VERSION_STRING* %9, %struct.SSH_BUFFER* %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = load %struct.SSH_VERSION_STRING*, %struct.SSH_VERSION_STRING** %5
%15 = call i64 @parse_line(%struct.SSH_VERSION_STRING* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13, %3
store i32 -1, i32* %4
br label %19
18: ; preds = %13
store i32 0, i32* %4
br label %19
19: ; preds = %18, %17
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
%struct.SSH_VERSION_STRING = type { i32 }
%struct.SSH_BUFFER = type { i32 }
define i32 @ssh_version_string_read(%struct.SSH_VERSION_STRING* %0, i32 %1, %struct.SSH_BUFFER* %2) {
%4 = tail call i64 @read_line(i32 %1, %struct.SSH_VERSION_STRING* %0, %struct.SSH_BUFFER* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i64 @parse_line(%struct.SSH_VERSION_STRING* %0)
%8 = ashr i64 %7, 63
%9 = trunc i64 %8 to i32
br label %10
10: ; preds = %6, %3
%11 = phi i32 [ -1, %3 ], [ %9, %6 ]
ret i32 %11
}