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

/* Variables and functions */
int bindDataSocket(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int /*<<< orphan*/ write(int, ...);
int sendDir(char *dir, int port) {
  int dataSocket = bindDataSocket(port);
  int size = strlen(dir);
  write(dataSocket, &size, sizeof(size));
  write(dataSocket, dir, strlen(dir));
  printf("Directory listing sent\n");
  printf("Closing Data1 connection Socket\n");
  close(dataSocket);
  return 1;
}


x86 assembly (clang, -O0):
<sendDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <bindDataSocket@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    0xe49(%rip),%rdi
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendDir>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %esi,%edi
call   1070 <bindDataSocket@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <write@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <write@plt>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Directory listing sent\0A\00"
@.str.1 = [33 x i8] c"Closing Data1 connection Socket\0A\00"
define i32 @sendDir(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call i32 @bindDataSocket(i32 %7)
store i32 %8, i32* %5
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %5
%12 = call i32 (i32, ...) @write(i32 %11, i32* %6, i64 4)
%13 = load i32, i32* %5
%14 = load i8*, i8** %3
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = call i32 (i32, ...) @write(i32 %13, i8* %14, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* %5
%21 = call i32 @close(i32 %20)
ret i32 1
}

LLVM IR (-O2):
@str = [23 x i8] c"Directory listing sent\00"
@str.2 = [32 x i8] c"Closing Data1 connection Socket\00"
define i32 @sendDir(i8* %0, i32 %1) {
%3 = alloca i32
%4 = tail call i32 @bindDataSocket(i32 %1)
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @strlen(i8* %0)
store i32 %6, i32* %3
%7 = call i32 (i32, ...) @write(i32 %4, i32* %3, i64 4)
%8 = call i32 @strlen(i8* %0)
%9 = call i32 (i32, ...) @write(i32 %4, i8* %0, i32 %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0))
%12 = call i32 @close(i32 %4)
ret i32 1
}