#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 */
struct katcl_parse *arg_parse_katcp(struct katcp_dispatch *);
int /*<<< orphan*/ log_message_katcp(struct katcp_dispatch *, int,
                                     int /*<<< orphan*/ *, char *);
scalar_t__ set_dbase_katcp(struct katcp_dispatch *, struct katcl_parse *);
int set_dbase_cmd_katcp(struct katcp_dispatch *d, int argc) {
  struct katcl_parse *p;
  if (argc < 3) {
    log_message_katcp(d, 4, NULL, "usage");
    return (-1);
  }
  p = arg_parse_katcp(d);
  if (p == NULL)
    return (-1);
  if (set_dbase_katcp(d, p) < 0)
    return (-1);
  return 0;
}


x86 assembly (clang, -O0):
<set_dbase_cmd_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    116e <set_dbase_cmd_katcp+0x3e>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
xor    %eax,%eax
mov    %eax,%edx
lea    0xea3(%rip),%rcx
call   1050 <log_message_katcp@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <set_dbase_cmd_katcp+0x8c>
mov    -0x10(%rbp),%rdi
call   1030 <arg_parse_katcp@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1192 <set_dbase_cmd_katcp+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <set_dbase_cmd_katcp+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <set_dbase_katcp@plt>
cmp    $0x0,%rax
jge    11b5 <set_dbase_cmd_katcp+0x85>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <set_dbase_cmd_katcp+0x8c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dbase_cmd_katcp>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x2,%esi
jg     1151 <set_dbase_cmd_katcp+0x21>
lea    0xec0(%rip),%rcx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1050 <log_message_katcp@plt>
jmp    116f <set_dbase_cmd_katcp+0x3f>
mov    %rbx,%rdi
call   1030 <arg_parse_katcp@plt>
test   %rax,%rax
je     116f <set_dbase_cmd_katcp+0x3f>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <set_dbase_katcp@plt>
sar    $0x3f,%rax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [6 x i8] c"usage\00"
define i32 @set_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*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%11 = call i32 @log_message_katcp(%struct.katcp_dispatch* %10, i32 4, i32* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %25
12: ; preds = %2
%13 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%14 = call %struct.katcl_parse* @arg_parse_katcp(%struct.katcp_dispatch* %13)
store %struct.katcl_parse* %14, %struct.katcl_parse** %6
%15 = load %struct.katcl_parse*, %struct.katcl_parse** %6
%16 = icmp eq %struct.katcl_parse* %15, null
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -1, i32* %3
br label %25
18: ; preds = %12
%19 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%20 = load %struct.katcl_parse*, %struct.katcl_parse** %6
%21 = call i64 @set_dbase_katcp(%struct.katcp_dispatch* %19, %struct.katcl_parse* %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %3
br label %25
24: ; preds = %18
store i32 0, i32* %3
br label %25
25: ; preds = %24, %23, %17, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [6 x i8] c"usage\00"
define i32 @set_dbase_cmd_katcp(%struct.katcp_dispatch* %0, i32 %1) {
%3 = icmp slt i32 %1, 3
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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %13
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 %13, label %9
9: ; preds = %6
%10 = tail call i64 @set_dbase_katcp(%struct.katcp_dispatch* %0, %struct.katcl_parse* %7)
%11 = ashr i64 %10, 63
%12 = trunc i64 %11 to i32
br label %13
13: ; preds = %9, %6, %4
%14 = phi i32 [ -1, %4 ], [ -1, %6 ], [ %12, %9 ]
ret i32 %14
}