#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*/ audio_init();
int /*<<< orphan*/ sprintf(char *, char *, int);
void audio_getdevs(char *indevlist, int *nindevs, char *outdevlist,
                   int *noutdevs, int *canmulti, int maxndev, int devdescsize) {
  audio_init();
  {
    int i;
    *nindevs = *noutdevs = 3;
    for (i = 0; i < 3; i++) {
      sprintf(indevlist + i * devdescsize, "input device #%d", i + 1);
      sprintf(outdevlist + i * devdescsize, "output device #%d", i + 1);
    }
    *canmulti = 0;
  }
}


x86 assembly (clang, -O0):
<audio_getdevs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    $0x0,%al
call   1030 <audio_init@plt>
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    11c1 <audio_getdevs+0xa1>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%eax
imul   0x10(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x30(%rbp),%edx
add    $0x1,%edx
lea    0xe74(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%eax
imul   0x10(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x30(%rbp),%edx
add    $0x1,%edx
lea    0xe63(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1165 <audio_getdevs+0x45>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<audio_getdevs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
movslq 0x40(%rsp),%rbp
xor    %eax,%eax
call   1030 <audio_init@plt>
movl   $0x3,(%r12)
movl   $0x3,0x0(%r13)
lea    0xea3(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1040 <sprintf@plt>
lea    0xe9d(%rip),%r13
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1040 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1040 <sprintf@plt>
lea    (%r15,%rbp,1),%rdi
mov    %r13,%rsi
mov    $0x2,%edx
call   1040 <sprintf@plt>
lea    (%rbx,%rbp,2),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1040 <sprintf@plt>
lea    (%r15,%rbp,2),%rdi
mov    %r13,%rsi
mov    $0x3,%edx
call   1040 <sprintf@plt>
movl   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"input device #%d\00"
@.str.1 = [18 x i8] c"output device #%d\00"
define void @audio_getdevs(i8* %0, i32* %1, i8* %2, i32* %3, i32* %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %8
store i32* %1, i32** %9
store i8* %2, i8** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%16 = call i32 (...) @audio_init()
%17 = load i32*, i32** %11
store i32 3, i32* %17
%18 = load i32*, i32** %9
store i32 3, i32* %18
store i32 0, i32* %15
br label %19
19: ; preds = %41, %7
%20 = load i32, i32* %15
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %44
22: ; preds = %19
%23 = load i8*, i8** %8
%24 = load i32, i32* %15
%25 = load i32, i32* %14
%26 = mul nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %23, i64 %27
%29 = load i32, i32* %15
%30 = add nsw i32 %29, 1
%31 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %10
%33 = load i32, i32* %15
%34 = load i32, i32* %14
%35 = mul nsw i32 %33, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %32, i64 %36
%38 = load i32, i32* %15
%39 = add nsw i32 %38, 1
%40 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %22
%42 = load i32, i32* %15
%43 = add nsw i32 %42, 1
store i32 %43, i32* %15
br label %19
44: ; preds = %19
%45 = load i32*, i32** %12
store i32 0, i32* %45
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"input device #%d\00"
@.str.1 = [18 x i8] c"output device #%d\00"
define void @audio_getdevs(i8* nocapture writeonly %0, i32* nocapture writeonly %1, i8* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32 %5, i32 %6) {
%8 = tail call i32 (...) @audio_init()
store i32 3, i32* %3
store i32 3, i32* %1
%9 = sext i32 %6 to i64
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 1)
%11 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1)
%12 = getelementptr inbounds i8, i8* %0, i64 %9
%13 = tail call i32 @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = getelementptr inbounds i8, i8* %2, i64 %9
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 2)
%16 = shl nsw i64 %9, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = tail call i32 @sprintf(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 3)
%19 = getelementptr inbounds i8, i8* %2, i64 %16
%20 = tail call i32 @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 3)
store i32 0, i32* %4
ret void
}