#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*/ assert(unsigned int *);
unsigned int dhcpcd_reason_to_state1(char const *, int *);
void dhcpcd_reason_to_statetype(const char *reason, unsigned int *state,
                                unsigned int *type) {
  int isdhcp6;
  assert(state);
  assert(type);
  *state = dhcpcd_reason_to_state1(reason, &isdhcp6);
  switch (*state) {
  case 0:
  case 6:
  case 12:
  case 8:
  case 7:
  case 3:
    *type = 1;
    return;
  case 21:
    *type = 5;
    return;
  case 15:
    *type = 3;
    return;
  case 13:
    if (isdhcp6) {
      *type = 4;
      return;
    }
  }
  if (isdhcp6)
    *type = 6;
  else
    *type = 2;
}


x86 assembly (clang, -O0):
<dhcpcd_reason_to_statetype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <dhcpcd_reason_to_state1@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %rax,-0x28(%rbp)
sub    $0x15,%rax
ja     11ce <dhcpcd_reason_to_statetype+0xae>
mov    -0x28(%rbp),%rax
lea    0xe86(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11f1 <dhcpcd_reason_to_statetype+0xd1>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    11f1 <dhcpcd_reason_to_statetype+0xd1>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    11f1 <dhcpcd_reason_to_statetype+0xd1>
cmpl   $0x0,-0x1c(%rbp)
je     11c9 <dhcpcd_reason_to_statetype+0xa9>
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
jmp    11f1 <dhcpcd_reason_to_statetype+0xd1>
jmp    11ce <dhcpcd_reason_to_statetype+0xae>
cmpl   $0x0,-0x1c(%rbp)
je     11e7 <dhcpcd_reason_to_statetype+0xc7>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    11f1 <dhcpcd_reason_to_statetype+0xd1>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcpcd_reason_to_statetype>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <assert@plt>
mov    %r14,%rdi
call   1030 <assert@plt>
lea    0xc(%rsp),%rsi
mov    %r15,%rdi
call   1040 <dhcpcd_reason_to_state1@plt>
mov    %eax,(%rbx)
cmp    $0x15,%eax
ja     117a <dhcpcd_reason_to_statetype+0x5a>
mov    $0x1,%ecx
mov    %eax,%eax
lea    0xe9c(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
mov    %ecx,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
cmpl   $0x0,0xc(%rsp)
setne  %al
lea    0x2(,%rax,4),%ecx
jmp    116d <dhcpcd_reason_to_statetype+0x4d>
mov    $0x4,%ecx
cmpl   $0x0,0xc(%rsp)
jne    116d <dhcpcd_reason_to_statetype+0x4d>
mov    $0x2,%ecx
jmp    116d <dhcpcd_reason_to_statetype+0x4d>
mov    $0x3,%ecx
jmp    116d <dhcpcd_reason_to_statetype+0x4d>
mov    $0x5,%ecx
jmp    116d <dhcpcd_reason_to_statetype+0x4d>

LLVM IR (-O0):
define void @dhcpcd_reason_to_statetype(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %5
%9 = call i32 @assert(i32* %8)
%10 = load i32*, i32** %6
%11 = call i32 @assert(i32* %10)
%12 = load i8*, i8** %4
%13 = call i32 @dhcpcd_reason_to_state1(i8* %12, i32* %7)
%14 = load i32*, i32** %5
store i32 %13, i32* %14
%15 = load i32*, i32** %5
%16 = load i32, i32* %15
switch i32 %16, label %29 [
i32 0, label %17
i32 6, label %17
i32 12, label %17
i32 8, label %17
i32 7, label %17
i32 3, label %17
i32 21, label %19
i32 15, label %21
i32 13, label %23
]
17: ; preds = %3, %3, %3, %3, %3, %3
%18 = load i32*, i32** %6
store i32 1, i32* %18
br label %36
19: ; preds = %3
%20 = load i32*, i32** %6
store i32 5, i32* %20
br label %36
21: ; preds = %3
%22 = load i32*, i32** %6
store i32 3, i32* %22
br label %36
23: ; preds = %3
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32*, i32** %6
store i32 4, i32* %27
br label %36
28: ; preds = %23
br label %29
29: ; preds = %28, %3
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i32*, i32** %6
store i32 6, i32* %33
br label %36
34: ; preds = %29
%35 = load i32*, i32** %6
store i32 2, i32* %35
br label %36
36: ; preds = %17, %19, %21, %26, %34, %32
ret void
}

LLVM IR (-O2):
define void @dhcpcd_reason_to_statetype(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 @assert(i32* %1)
%7 = tail call i32 @assert(i32* %2)
%8 = call i32 @dhcpcd_reason_to_state1(i8* %0, i32* %4)
store i32 %8, i32* %1
switch i32 %8, label %9 [
i32 0, label %20
i32 6, label %20
i32 12, label %20
i32 8, label %20
i32 7, label %20
i32 3, label %20
i32 21, label %13
i32 15, label %14
i32 13, label %15
]
9: ; preds = %3
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 2, i32 6
br label %18
13: ; preds = %3
br label %20
14: ; preds = %3
br label %20
15: ; preds = %3
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %9, %15
%19 = phi i32 [ %12, %9 ], [ 2, %15 ]
br label %20
20: ; preds = %15, %3, %3, %3, %3, %3, %3, %18, %14, %13
%21 = phi i32 [ %19, %18 ], [ 3, %14 ], [ 5, %13 ], [ 1, %3 ], [ 1, %3 ], [ 1, %3 ], [ 1, %3 ], [ 1, %3 ], [ 1, %3 ], [ 4, %15 ]
store i32 %21, i32* %2
ret void
}