#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*/ snprintf(char *, int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void iw_print_pm_mode(char *buffer, int buflen, int flags) {
  if (buflen < 28) {
    snprintf(buffer, buflen, "<too big>");
    return;
  }
  switch (flags & 0x0F00) {
  case 0x0100:
    strcpy(buffer, "mode:Unicast only received");
    break;
  case 0x0200:
    strcpy(buffer, "mode:Multicast only received");
    break;
  case 0x0300:
    strcpy(buffer, "mode:All packets received");
    break;
  case 0x0400:
    strcpy(buffer, "mode:Force sending");
    break;
  case 0x0800:
    strcpy(buffer, "mode:Repeat multicasts");
    break;
  default:
    strcpy(buffer, "");
    break;
  }
}


x86 assembly (clang, -O0):
<iw_print_pm_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1c,-0xc(%rbp)
jge    1154 <iw_print_pm_mode+0x34>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xeb6(%rip),%rdx
call   1040 <snprintf@plt>
jmp    1234 <iw_print_pm_mode+0x114>
mov    -0x10(%rbp),%eax
and    $0xf00,%eax
mov    %eax,-0x14(%rbp)
sub    $0x100,%eax
je     11bb <iw_print_pm_mode+0x9b>
jmp    116f <iw_print_pm_mode+0x4f>
mov    -0x14(%rbp),%eax
sub    $0x200,%eax
je     11d0 <iw_print_pm_mode+0xb0>
jmp    1182 <iw_print_pm_mode+0x62>
mov    -0x14(%rbp),%eax
sub    $0x300,%eax
je     11e5 <iw_print_pm_mode+0xc5>
jmp    1195 <iw_print_pm_mode+0x75>
mov    -0x14(%rbp),%eax
sub    $0x400,%eax
je     11fa <iw_print_pm_mode+0xda>
jmp    11a8 <iw_print_pm_mode+0x88>
mov    -0x14(%rbp),%eax
sub    $0x800,%eax
je     120f <iw_print_pm_mode+0xef>
jmp    1224 <iw_print_pm_mode+0x104>
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1234 <iw_print_pm_mode+0x114>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1234 <iw_print_pm_mode+0x114>
mov    -0x8(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1234 <iw_print_pm_mode+0x114>
mov    -0x8(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1234 <iw_print_pm_mode+0x114>
mov    -0x8(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1234 <iw_print_pm_mode+0x114>
mov    -0x8(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iw_print_pm_mode>:
cmp    $0x1b,%esi
jg     1131 <iw_print_pm_mode+0x11>
lea    0xef4(%rip),%rdx
jmp    1040 <snprintf@plt>
and    $0xf00,%edx
add    $0xffffff00,%edx
shr    $0x8,%edx
cmp    $0x7,%edx
ja     1185 <iw_print_pm_mode+0x65>
lea    0xeb4(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xece(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xedd(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xeee(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xefc(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xe9d(%rip),%rsi
jmp    1030 <strcpy@plt>
lea    0xef7(%rip),%rsi
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"<too big>\00"
@.str.1 = [27 x i8] c"mode:Unicast only received\00"
@.str.2 = [29 x i8] c"mode:Multicast only received\00"
@.str.3 = [26 x i8] c"mode:All packets received\00"
@.str.4 = [19 x i8] c"mode:Force sending\00"
@.str.5 = [23 x i8] c"mode:Repeat multicasts\00"
@.str.6 = [1 x i8] zeroinitializer
define void @iw_print_pm_mode(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 28
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = call i32 @snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %34
13: ; preds = %3
%14 = load i32, i32* %6
%15 = and i32 %14, 3840
switch i32 %15, label %31 [
i32 256, label %16
i32 512, label %19
i32 768, label %22
i32 1024, label %25
i32 2048, label %28
]
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %34
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %34
22: ; preds = %13
%23 = load i8*, i8** %4
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %34
25: ; preds = %13
%26 = load i8*, i8** %4
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %34
28: ; preds = %13
%29 = load i8*, i8** %4
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %34
31: ; preds = %13
%32 = load i8*, i8** %4
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %34
34: ; preds = %9, %31, %28, %25, %22, %19, %16
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"<too big>\00"
@.str.1 = [27 x i8] c"mode:Unicast only received\00"
@.str.2 = [29 x i8] c"mode:Multicast only received\00"
@.str.3 = [26 x i8] c"mode:All packets received\00"
@.str.4 = [19 x i8] c"mode:Force sending\00"
@.str.5 = [23 x i8] c"mode:Repeat multicasts\00"
@.str.6 = [1 x i8] zeroinitializer
define void @iw_print_pm_mode(i8* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 28
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %23
7: ; preds = %3
%8 = and i32 %2, 3840
%9 = add nsw i32 %8, -256
%10 = lshr exact i32 %9, 8
switch i32 %10, label %21 [
i32 0, label %11
i32 1, label %13
i32 2, label %15
i32 3, label %17
i32 7, label %19
]
11: ; preds = %7
%12 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %23
13: ; preds = %7
%14 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %23
15: ; preds = %7
%16 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %23
17: ; preds = %7
%18 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %23
19: ; preds = %7
%20 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %23
21: ; preds = %7
%22 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %23
23: ; preds = %5, %21, %19, %17, %15, %13, %11
ret void
}