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


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)
mov    %r8,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1160 <hydra_reconnect+0x30>
mov    -0x4(%rbp),%edi
call   1030 <hydra_disconnect@plt>
mov    %eax,-0x4(%rbp)
movzbl -0x15(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1184 <hydra_reconnect+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <hydra_connect_tcp@plt>
mov    %eax,-0x4(%rbp)
jmp    1197 <hydra_reconnect+0x67>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
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   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %rsi,%rbx
test   %edi,%edi
js     114b <hydra_reconnect+0x1b>
call   1030 <hydra_disconnect@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
test   $0x1,%bpl
jne    1166 <hydra_reconnect+0x36>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <hydra_connect_tcp@plt>
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <hydra_connect_ssl@plt>

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

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