#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 int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_log(char *);
void stop_ssh_tunnel(pid_t process_id) {
  write_log("Stopping ssh process.");
  if (kill(process_id, SIGTERM) != 0) {
    perror("kill");
    exit(EXIT_FAILURE);
  }
  wait(NULL);
}


x86 assembly (clang, -O0):
<stop_ssh_tunnel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
call   1030 <write_log@plt>
mov    -0x4(%rbp),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
je     119c <stop_ssh_tunnel+0x4c>
lea    0xe8d(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stop_ssh_tunnel>:
push   %rbx
mov    %edi,%ebx
lea    0xea6(%rip),%rdi
call   1030 <write_log@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <kill@plt>
test   %rax,%rax
jne    117c <stop_ssh_tunnel+0x2c>
xor    %edi,%edi
pop    %rbx
jmp    1070 <wait@plt>
lea    0xe93(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Stopping ssh process.\00"
@SIGTERM = global i32 0
@.str.1 = [5 x i8] c"kill\00"
@EXIT_FAILURE = global i32 0
define void @stop_ssh_tunnel(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @write_log(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = load i32, i32* @SIGTERM
%6 = call i64 @kill(i32 %4, i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = call i32 @wait(i32* null)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Stopping ssh process.\00"
@SIGTERM = global i32 0
@.str.1 = [5 x i8] c"kill\00"
@EXIT_FAILURE = global i32 0
define void @stop_ssh_tunnel(i32 %0) {
%2 = tail call i32 @write_log(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @SIGTERM
%4 = tail call i64 @kill(i32 %0, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = tail call i32 @wait(i32* null)
ret void
}