#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*/ localname;

/* Variables and functions */
int MAXHOSTNAMELEN;
int abre_conexao(int *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ create_slave(char *, char *, int);
int /*<<< orphan*/ gethostname(char *, int);
int /*<<< orphan*/ ping(int, long long *, long long *, char *);
int /*<<< orphan*/ printf(char *, char *, long long, char *, long long);
int wait_connection(int);
void sincroniza(char *localhost, char *remotehost) {
  long long local;
  long long remote;
  int porta;
  int com_socket;
  int new_socket;
  char localname[MAXHOSTNAMELEN];
  char remotename[MAXHOSTNAMELEN];
  gethostname(localname, sizeof(localname));
  com_socket = abre_conexao(&porta);
  create_slave(remotehost, localhost, porta);
  new_socket = wait_connection(com_socket);
  ping(new_socket, &local, &remote, remotename);
  printf("%s %lld %s %lld\n", localname, local, remotename, remote);
  close(new_socket);
  close(com_socket);
}


x86 assembly (clang, -O0):
<sincroniza>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e61(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x58(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    (%rcx),%ecx
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x48(%rbp)
mov    %eax,%esi
call   1090 <gethostname@plt>
lea    -0x24(%rbp),%rdi
call   1040 <abre_conexao@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <create_slave@plt>
mov    -0x28(%rbp),%edi
call   1080 <wait_connection@plt>
mov    -0x50(%rbp),%rcx
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <ping@plt>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rcx
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%r8
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1050 <close@plt>
mov    -0x28(%rbp),%edi
call   1050 <close@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sincroniza>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rsp,-0x38(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r14
mov    %rsi,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,%rdi
call   1090 <gethostname@plt>
lea    -0x2c(%rbp),%rdi
call   1040 <abre_conexao@plt>
mov    %eax,%r13d
mov    -0x2c(%rbp),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <create_slave@plt>
mov    %r13d,%edi
call   1080 <wait_connection@plt>
mov    %eax,%r15d
lea    -0x48(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    %eax,%edi
mov    %rbx,%rcx
call   1070 <ping@plt>
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%r8
lea    0xdf7(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %r15d,%edi
call   1050 <close@plt>
mov    %r13d,%edi
call   1050 <close@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MAXHOSTNAMELEN = global i32 0
@.str = [17 x i8] c"%s %lld %s %lld\0A\00"
define void @sincroniza(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%13 = load i32, i32* @MAXHOSTNAMELEN
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %10
%16 = alloca i8, i64 %14
store i64 %14, i64* %11
%17 = load i32, i32* @MAXHOSTNAMELEN
%18 = zext i32 %17 to i64
%19 = alloca i8, i64 %18
store i64 %18, i64* %12
%20 = trunc i64 %14 to i32
%21 = call i32 @gethostname(i8* %16, i32 %20)
%22 = call i32 @abre_conexao(i32* %7)
store i32 %22, i32* %8
%23 = load i8*, i8** %4
%24 = load i8*, i8** %3
%25 = load i32, i32* %7
%26 = call i32 @create_slave(i8* %23, i8* %24, i32 %25)
%27 = load i32, i32* %8
%28 = call i32 @wait_connection(i32 %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = call i32 @ping(i32 %29, i64* %5, i64* %6, i8* %19)
%31 = load i64, i64* %5
%32 = load i64, i64* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %16, i64 %31, i8* %19, i64 %32)
%34 = load i32, i32* %9
%35 = call i32 @close(i32 %34)
%36 = load i32, i32* %8
%37 = call i32 @close(i32 %36)
%38 = load i8*, i8** %10
ret void
}

LLVM IR (-O2):
@MAXHOSTNAMELEN = global i32 0
@.str = [17 x i8] c"%s %lld %s %lld\0A\00"
define void @sincroniza(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = load i32, i32* @MAXHOSTNAMELEN
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = load i32, i32* @MAXHOSTNAMELEN
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
%16 = call i32 @gethostname(i8* %12, i32 %9)
%17 = call i32 @abre_conexao(i32* %5)
%18 = load i32, i32* %5
%19 = call i32 @create_slave(i8* %1, i8* %0, i32 %18)
%20 = call i32 @wait_connection(i32 %17)
%21 = call i32 @ping(i32 %20, i64* %3, i64* %4, i8* %15)
%22 = load i64, i64* %3
%23 = load i64, i64* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %12, i64 %22, i8* %15, i64 %23)
%25 = call i32 @close(i32 %20)
%26 = call i32 @close(i32 %17)
ret void
}