#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGHUP;
scalar_t__ get_file_lock();
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ lock_pid_file();
int /*<<< orphan*/ printf(char *, ...);
void reconnect() {
  pid_t pid_lock = get_file_lock();
  if (!lock_pid_file() && pid_lock > 0) {
    printf("Signal send to %ld.\n", (long)pid_lock);
    kill(pid_lock, SIGHUP);
  } else {
    printf("Program is not running\n");
  }
}


x86 assembly (clang, -O0):
<reconnect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <get_file_lock@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <lock_pid_file@plt>
cmp    $0x0,%eax
jne    1197 <reconnect+0x57>
cmpq   $0x0,-0x8(%rbp)
jle    1197 <reconnect+0x57>
mov    -0x8(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
jmp    11a5 <reconnect+0x65>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reconnect>:
push   %rbx
xor    %eax,%eax
call   1050 <get_file_lock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <lock_pid_file@plt>
test   %eax,%eax
jne    118e <reconnect+0x3e>
test   %rbx,%rbx
jle    118e <reconnect+0x3e>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <kill@plt>
lea    0xe80(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Signal send to %ld.\0A\00"
@SIGHUP = global i32 0
@.str.1 = [24 x i8] c"Program is not running\0A\00"
define void @reconnect() {
%1 = alloca i64
%2 = call i64 (...) @get_file_lock()
store i64 %2, i64* %1
%3 = call i32 (...) @lock_pid_file()
%4 = icmp ne i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %0
%6 = load i64, i64* %1
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i64, i64* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %1
%12 = load i32, i32* @SIGHUP
%13 = call i32 @kill(i64 %11, i32 %12)
br label %16
14: ; preds = %5, %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Signal send to %ld.\0A\00"
@SIGHUP = global i32 0
@str = [23 x i8] c"Program is not running\00"
define void @reconnect() {
%1 = tail call i64 (...) @get_file_lock()
%2 = tail call i32 (...) @lock_pid_file()
%3 = icmp eq i32 %2, 0
%4 = icmp sgt i64 %1, 0
%5 = select i1 %3, i1 %4, i1 false
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %1)
%8 = load i32, i32* @SIGHUP
%9 = tail call i32 @kill(i64 %1, i32 %8)
br label %12
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
ret void
}