#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 /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
char *format_hwmodes(int modes) {
  static char buf[12];
  if (modes <= 0)
    snprintf(buf, sizeof(buf), "unknown");
  else
    snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s",
             (modes & (1 << 0)) ? "a" : "", (modes & (1 << 1)) ? "b" : "",
             (modes & (1 << 2)) ? "g" : "", (modes & (1 << 3)) ? "n" : "",
             (modes & (1 << 4)) ? "ac" : "");
  return buf;
}


x86 assembly (clang, -O0):
<format_hwmodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1144 <format_hwmodes+0x34>
lea    0x2efd(%rip),%rdi
mov    $0xc,%esi
lea    0xec8(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11ee <format_hwmodes+0xde>
mov    -0x4(%rbp),%edx
and    $0x1,%edx
lea    0xec9(%rip),%rcx
lea    0xec1(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%rcx
mov    -0x4(%rbp),%edx
and    $0x2,%edx
lea    0xeae(%rip),%r8
lea    0xea8(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r8
mov    -0x4(%rbp),%edx
and    $0x4,%edx
lea    0xe93(%rip),%r9
lea    0xe8f(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r9
mov    -0x4(%rbp),%edx
and    $0x8,%edx
lea    0xe78(%rip),%r10
lea    0xe5d(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r10
mov    -0x4(%rbp),%esi
and    $0x10,%esi
lea    0xe5d(%rip),%rax
lea    0xe5b(%rip),%rdx
cmp    $0x0,%esi
cmovne %rdx,%rax
lea    0x2e57(%rip),%rdi
mov    $0xc,%esi
lea    0xe2a(%rip),%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2e34(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_hwmodes>:
push   %rax
test   %edi,%edi
jle    118b <format_hwmodes+0x7b>
test   $0x1,%dil
lea    0xefa(%rip),%rax
lea    0xef2(%rip),%rcx
cmove  %rax,%rcx
test   $0x2,%dil
lea    0xee5(%rip),%r8
cmove  %rax,%r8
test   $0x4,%dil
lea    0xed8(%rip),%r9
cmove  %rax,%r9
test   $0x8,%dil
lea    0xeb2(%rip),%r10
cmove  %rax,%r10
test   $0x10,%dil
lea    0xebc(%rip),%r11
cmove  %rax,%r11
lea    0x2ebb(%rip),%rdi
lea    0xe93(%rip),%rdx
mov    $0xc,%esi
xor    %eax,%eax
push   %r11
push   %r10
call   1030 <snprintf@plt>
add    $0x10,%rsp
jmp    11a5 <format_hwmodes+0x95>
lea    0x2e97(%rip),%rdi
lea    0xe67(%rip),%rdx
mov    $0xc,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2e7d(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@format_hwmodes.buf = internal global [12 x i8] zeroinitializer
@.str = [8 x i8] c"unknown\00"
@.str.1 = [17 x i8] c"802.11%s%s%s%s%s\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [2 x i8] c"g\00"
@.str.6 = [2 x i8] c"n\00"
@.str.7 = [3 x i8] c"ac\00"
define i8* @format_hwmodes(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sle i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_hwmodes.buf, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %34
7: ; preds = %1
%8 = load i32, i32* %2
%9 = and i32 %8, 1
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%13 = load i32, i32* %2
%14 = and i32 %13, 2
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%18 = load i32, i32* %2
%19 = and i32 %18, 4
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%23 = load i32, i32* %2
%24 = and i32 %23, 8
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%28 = load i32, i32* %2
%29 = and i32 %28, 16
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%33 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_hwmodes.buf, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %17, i8* %22, i8* %27, i8* %32)
br label %34
34: ; preds = %7, %5
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_hwmodes.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@format_hwmodes.buf = internal global [12 x i8] zeroinitializer
@.str = [8 x i8] c"unknown\00"
@.str.1 = [17 x i8] c"802.11%s%s%s%s%s\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [2 x i8] c"g\00"
@.str.6 = [2 x i8] c"n\00"
@.str.7 = [3 x i8] c"ac\00"
define i8* @format_hwmodes(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_hwmodes.buf, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %22
5: ; preds = %1
%6 = and i32 %0, 1
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%9 = and i32 %0, 2
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%12 = and i32 %0, 4
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%15 = and i32 %0, 8
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%18 = and i32 %0, 16
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0)
%21 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_hwmodes.buf, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %11, i8* %14, i8* %17, i8* %20)
br label %22
22: ; preds = %5, %3
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_hwmodes.buf, i64 0, i64 0)
}