#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 */
typedef int __u8;

/* Variables and functions */
int /*<<< orphan*/ invarg(char *, char *);
scalar_t__ matches(char *, char *);
int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp) {
  int argc = *argcp;
  char **argv = *argvp;
  if (matches(*argv, "transport") == 0)
    *mode = 0;
  else if (matches(*argv, "tunnel") == 0)
    *mode = 1;
  else
    invarg("\"MODE\" is invalid", *argv);
  *argcp = argc;
  *argvp = argv;
  return 0;
}


x86 assembly (clang, -O0):
<xfrm_mode_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xeaa(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    1174 <xfrm_mode_parse+0x54>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
jmp    11b8 <xfrm_mode_parse+0x98>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xe88(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    11a0 <xfrm_mode_parse+0x80>
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
jmp    11b3 <xfrm_mode_parse+0x93>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe63(%rip),%rdi
call   1040 <invarg@plt>
jmp    11b8 <xfrm_mode_parse+0x98>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfrm_mode_parse>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rsi),%r12d
mov    (%rdx),%rbp
mov    0x0(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     1173 <xfrm_mode_parse+0x53>
mov    0x0(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     117c <xfrm_mode_parse+0x5c>
mov    0x0(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1040 <invarg@plt>
jmp    1183 <xfrm_mode_parse+0x63>
movl   $0x0,(%r15)
jmp    1183 <xfrm_mode_parse+0x63>
movl   $0x1,(%r15)
mov    %r12d,(%rbx)
mov    %rbp,(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"transport\00"
@.str.1 = [7 x i8] c"tunnel\00"
@.str.2 = [18 x i8] c"\22MODE\22 is invalid\00"
define i32 @xfrm_mode_parse(i32* %0, i32* %1, i8*** %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8***
%7 = alloca i32
%8 = alloca i8**
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8*** %2, i8**** %6
%9 = load i32*, i32** %5
%10 = load i32, i32* %9
store i32 %10, i32* %7
%11 = load i8***, i8**** %6
%12 = load i8**, i8*** %11
store i8** %12, i8*** %8
%13 = load i8**, i8*** %8
%14 = load i8*, i8** %13
%15 = call i64 @matches(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = load i32*, i32** %4
store i32 0, i32* %18
br label %31
19: ; preds = %3
%20 = load i8**, i8*** %8
%21 = load i8*, i8** %20
%22 = call i64 @matches(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i32*, i32** %4
store i32 1, i32* %25
br label %30
26: ; preds = %19
%27 = load i8**, i8*** %8
%28 = load i8*, i8** %27
%29 = call i32 @invarg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %26, %24
br label %31
31: ; preds = %30, %17
%32 = load i32, i32* %7
%33 = load i32*, i32** %5
store i32 %32, i32* %33
%34 = load i8**, i8*** %8
%35 = load i8***, i8**** %6
store i8** %34, i8*** %35
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"transport\00"
@.str.1 = [7 x i8] c"tunnel\00"
@.str.2 = [18 x i8] c"\22MODE\22 is invalid\00"
define i32 @xfrm_mode_parse(i32* nocapture writeonly %0, i32* nocapture %1, i8*** nocapture %2) {
%4 = load i32, i32* %1
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = tail call i64 @matches(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %3
store i32 0, i32* %0
br label %18
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = tail call i64 @matches(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %0
br label %18
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = tail call i32 @invarg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %15, %9
store i32 %4, i32* %1
store i8** %5, i8*** %2
ret i32 0
}