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

/* Variables and functions */
int /*<<< orphan*/ NEXT_ARG();
int parse_u16(int *, char ***, struct tc_u32_sel *, int, int);
scalar_t__ strcmp(char *, char *);
int parse_udp(int *argc_p, char ***argv_p, struct tc_u32_sel *sel) {
  int res = -1;
  int argc = *argc_p;
  char **argv = *argv_p;
  if (argc < 2)
    return -1;
  if (strcmp(*argv, "src") == 0) {
    NEXT_ARG();
    res = parse_u16(&argc, &argv, sel, 0, -1);
    goto done;
  }
  if (strcmp(*argv, "dst") == 0) {
    NEXT_ARG();
    res = parse_u16(&argc, &argv, sel, 2, -1);
    goto done;
  }
  return -1;
done:
  *argc_p = argc;
  *argv_p = argv;
  return res;
}


x86 assembly (clang, -O0):
<parse_udp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x2,-0x28(%rbp)
jge    1175 <parse_udp+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <parse_udp+0xf8>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <parse_udp+0x8a>
mov    $0x0,%al
call   1050 <NEXT_ARG@plt>
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %ecx,%ecx
mov    $0xffffffff,%r8d
call   1030 <parse_u16@plt>
mov    %eax,-0x24(%rbp)
jmp    120e <parse_udp+0xde>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xe3c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1202 <parse_udp+0xd2>
mov    $0x0,%al
call   1050 <NEXT_ARG@plt>
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x2,%ecx
mov    $0xffffffff,%r8d
call   1030 <parse_u16@plt>
mov    %eax,-0x24(%rbp)
jmp    120e <parse_udp+0xde>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <parse_udp+0xf8>
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_udp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%eax
mov    %eax,0x4(%rsp)
mov    (%rsi),%rbx
mov    %rbx,0x8(%rsp)
mov    $0xffffffff,%ebp
cmp    $0x2,%eax
jl     11c1 <parse_udp+0x91>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rbx),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     118c <parse_udp+0x5c>
mov    (%rbx),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11c1 <parse_udp+0x91>
mov    $0x2,%ebp
jmp    118e <parse_udp+0x5e>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <NEXT_ARG@plt>
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    $0xffffffff,%r8d
call   1030 <parse_u16@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%eax
mov    %eax,(%r12)
mov    0x8(%rsp),%rax
mov    %rax,(%r14)
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.tc_u32_sel = type { i32 }
@.str = [4 x i8] c"src\00"
@.str.1 = [4 x i8] c"dst\00"
define i32 @parse_udp(i32* nocapture %0, i8*** nocapture %1, %struct.tc_u32_sel* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* %0
store i32 %7, i32* %4
%8 = bitcast i8*** %5 to i8*
%9 = load i8**, i8*** %1
store i8** %9, i8*** %5
%10 = icmp slt i32 %7, 2
br i1 %10, label %25, label %11
11: ; preds = %3
%12 = load i8*, i8** %9
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i8*, i8** %9
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15, %11
%20 = phi i32 [ 0, %11 ], [ 2, %15 ]
%21 = tail call i32 (...) @NEXT_ARG()
%22 = call i32 @parse_u16(i32* %4, i8*** %5, %struct.tc_u32_sel* %2, i32 %20, i32 -1)
%23 = load i32, i32* %4
store i32 %23, i32* %0
%24 = load i8**, i8*** %5
store i8** %24, i8*** %1
br label %25
25: ; preds = %15, %3, %19
%26 = phi i32 [ %22, %19 ], [ -1, %3 ], [ -1, %15 ]
ret i32 %26
}