#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 uint16_t;
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
const char *mv6_dev_str(uint16_t dev) {
  static char str[32];
  if (dev < 0xf)
    snprintf(str, sizeof(str), "phy:%d", dev);
  else if (dev == 0xf)
    return "serdes";
  else if (dev)
    snprintf(str, sizeof(str), "port:%d", dev - 0x10);
  else if (dev == 0x1b)
    return "global:1";
  else if (dev == 0x1c)
    return "global:2";
  else if (dev == 0x1d)
    return "global:3";
  else
    snprintf(str, sizeof(str), "port:RESERVED(%#.2x)", dev);
  return str;
}


x86 assembly (clang, -O0):
<mv6_dev_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0xf,-0xc(%rbp)
jge    1145 <mv6_dev_str+0x35>
mov    -0xc(%rbp),%ecx
lea    0x2f11(%rip),%rdi
mov    $0x20,%esi
lea    0xec5(%rip),%rdx
call   1030 <snprintf@plt>
jmp    120e <mv6_dev_str+0xfe>
cmpl   $0xf,-0xc(%rbp)
jne    115f <mv6_dev_str+0x4f>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1219 <mv6_dev_str+0x109>
cmpl   $0x0,-0xc(%rbp)
je     118c <mv6_dev_str+0x7c>
mov    -0xc(%rbp),%ecx
sub    $0x10,%ecx
lea    0x2eca(%rip),%rdi
mov    $0x20,%esi
lea    0xe8c(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1204 <mv6_dev_str+0xf4>
cmpl   $0x1b,-0xc(%rbp)
jne    11a6 <mv6_dev_str+0x96>
lea    0xe79(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1219 <mv6_dev_str+0x109>
cmpl   $0x1c,-0xc(%rbp)
jne    11c0 <mv6_dev_str+0xb0>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1219 <mv6_dev_str+0x109>
cmpl   $0x1d,-0xc(%rbp)
jne    11da <mv6_dev_str+0xca>
lea    0xe57(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1219 <mv6_dev_str+0x109>
mov    -0xc(%rbp),%ecx
lea    0x2e5c(%rip),%rdi
mov    $0x20,%esi
lea    0xe41(%rip),%rdx
call   1030 <snprintf@plt>
jmp    11fa <mv6_dev_str+0xea>
jmp    11ff <mv6_dev_str+0xef>
jmp    1204 <mv6_dev_str+0xf4>
jmp    1209 <mv6_dev_str+0xf9>
jmp    120e <mv6_dev_str+0xfe>
lea    0x2e2b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mv6_dev_str>:
push   %rbx
mov    %edi,%ecx
cmp    $0xe,%edi
jg     1128 <mv6_dev_str+0x18>
lea    0x2f21(%rip),%rbx
lea    0xeda(%rip),%rdx
jmp    1147 <mv6_dev_str+0x37>
cmp    $0xf,%ecx
jne    1136 <mv6_dev_str+0x26>
lea    0xed3(%rip),%rbx
jmp    1154 <mv6_dev_str+0x44>
add    $0xfffffff0,%ecx
lea    0x2f00(%rip),%rbx
lea    0xec7(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@mv6_dev_str.str = internal global [32 x i8] zeroinitializer
@.str = [7 x i8] c"phy:%d\00"
@.str.1 = [7 x i8] c"serdes\00"
@.str.2 = [8 x i8] c"port:%d\00"
@.str.3 = [9 x i8] c"global:1\00"
@.str.4 = [9 x i8] c"global:2\00"
@.str.5 = [9 x i8] c"global:3\00"
@.str.6 = [21 x i8] c"port:RESERVED(%#.2x)\00"
define i8* @mv6_dev_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 15
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %3
%8 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %40
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 15
br i1 %11, label %12, label %13
12: ; preds = %9
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %41
13: ; preds = %9
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 16
%19 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %38
20: ; preds = %13
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 27
br i1 %22, label %23, label %24
23: ; preds = %20
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %41
24: ; preds = %20
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 28
br i1 %26, label %27, label %28
27: ; preds = %24
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %41
28: ; preds = %24
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 29
br i1 %30, label %31, label %32
31: ; preds = %28
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %41
32: ; preds = %28
%33 = load i32, i32* %3
%34 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37, %16
br label %39
39: ; preds = %38
br label %40
40: ; preds = %39, %6
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), i8** %2
br label %41
41: ; preds = %40, %31, %27, %23, %12
%42 = load i8*, i8** %2
ret i8* %42
}

LLVM IR (-O2):
@mv6_dev_str.str = internal global [32 x i8] zeroinitializer
@.str = [7 x i8] c"phy:%d\00"
@.str.1 = [7 x i8] c"serdes\00"
@.str.2 = [8 x i8] c"port:%d\00"
define i8* @mv6_dev_str(i32 %0) {
%2 = icmp slt i32 %0, 15
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %10
5: ; preds = %1
%6 = icmp eq i32 %0, 15
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = add nsw i32 %0, -16
%9 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %3, %7, %5
%11 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), %7 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_dev_str.str, i64 0, i64 0), %3 ]
ret i8* %11
}