#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 hydra_connect_ssl(char *, int);
int hydra_connect_tcp(char *, int);
int hydra_disconnect(int);
void hydra_reconnect(int s, char *ip, int port, unsigned char options) {
  if (s >= 0)
    s = hydra_disconnect(s);
  if ((options & 1) == 0) {
    s = hydra_connect_tcp(ip, port);
  } else {
    s = hydra_connect_ssl(ip, port);
  }
}


x86 assembly (clang, -O0):
<hydra_reconnect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     115c <hydra_reconnect+0x2c>
mov    -0x4(%rbp),%edi
call   1030 <hydra_disconnect@plt>
mov    %eax,-0x4(%rbp)
movzbl -0x15(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1180 <hydra_reconnect+0x50>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <hydra_connect_tcp@plt>
mov    %eax,-0x4(%rbp)
jmp    118f <hydra_reconnect+0x5f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <hydra_connect_ssl@plt>
mov    %eax,-0x4(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hydra_reconnect>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,%rbx
test   %edi,%edi
js     1145 <hydra_reconnect+0x15>
call   1030 <hydra_disconnect@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
test   $0x1,%bpl
jne    115a <hydra_reconnect+0x2a>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <hydra_connect_tcp@plt>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <hydra_connect_ssl@plt>

LLVM IR (-O0):
define void @hydra_reconnect(i32 %0, i8* %1, i32 %2, i8 zeroext %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8 %3, i8* %8
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i32, i32* %5
%13 = call i32 @hydra_disconnect(i32 %12)
store i32 %13, i32* %5
br label %14
14: ; preds = %11, %4
%15 = load i8, i8* %8
%16 = zext i8 %15 to i32
%17 = and i32 %16, 1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = call i32 @hydra_connect_tcp(i8* %20, i32 %21)
store i32 %22, i32* %5
br label %27
23: ; preds = %14
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = call i32 @hydra_connect_ssl(i8* %24, i32 %25)
store i32 %26, i32* %5
br label %27
27: ; preds = %23, %19
ret void
}

LLVM IR (-O2):
define void @hydra_reconnect(i32 %0, i8* %1, i32 %2, i8 zeroext %3) {
%5 = icmp sgt i32 %0, -1
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @hydra_disconnect(i32 %0)
br label %8
8: ; preds = %6, %4
%9 = and i8 %3, 1
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @hydra_connect_tcp(i8* %1, i32 %2)
br label %15
13: ; preds = %8
%14 = tail call i32 @hydra_connect_ssl(i8* %1, i32 %2)
br label %15
15: ; preds = %13, %11
ret void
}