#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 */
struct pcm {
  int dummy;
};

/* Variables and functions */
int open_alsa_write(struct pcm **, char *, int, int, float);
int open_wav_write(struct pcm **, char *, int, int, float);
int strlen(char *);
char *strstr(char *, char *);
int open_pcm_write(struct pcm **p, char *name, int rate, int channels,
                   float seconds) {
  if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name ||
      strstr(name, "default") == name)
    return open_alsa_write(p, name, rate, channels, seconds);
  if (strstr(name, ".wav") == (name + (strlen(name) - strlen(".wav"))))
    return open_wav_write(p, name, rate, channels, seconds);
  return 0;
}


x86 assembly (clang, -O0):
<open_pcm_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <strstr@plt>
cmp    -0x18(%rbp),%rax
je     11a9 <open_pcm_write+0x69>
mov    -0x18(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1060 <strstr@plt>
cmp    -0x18(%rbp),%rax
je     11a9 <open_pcm_write+0x69>
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <strstr@plt>
cmp    -0x18(%rbp),%rax
jne    11c9 <open_pcm_write+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
movss  -0x24(%rbp),%xmm0
call   1050 <open_alsa_write@plt>
mov    %eax,-0x4(%rbp)
jmp    1242 <open_pcm_write+0x102>
mov    -0x18(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
lea    0xe18(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    %eax,%esi
mov    -0x30(%rbp),%rax
sub    %esi,%edx
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jne    123b <open_pcm_write+0xfb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
movss  -0x24(%rbp),%xmm0
call   1040 <open_wav_write@plt>
mov    %eax,-0x4(%rbp)
jmp    1242 <open_pcm_write+0x102>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_pcm_write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xe8c(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <open_pcm_write+0xcc>
lea    0xe6b(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <open_pcm_write+0xcc>
lea    0xe4e(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <open_pcm_write+0xcc>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
lea    0xe18(%rip),%rdi
call   1040 <strlen@plt>
sub    %eax,%r13d
movslq %r13d,%rax
add    %rbx,%rax
cmp    %rax,%rbp
je     1241 <open_pcm_write+0xf1>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
movss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <open_alsa_write@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
movss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <open_wav_write@plt>

LLVM IR (-O0):
%struct.pcm = type { i32 }
@.str = [8 x i8] c"plughw:\00"
@.str.1 = [4 x i8] c"hw:\00"
@.str.2 = [8 x i8] c"default\00"
@.str.3 = [5 x i8] c".wav\00"
define i32 @open_pcm_write(%struct.pcm** %0, i8* %1, i32 %2, i32 %3, float %4) {
%6 = alloca i32
%7 = alloca %struct.pcm**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
store %struct.pcm** %0, %struct.pcm*** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store float %4, float* %11
%12 = load i8*, i8** %8
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %8
%15 = icmp eq i8* %13, %14
br i1 %15, label %26, label %16
16: ; preds = %5
%17 = load i8*, i8** %8
%18 = call i8* @strstr(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8*, i8** %8
%20 = icmp eq i8* %18, %19
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %8
%23 = call i8* @strstr(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%24 = load i8*, i8** %8
%25 = icmp eq i8* %23, %24
br i1 %25, label %26, label %33
26: ; preds = %21, %16, %5
%27 = load %struct.pcm**, %struct.pcm*** %7
%28 = load i8*, i8** %8
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = load float, float* %11
%32 = call i32 @open_alsa_write(%struct.pcm** %27, i8* %28, i32 %29, i32 %30, float %31)
store i32 %32, i32* %6
br label %52
33: ; preds = %21
%34 = load i8*, i8** %8
%35 = call i8* @strstr(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%36 = load i8*, i8** %8
%37 = load i8*, i8** %8
%38 = call i32 @strlen(i8* %37)
%39 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%40 = sub nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %36, i64 %41
%43 = icmp eq i8* %35, %42
br i1 %43, label %44, label %51
44: ; preds = %33
%45 = load %struct.pcm**, %struct.pcm*** %7
%46 = load i8*, i8** %8
%47 = load i32, i32* %9
%48 = load i32, i32* %10
%49 = load float, float* %11
%50 = call i32 @open_wav_write(%struct.pcm** %45, i8* %46, i32 %47, i32 %48, float %49)
store i32 %50, i32* %6
br label %52
51: ; preds = %33
store i32 0, i32* %6
br label %52
52: ; preds = %51, %44, %26
%53 = load i32, i32* %6
ret i32 %53
}

LLVM IR (-O2):
%struct.pcm = type { i32 }
@.str = [8 x i8] c"plughw:\00"
@.str.1 = [4 x i8] c"hw:\00"
@.str.2 = [8 x i8] c"default\00"
@.str.3 = [5 x i8] c".wav\00"
define i32 @open_pcm_write(%struct.pcm** %0, i8* %1, i32 %2, i32 %3, float %4) {
%6 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %5
%10 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13, %9, %5
%18 = tail call i32 @open_alsa_write(%struct.pcm** %0, i8* %1, i32 %2, i32 %3, float %4)
br label %29
19: ; preds = %13
%20 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%21 = tail call i32 @strlen(i8* %1)
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = sub nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %1, i64 %24
%26 = icmp eq i8* %20, %25
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = tail call i32 @open_wav_write(%struct.pcm** %0, i8* %1, i32 %2, i32 %3, float %4)
br label %29
29: ; preds = %19, %27, %17
%30 = phi i32 [ %18, %17 ], [ %28, %27 ], [ 0, %19 ]
ret i32 %30
}