#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ match(char **, char **, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int strlen(char *);
void parse_target_dev(char *input, char **WWN, char **SP, char **SG_NAME,
                      char **ARGS, char **FSTYPE) {
  int len;
  int cur;
  char *pos, *sep, *val;
  *WWN = NULL;
  if (input == NULL) {
    return;
  }
  len = strlen(input);
  cur = 0;
  pos = input;
  while (cur < len) {
    sep = strchr(pos, ',');
    if (sep == NULL)
      cur = len;
    else
      *sep = 0;
    val = NULL;
    if (match(&pos, &val, "WWN")) {
      *WWN = val;
    } else if (match(&pos, &val, "SP")) {
      *SP = val;
    } else if (match(&pos, &val, "SG_NAME")) {
      *SG_NAME = val;
    } else if (match(&pos, &val, "ARGS")) {
      *ARGS = val;
    } else if (match(&pos, &val, "FSTYPE")) {
      *FSTYPE = val;
    } else {
      fprintf(stderr, "Failed parsing: %s\n", pos);
      exit(1);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<parse_target_dev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    118b <parse_target_dev+0x3b>
jmp    1310 <parse_target_dev+0x1c0>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    130b <parse_target_dev+0x1bb>
mov    -0x40(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11da <parse_target_dev+0x8a>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11e1 <parse_target_dev+0x91>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
movq   $0x0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    0xe08(%rip),%rdx
call   1060 <match@plt>
cmp    $0x0,%rax
je     1217 <parse_target_dev+0xc7>
mov    -0x50(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1306 <parse_target_dev+0x1b6>
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    0xdde(%rip),%rdx
call   1060 <match@plt>
cmp    $0x0,%rax
je     1245 <parse_target_dev+0xf5>
mov    -0x50(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1301 <parse_target_dev+0x1b1>
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    0xdb3(%rip),%rdx
call   1060 <match@plt>
cmp    $0x0,%rax
je     1273 <parse_target_dev+0x123>
mov    -0x50(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    12fc <parse_target_dev+0x1ac>
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    0xd8d(%rip),%rdx
call   1060 <match@plt>
cmp    $0x0,%rax
je     12a1 <parse_target_dev+0x151>
mov    -0x50(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    12f7 <parse_target_dev+0x1a7>
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    0xd64(%rip),%rdx
call   1060 <match@plt>
cmp    $0x0,%rax
je     12cf <parse_target_dev+0x17f>
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
jmp    12f2 <parse_target_dev+0x1a2>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
lea    0xd38(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    12f7 <parse_target_dev+0x1a7>
jmp    12fc <parse_target_dev+0x1ac>
jmp    1301 <parse_target_dev+0x1b1>
jmp    1306 <parse_target_dev+0x1b6>
jmp    11a6 <parse_target_dev+0x56>
jmp    1310 <parse_target_dev+0x1c0>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_target_dev>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x18(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,0x28(%rsp)
mov    %rsi,0x30(%rsp)
movq   $0x0,(%rsi)
test   %rdi,%rdi
je     12a4 <parse_target_dev+0x154>
mov    %rdi,%r13
call   1030 <strlen@plt>
mov    %r13,0x8(%rsp)
test   %eax,%eax
jle    12a4 <parse_target_dev+0x154>
mov    %eax,%r14d
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
mov    %rsp,%r12
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %r14d,%ebp
test   %rax,%rax
je     11ca <parse_target_dev+0x7a>
movb   $0x0,(%rax)
mov    %ebx,%ebp
movq   $0x0,(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
lea    0xe21(%rip),%rdx
call   1060 <match@plt>
test   %rax,%rax
je     1200 <parse_target_dev+0xb0>
mov    (%rsp),%rax
mov    0x30(%rsp),%rcx
jmp    1290 <parse_target_dev+0x140>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
lea    0xdf7(%rip),%rdx
call   1060 <match@plt>
test   %rax,%rax
je     1222 <parse_target_dev+0xd2>
mov    (%rsp),%rax
mov    0x28(%rsp),%rcx
jmp    1290 <parse_target_dev+0x140>
mov    %r15,%rdi
mov    %r12,%rsi
lea    0xdd8(%rip),%rdx
call   1060 <match@plt>
test   %rax,%rax
je     1244 <parse_target_dev+0xf4>
mov    (%rsp),%rax
mov    0x20(%rsp),%rcx
jmp    1290 <parse_target_dev+0x140>
mov    %r15,%rdi
mov    %r12,%rsi
lea    0xdbe(%rip),%rdx
call   1060 <match@plt>
test   %rax,%rax
je     1266 <parse_target_dev+0x116>
mov    (%rsp),%rax
mov    0x18(%rsp),%rcx
jmp    1290 <parse_target_dev+0x140>
mov    %r15,%rdi
mov    %r12,%rsi
lea    0xda1(%rip),%rdx
call   1060 <match@plt>
test   %rax,%rax
je     12b3 <parse_target_dev+0x163>
mov    (%rsp),%rax
mov    0x10(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
mov    %rax,(%rcx)
cmp    %r14d,%ebp
jge    12a4 <parse_target_dev+0x154>
mov    0x8(%rsp),%r13
mov    %ebp,%ebx
jmp    11b0 <parse_target_dev+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rdx
lea    0xd53(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"WWN\00"
@.str.1 = [3 x i8] c"SP\00"
@.str.2 = [8 x i8] c"SG_NAME\00"
@.str.3 = [5 x i8] c"ARGS\00"
@.str.4 = [7 x i8] c"FSTYPE\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"Failed parsing: %s\0A\00"
define void @parse_target_dev(i8* %0, i8** %1, i8** %2, i8** %3, i8** %4, i8** %5) {
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
store i8* %0, i8** %7
store i8** %1, i8*** %8
store i8** %2, i8*** %9
store i8** %3, i8*** %10
store i8** %4, i8*** %11
store i8** %5, i8*** %12
%18 = load i8**, i8*** %8
store i8* null, i8** %18
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %6
br label %80
22: ; preds = %6
%23 = load i8*, i8** %7
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %13
store i32 0, i32* %14
%25 = load i8*, i8** %7
store i8* %25, i8** %15
br label %26
26: ; preds = %78, %22
%27 = load i32, i32* %14
%28 = load i32, i32* %13
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %79
30: ; preds = %26
%31 = load i8*, i8** %15
%32 = call i8* @strchr(i8* %31, i8 signext 44)
store i8* %32, i8** %16
%33 = load i8*, i8** %16
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i32, i32* %13
store i32 %36, i32* %14
br label %39
37: ; preds = %30
%38 = load i8*, i8** %16
store i8 0, i8* %38
br label %39
39: ; preds = %37, %35
store i8* null, i8** %17
%40 = call i64 @match(i8** %15, i8** %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i8*, i8** %17
%44 = load i8**, i8*** %8
store i8* %43, i8** %44
br label %78
45: ; preds = %39
%46 = call i64 @match(i8** %15, i8** %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i8*, i8** %17
%50 = load i8**, i8*** %9
store i8* %49, i8** %50
br label %77
51: ; preds = %45
%52 = call i64 @match(i8** %15, i8** %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i8*, i8** %17
%56 = load i8**, i8*** %10
store i8* %55, i8** %56
br label %76
57: ; preds = %51
%58 = call i64 @match(i8** %15, i8** %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i8*, i8** %17
%62 = load i8**, i8*** %11
store i8* %61, i8** %62
br label %75
63: ; preds = %57
%64 = call i64 @match(i8** %15, i8** %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i8*, i8** %17
%68 = load i8**, i8*** %12
store i8* %67, i8** %68
br label %74
69: ; preds = %63
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %15
%72 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %71)
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %66
br label %75
75: ; preds = %74, %60
br label %76
76: ; preds = %75, %54
br label %77
77: ; preds = %76, %48
br label %78
78: ; preds = %77, %42
br label %26
79: ; preds = %26
br label %80
80: ; preds = %79, %21
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"WWN\00"
@.str.1 = [3 x i8] c"SP\00"
@.str.2 = [8 x i8] c"SG_NAME\00"
@.str.3 = [5 x i8] c"ARGS\00"
@.str.4 = [7 x i8] c"FSTYPE\00"
@stderr = global i32 0
@.str.5 = [20 x i8] c"Failed parsing: %s\0A\00"
define void @parse_target_dev(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3, i8** nocapture writeonly %4, i8** nocapture writeonly %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = bitcast i8** %7 to i8*
%10 = bitcast i8** %8 to i8*
store i8* null, i8** %1
%11 = icmp eq i8* %0, null
br i1 %11, label %56, label %12
12: ; preds = %6
%13 = tail call i32 @strlen(i8* %0)
store i8* %0, i8** %7
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %56
15: ; preds = %12, %54
%16 = phi i8* [ %55, %54 ], [ %0, %12 ]
%17 = phi i32 [ %22, %54 ], [ 0, %12 ]
%18 = call i8* @strchr(i8* dereferenceable(1) %16, i8 signext 44)
%19 = icmp eq i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %15
store i8 0, i8* %18
br label %21
21: ; preds = %15, %20
%22 = phi i32 [ %17, %20 ], [ %13, %15 ]
store i8* null, i8** %8
%23 = call i64 @match(i8** %7, i8** %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = load i8*, i8** %8
store i8* %26, i8** %1
br label %52
27: ; preds = %21
%28 = call i64 @match(i8** %7, i8** %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = load i8*, i8** %8
store i8* %31, i8** %2
br label %52
32: ; preds = %27
%33 = call i64 @match(i8** %7, i8** %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = load i8*, i8** %8
store i8* %36, i8** %3
br label %52
37: ; preds = %32
%38 = call i64 @match(i8** %7, i8** %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = load i8*, i8** %8
store i8* %41, i8** %4
br label %52
42: ; preds = %37
%43 = call i64 @match(i8** %7, i8** %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = load i8*, i8** %8
store i8* %46, i8** %5
br label %52
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %7
%50 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %30, %40, %45, %35, %25
%53 = icmp slt i32 %22, %13
br i1 %53, label %54, label %56
54: ; preds = %52
%55 = load i8*, i8** %7
br label %15
56: ; preds = %52, %12, %6
ret void
}