#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 *, size_t, char *, ...);
void nchan_format(char *buf, size_t buflen, int nchan) {
  if (nchan == 1)
    snprintf(buf, buflen, "mono");
  else if (nchan == 2)
    snprintf(buf, buflen, "stereo");
  else
    snprintf(buf, buflen, "%d channels", nchan);
}


x86 assembly (clang, -O0):
<nchan_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1148 <nchan_format+0x38>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xec4(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    118b <nchan_format+0x7b>
cmpl   $0x2,-0x14(%rbp)
jne    116d <nchan_format+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xea4(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1186 <nchan_format+0x76>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%ecx
lea    0xe8d(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    118b <nchan_format+0x7b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nchan_format>:
cmp    $0x2,%edx
je     112a <nchan_format+0x1a>
mov    %edx,%ecx
cmp    $0x1,%edx
jne    1138 <nchan_format+0x28>
lea    0xedd(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
lea    0xed4(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
lea    0xecd(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"mono\00"
@.str.1 = [7 x i8] c"stereo\00"
@.str.2 = [12 x i8] c"%d channels\00"
define void @nchan_format(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i64, i64* %5
%12 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %10, i64 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %26
13: ; preds = %3
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i64, i64* %5
%19 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %17, i64 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %25
20: ; preds = %13
%21 = load i8*, i8** %4
%22 = load i64, i64* %5
%23 = load i32, i32* %6
%24 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %21, i64 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %20, %16
br label %26
26: ; preds = %25, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"mono\00"
@.str.1 = [7 x i8] c"stereo\00"
@.str.2 = [12 x i8] c"%d channels\00"
define void @nchan_format(i8* nocapture writeonly %0, i64 %1, i32 %2) {
switch i32 %2, label %8 [
i32 1, label %4
i32 2, label %6
]
4: ; preds = %3
%5 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %10
6: ; preds = %3
%7 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %3
%9 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %10
10: ; preds = %6, %8, %4
ret void
}