#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*/ asprintf(char **, char *, char const *);
char *edit_box(int, char *, int /*<<< orphan*/ *);
char *explode_path(char const *);
int /*<<< orphan*/ free(void *);
int init_send_dcc(char const *, int, int, char const *);
int log_channel(int, int, char const *, char *, int);
int dcc_send_user(int sr, int ch, const char *nick) {
  int rc = 0;
  const char *filename_in = edit_box(60, "^DCC send file^", NULL);
  if (filename_in) {
    char *log_msg = NULL;
    const char *filename = explode_path(filename_in);
    rc = init_send_dcc(filename, sr, ch, nick);
    asprintf(&log_msg, "DCC send %s", filename);
    if (rc == 0 && log_channel(sr, ch, nick, log_msg, 1) == -1)
      rc = -1;
    free((void *)filename);
    ;
    free((void *)log_msg);
    ;
    free((void *)filename_in);
    ;
  }
  return rc;
}


x86 assembly (clang, -O0):
<dcc_send_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x3c,%edi
lea    0xe7b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <edit_box@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122a <dcc_send_user+0xca>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <explode_path@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1040 <init_send_dcc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1060 <asprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    120f <dcc_send_user+0xaf>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%r8d
call   1070 <log_channel@plt>
cmp    $0xffffffff,%eax
jne    120f <dcc_send_user+0xaf>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcc_send_user>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r12d
mov    %edi,%r13d
lea    0xe85(%rip),%rsi
xor    %ebx,%ebx
mov    $0x3c,%edi
xor    %edx,%edx
call   1050 <edit_box@plt>
test   %rax,%rax
je     1208 <dcc_send_user+0xa8>
mov    %rax,%r15
movq   $0x0,(%rsp)
mov    %rax,%rdi
call   1080 <explode_path@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1040 <init_send_dcc@plt>
mov    %eax,%ebx
lea    0xe52(%rip),%rsi
mov    %rsp,%rdi
mov    %rbp,%rdx
call   1060 <asprintf@plt>
test   %ebx,%ebx
jne    11ef <dcc_send_user+0x8f>
mov    (%rsp),%rcx
mov    %r13d,%edi
mov    %r12d,%esi
mov    %r14,%rdx
mov    $0x1,%r8d
call   1070 <log_channel@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
neg    %ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"^DCC send file^\00"
@.str.1 = [12 x i8] c"DCC send %s\00"
define i32 @dcc_send_user(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
%11 = call i8* @edit_box(i32 60, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* null)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %41
14: ; preds = %3
store i8* null, i8** %9
%15 = load i8*, i8** %8
%16 = call i8* @explode_path(i8* %15)
store i8* %16, i8** %10
%17 = load i8*, i8** %10
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i8*, i8** %6
%21 = call i32 @init_send_dcc(i8* %17, i32 %18, i32 %19, i8* %20)
store i32 %21, i32* %7
%22 = load i8*, i8** %10
%23 = call i32 @asprintf(i8** %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %14
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = load i8*, i8** %6
%30 = load i8*, i8** %9
%31 = call i32 @log_channel(i32 %27, i32 %28, i8* %29, i8* %30, i32 1)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 -1, i32* %7
br label %34
34: ; preds = %33, %26, %14
%35 = load i8*, i8** %10
%36 = call i32 @free(i8* %35)
%37 = load i8*, i8** %9
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %34, %3
%42 = load i32, i32* %7
ret i32 %42
}

LLVM IR (-O2):
@.str = [16 x i8] c"^DCC send file^\00"
@.str.1 = [12 x i8] c"DCC send %s\00"
define i32 @dcc_send_user(i32 %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = tail call i8* @edit_box(i32 60, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* null)
%6 = icmp eq i8* %5, null
br i1 %6, label %24, label %7
7: ; preds = %3
%8 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%9 = tail call i8* @explode_path(i8* %5)
%10 = tail call i32 @init_send_dcc(i8* %9, i32 %0, i32 %1, i8* %2)
%11 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = icmp eq i32 %10, 0
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = load i8*, i8** %4
%15 = call i32 @log_channel(i32 %0, i32 %1, i8* %2, i8* %14, i32 1)
%16 = icmp eq i32 %15, -1
%17 = sext i1 %16 to i32
br label %18
18: ; preds = %13, %7
%19 = phi i32 [ %10, %7 ], [ %17, %13 ]
%20 = call i32 @free(i8* %9)
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
%23 = call i32 @free(i8* %5)
br label %24
24: ; preds = %18, %3
%25 = phi i32 [ %19, %18 ], [ 0, %3 ]
ret i32 %25
}