#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*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int accept_authentic_connection_from_client(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int multi_receive_file_from_server(char *, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
int multi_receive_file_from_socket(int);
scalar_t__ parse_args(int, char **, char **, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int do_multi_receive_file(int num_args, char **args) {
  char *ip_str;
  uint16_t port;
  uint32_t nonce;
  if (parse_args(num_args, args, &ip_str, &port, &nonce) != 0) {
    return 1;
  }
  if (strcmp(ip_str, "-") == 0) {
    int socket = accept_authentic_connection_from_client(port);
    if (socket < 0) {
      return 1;
    }
    int ret = multi_receive_file_from_socket(socket);
    close(socket);
    if (ret != 0) {
      return 1;
    }
    return 0;
  } else {
    return multi_receive_file_from_server(ip_str, port, nonce);
  }
}


x86 assembly (clang, -O0):
<do_multi_receive_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1060 <parse_args@plt>
cmp    $0x0,%rax
je     119d <do_multi_receive_file+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    121f <do_multi_receive_file+0xbf>
mov    -0x18(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    120d <do_multi_receive_file+0xad>
mov    -0x1c(%rbp),%edi
call   1040 <accept_authentic_connection_from_client@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11d8 <do_multi_receive_file+0x78>
movl   $0x1,-0x4(%rbp)
jmp    121f <do_multi_receive_file+0xbf>
mov    -0x24(%rbp),%edi
call   1080 <multi_receive_file_from_socket@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x28(%rbp)
je     1201 <do_multi_receive_file+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    121f <do_multi_receive_file+0xbf>
movl   $0x0,-0x4(%rbp)
jmp    121f <do_multi_receive_file+0xbf>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <multi_receive_file_from_server@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_multi_receive_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
lea    0x4(%rsp),%r8
call   1060 <parse_args@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11d6 <do_multi_receive_file+0x76>
mov    0x8(%rsp),%rdi
lea    0xe70(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11af <do_multi_receive_file+0x4f>
mov    0x8(%rsp),%rdi
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
call   1030 <multi_receive_file_from_server@plt>
mov    %eax,%ebx
jmp    11d6 <do_multi_receive_file+0x76>
mov    (%rsp),%edi
call   1040 <accept_authentic_connection_from_client@plt>
test   %eax,%eax
js     11d6 <do_multi_receive_file+0x76>
mov    %eax,%ebp
mov    %eax,%edi
call   1080 <multi_receive_file_from_socket@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1050 <close@plt>
xor    %ebx,%ebx
test   %r14d,%r14d
setne  %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define i32 @do_multi_receive_file(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i64 @parse_args(i32 %11, i8** %12, i8** %6, i32* %7, i32* %8)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 1, i32* %3
br label %40
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load i32, i32* %7
%22 = call i32 @accept_authentic_connection_from_client(i32 %21)
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %3
br label %40
26: ; preds = %20
%27 = load i32, i32* %9
%28 = call i32 @multi_receive_file_from_socket(i32 %27)
store i32 %28, i32* %10
%29 = load i32, i32* %9
%30 = call i32 @close(i32 %29)
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 1, i32* %3
br label %40
34: ; preds = %26
store i32 0, i32* %3
br label %40
35: ; preds = %16
%36 = load i8*, i8** %6
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = call i32 @multi_receive_file_from_server(i8* %36, i32 %37, i32 %38)
store i32 %39, i32* %3
br label %40
40: ; preds = %35, %34, %33, %25, %15
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define i32 @do_multi_receive_file(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i8** %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i64 @parse_args(i32 %0, i8** %1, i8** %3, i32* %4, i32* %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i32, i32* %4
%17 = call i32 @accept_authentic_connection_from_client(i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %15
%20 = call i32 @multi_receive_file_from_socket(i32 %17)
%21 = call i32 @close(i32 %17)
%22 = icmp ne i32 %20, 0
%23 = zext i1 %22 to i32
br label %29
24: ; preds = %11
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = call i32 @multi_receive_file_from_server(i8* %25, i32 %26, i32 %27)
br label %29
29: ; preds = %19, %15, %2, %24
%30 = phi i32 [ %28, %24 ], [ 1, %2 ], [ %23, %19 ], [ 1, %15 ]
ret i32 %30
}