#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*/ die(char *, int, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
void ftpparse(int in, char *cmd, char *arg, char *disp) {
  int len = strlen(cmd) + strlen(arg) - 2;
  char *packet = (char *)malloc(len);
  sprintf(packet, cmd, arg);
  printf("> ");
  printf(cmd, disp);
  len = send(in, packet, len, 0);
  free(packet);
  if (len < 0)
    die("Send", 1, in);
}


x86 assembly (clang, -O0):
<ftpparse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
sub    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1090 <sprintf@plt>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x24(%rbp)
jge    121e <ftpparse+0xae>
mov    -0x4(%rbp),%edx
lea    0xdef(%rip),%rdi
mov    $0x1,%esi
call   1080 <die@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftpparse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r13,%rdi
call   1040 <strlen@plt>
add    %eax,%r12d
add    $0xfffffffe,%r12d
mov    %r12d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1090 <sprintf@plt>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
js     1202 <ftpparse+0x92>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfa(%rip),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <die@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@.str.1 = [5 x i8] c"Send\00"
define void @ftpparse(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
%15 = add nsw i32 %12, %14
%16 = sub nsw i32 %15, 2
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %10
%20 = load i8*, i8** %10
%21 = load i8*, i8** %6
%22 = load i8*, i8** %7
%23 = call i32 @sprintf(i8* %20, i8* %21, i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %6
%26 = load i8*, i8** %8
%27 = call i32 (i8*, ...) @printf(i8* %25, i8* %26)
%28 = load i32, i32* %5
%29 = load i8*, i8** %10
%30 = load i32, i32* %9
%31 = call i32 @send(i32 %28, i8* %29, i32 %30, i32 0)
store i32 %31, i32* %9
%32 = load i8*, i8** %10
%33 = call i32 @free(i8* %32)
%34 = load i32, i32* %9
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %4
%37 = load i32, i32* %5
%38 = call i32 @die(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %37)
br label %39
39: ; preds = %36, %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@.str.1 = [5 x i8] c"Send\00"
define void @ftpparse(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i32 @strlen(i8* %2)
%7 = add i32 %5, -2
%8 = add i32 %7, %6
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) %1, i8* %2)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %1, i8* %3)
%14 = tail call i32 @send(i32 %0, i8* %10, i32 %8, i32 0)
%15 = tail call i32 @free(i8* %10)
%16 = icmp slt i32 %14, 0
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = tail call i32 @die(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %0)
br label %19
19: ; preds = %17, %4
ret void
}