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

/* Variables and functions */
scalar_t__ get_walnutname(char *, struct walnut_cmd_arg *);
scalar_t__ parse_help(int, char **, struct walnut_cmd_arg *);
int parse_walnutname(int argc, char **argv, struct walnut_cmd_arg *cmd) {
  int ret;
  if (parse_help(argc, argv, cmd) < 0)
    return -1;
  if (argc != 3)
    return -1;
  if (get_walnutname(argv[2], cmd))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<parse_walnutname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <parse_help@plt>
cmp    $0x0,%rax
jge    1159 <parse_walnutname+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <parse_walnutname+0x7d>
cmpl   $0x3,-0x8(%rbp)
je     116f <parse_walnutname+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <parse_walnutname+0x7d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <get_walnutname@plt>
cmp    $0x0,%rax
je     1196 <parse_walnutname+0x76>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <parse_walnutname+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_walnutname>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
call   1040 <parse_help@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
cmp    $0x3,%ebp
jne    1154 <parse_walnutname+0x34>
test   %rcx,%rcx
js     1154 <parse_walnutname+0x34>
mov    0x10(%rbx),%rdi
mov    %r14,%rsi
call   1030 <get_walnutname@plt>
neg    %rax
sbb    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.walnut_cmd_arg = type { i32 }
define i32 @parse_walnutname(i32 %0, i8** %1, %struct.walnut_cmd_arg* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca %struct.walnut_cmd_arg*
%8 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store %struct.walnut_cmd_arg* %2, %struct.walnut_cmd_arg** %7
%9 = load i32, i32* %5
%10 = load i8**, i8*** %6
%11 = load %struct.walnut_cmd_arg*, %struct.walnut_cmd_arg** %7
%12 = call i64 @parse_help(i32 %9, i8** %10, %struct.walnut_cmd_arg* %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %28
15: ; preds = %3
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 -1, i32* %4
br label %28
19: ; preds = %15
%20 = load i8**, i8*** %6
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = load %struct.walnut_cmd_arg*, %struct.walnut_cmd_arg** %7
%24 = call i64 @get_walnutname(i8* %22, %struct.walnut_cmd_arg* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 -1, i32* %4
br label %28
27: ; preds = %19
store i32 0, i32* %4
br label %28
28: ; preds = %27, %26, %18, %14
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
%struct.walnut_cmd_arg = type { i32 }
define i32 @parse_walnutname(i32 %0, i8** %1, %struct.walnut_cmd_arg* %2) {
%4 = tail call i64 @parse_help(i32 %0, i8** %1, %struct.walnut_cmd_arg* %2)
%5 = icmp sgt i64 %4, -1
%6 = icmp eq i32 %0, 3
%7 = and i1 %6, %5
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i64 @get_walnutname(i8* %10, %struct.walnut_cmd_arg* %2)
%12 = icmp ne i64 %11, 0
%13 = sext i1 %12 to i32
br label %14
14: ; preds = %8, %3
%15 = phi i32 [ -1, %3 ], [ %13, %8 ]
ret i32 %15
}