#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;
};
struct katcl_parse {
  int dummy;
};

/* Variables and functions */
scalar_t__ append_parse_katcp(struct katcp_dispatch *, struct katcl_parse *);
struct katcl_parse *arg_parse_katcp(struct katcp_dispatch *);
struct katcl_parse *get_dbase_katcp(struct katcp_dispatch *,
                                    struct katcl_parse *);
int /*<<< orphan*/ log_message_katcp(struct katcp_dispatch *, int,
                                     int /*<<< orphan*/ *, char *);
int get_dbase_cmd_katcp(struct katcp_dispatch *d, int argc) {
  struct katcl_parse *ptx, *prx;
  if (argc < 2) {
    log_message_katcp(d, 4, NULL, "useage");
    return (-1);
  }
  ptx = arg_parse_katcp(d);
  if (ptx == NULL)
    return (-1);
  prx = get_dbase_katcp(d, ptx);
  if (prx == NULL)
    return (-1);
  if (append_parse_katcp(d, prx) < 0)
    return (-1);
  return 1;
}


x86 assembly (clang, -O0):
<get_dbase_cmd_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    117e <get_dbase_cmd_katcp+0x3e>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
mov    %eax,%edx
lea    0xe93(%rip),%rcx
call   1060 <log_message_katcp@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <get_dbase_cmd_katcp+0xb4>
mov    -0x10(%rbp),%rdi
call   1030 <arg_parse_katcp@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a2 <get_dbase_cmd_katcp+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <get_dbase_cmd_katcp+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <get_dbase_katcp@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ca <get_dbase_cmd_katcp+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <get_dbase_cmd_katcp+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <append_parse_katcp@plt>
cmp    $0x0,%rax
jge    11ed <get_dbase_cmd_katcp+0xad>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <get_dbase_cmd_katcp+0xb4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dbase_cmd_katcp>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0x1,%esi
jg     1168 <get_dbase_cmd_katcp+0x28>
lea    0xeae(%rip),%rcx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <log_message_katcp@plt>
mov    $0xffffffff,%ebp
jmp    11a3 <get_dbase_cmd_katcp+0x63>
mov    %rbx,%rdi
call   1030 <arg_parse_katcp@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     11a3 <get_dbase_cmd_katcp+0x63>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <get_dbase_katcp@plt>
test   %rax,%rax
je     11a3 <get_dbase_cmd_katcp+0x63>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <append_parse_katcp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setns  %cl
lea    (%rcx,%rcx,1),%ebp
add    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [7 x i8] c"useage\00"
define i32 @get_dbase_cmd_katcp(%struct.katcp_dispatch* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.katcp_dispatch*
%5 = alloca i32
%6 = alloca %struct.katcl_parse*
%7 = alloca %struct.katcl_parse*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%12 = call i32 @log_message_katcp(%struct.katcp_dispatch* %11, i32 4, i32* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %33
13: ; preds = %2
%14 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%15 = call %struct.katcl_parse* @arg_parse_katcp(%struct.katcp_dispatch* %14)
store %struct.katcl_parse* %15, %struct.katcl_parse** %6
%16 = load %struct.katcl_parse*, %struct.katcl_parse** %6
%17 = icmp eq %struct.katcl_parse* %16, null
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %3
br label %33
19: ; preds = %13
%20 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%21 = load %struct.katcl_parse*, %struct.katcl_parse** %6
%22 = call %struct.katcl_parse* @get_dbase_katcp(%struct.katcp_dispatch* %20, %struct.katcl_parse* %21)
store %struct.katcl_parse* %22, %struct.katcl_parse** %7
%23 = load %struct.katcl_parse*, %struct.katcl_parse** %7
%24 = icmp eq %struct.katcl_parse* %23, null
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 -1, i32* %3
br label %33
26: ; preds = %19
%27 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%28 = load %struct.katcl_parse*, %struct.katcl_parse** %7
%29 = call i64 @append_parse_katcp(%struct.katcp_dispatch* %27, %struct.katcl_parse* %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 -1, i32* %3
br label %33
32: ; preds = %26
store i32 1, i32* %3
br label %33
33: ; preds = %32, %31, %25, %18, %10
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [7 x i8] c"useage\00"
define i32 @get_dbase_cmd_katcp(%struct.katcp_dispatch* %0, i32 %1) {
%3 = icmp slt i32 %1, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @log_message_katcp(%struct.katcp_dispatch* %0, i32 4, i32* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %16
6: ; preds = %2
%7 = tail call %struct.katcl_parse* @arg_parse_katcp(%struct.katcp_dispatch* %0)
%8 = icmp eq %struct.katcl_parse* %7, null
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call %struct.katcl_parse* @get_dbase_katcp(%struct.katcp_dispatch* %0, %struct.katcl_parse* %7)
%11 = icmp eq %struct.katcl_parse* %10, null
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i64 @append_parse_katcp(%struct.katcp_dispatch* %0, %struct.katcl_parse* %10)
%14 = icmp slt i64 %13, 0
%15 = select i1 %14, i32 -1, i32 1
br label %16
16: ; preds = %12, %9, %6, %4
%17 = phi i32 [ -1, %4 ], [ -1, %6 ], [ -1, %9 ], [ %15, %12 ]
ret i32 %17
}