#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 /*<<< orphan*/ sayf(int, char *, char *, unsigned short, unsigned short);
char *strchr(char *, char);
void saypasv(int cs, char *addr, unsigned short int port) {
  unsigned short int lo, hi;
  char *dot;
  hi = port % 256;
  lo = (port - hi) / 256;
  while ((dot = strchr(addr, '.'))) {
    *dot = ',';
  }
  sayf(cs, "227 Entering Passive Mode (%s,%d,%d)\r\n", addr, lo, hi);
}


x86 assembly (clang, -O0):
<saypasv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movzwl -0x12(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0x16(%rbp)
movzwl -0x12(%rbp),%eax
movzwl -0x16(%rbp),%ecx
sub    %ecx,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %ax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1187 <saypasv+0x67>
mov    -0x20(%rbp),%rax
movb   $0x2c,(%rax)
jmp    115f <saypasv+0x3f>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ax
lea    0xe67(%rip),%rsi
movzwl %ax,%ecx
movzwl -0x16(%rbp),%r8d
call   1040 <sayf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saypasv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r14d
movzbl %bpl,%r15d
mov    %rsi,%rdi
cs nopw 0x0(%rax,%rax,1)
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1157 <saypasv+0x37>
movb   $0x2c,(%rax)
mov    %rbx,%rdi
jmp    1140 <saypasv+0x20>
movzwl %bp,%eax
movzwl %r15w,%r8d
sub    %r8d,%eax
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
shr    $0x8,%ecx
movzwl %cx,%ecx
lea    0xe87(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sayf@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"227 Entering Passive Mode (%s,%d,%d)\0D\0A\00"
define void @saypasv(i32 %0, i8* %1, i16 zeroext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i16 %2, i16* %6
%10 = load i16, i16* %6
%11 = zext i16 %10 to i32
%12 = srem i32 %11, 256
%13 = trunc i32 %12 to i16
store i16 %13, i16* %8
%14 = load i16, i16* %6
%15 = zext i16 %14 to i32
%16 = load i16, i16* %8
%17 = zext i16 %16 to i32
%18 = sub nsw i32 %15, %17
%19 = sdiv i32 %18, 256
%20 = trunc i32 %19 to i16
store i16 %20, i16* %7
br label %21
21: ; preds = %25, %3
%22 = load i8*, i8** %5
%23 = call i8* @strchr(i8* %22, i8 signext 46)
store i8* %23, i8** %9
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i8*, i8** %9
store i8 44, i8* %26
br label %21
27: ; preds = %21
%28 = load i32, i32* %4
%29 = load i8*, i8** %5
%30 = load i16, i16* %7
%31 = load i16, i16* %8
%32 = call i32 @sayf(i32 %28, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %29, i16 zeroext %30, i16 zeroext %31)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"227 Entering Passive Mode (%s,%d,%d)\0D\0A\00"
define void @saypasv(i32 %0, i8* %1, i16 zeroext %2) {
%4 = and i16 %2, 255
%5 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 46)
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %3, %7
%8 = phi i8* [ %9, %7 ], [ %5, %3 ]
store i8 44, i8* %8
%9 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 46)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %7
11: ; preds = %7, %3
%12 = zext i16 %2 to i32
%13 = zext i16 %4 to i32
%14 = sub nsw i32 %12, %13
%15 = sdiv i32 %14, 256
%16 = trunc i32 %15 to i16
%17 = tail call i32 @sayf(i32 %0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %1, i16 zeroext %16, i16 zeroext %4)
ret void
}