#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 */
struct katcp_dispatch {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_client_server_katcp(struct katcp_dispatch *, int,
                                           char *);
int pipe_from_file_katcp(struct katcp_dispatch *, char *);
int load_from_file_katcp(struct katcp_dispatch *d, char *file) {
  int fd;
  if (file) {
    fd = pipe_from_file_katcp(d, file);
    if (fd < 0) {
      return -1;
    }
    add_client_server_katcp(d, fd, file);
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<load_from_file_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117d <load_from_file_katcp+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <pipe_from_file_katcp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1161 <load_from_file_katcp+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    1184 <load_from_file_katcp+0x64>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <add_client_server_katcp@plt>
movl   $0x0,-0x4(%rbp)
jmp    1184 <load_from_file_katcp+0x64>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_from_file_katcp>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebp
test   %rsi,%rsi
je     114c <load_from_file_katcp+0x2c>
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <pipe_from_file_katcp@plt>
test   %eax,%eax
js     114c <load_from_file_katcp+0x2c>
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <add_client_server_katcp@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
define i32 @load_from_file_katcp(%struct.katcp_dispatch* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.katcp_dispatch*
%5 = alloca i8*
%6 = alloca i32
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%11 = load i8*, i8** %5
%12 = call i32 @pipe_from_file_katcp(%struct.katcp_dispatch* %10, i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 -1, i32* %3
br label %22
16: ; preds = %9
%17 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%18 = load i32, i32* %6
%19 = load i8*, i8** %5
%20 = call i32 @add_client_server_katcp(%struct.katcp_dispatch* %17, i32 %18, i8* %19)
store i32 0, i32* %3
br label %22
21: ; preds = %2
store i32 -1, i32* %3
br label %22
22: ; preds = %21, %16, %15
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
define i32 @load_from_file_katcp(%struct.katcp_dispatch* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = tail call i32 @pipe_from_file_katcp(%struct.katcp_dispatch* %0, i8* %1)
%6 = icmp slt i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @add_client_server_katcp(%struct.katcp_dispatch* %0, i32 %5, i8* %1)
br label %9
9: ; preds = %2, %4, %7
%10 = phi i32 [ 0, %7 ], [ -1, %4 ], [ -1, %2 ]
ret i32 %10
}