#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_read(struct pcm **, char *);
int open_wav_read(struct pcm **, char *);
int strlen(char *);
char *strstr(char *, char *);
int open_pcm_read(struct pcm **p, char *name) {
  if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name ||
      strstr(name, "default") == name)
    return open_alsa_read(p, name);
  if (strstr(name, ".wav") == (name + (strlen(name) - strlen(".wav"))))
    return open_wav_read(p, name);
  return 0;
}


x86 assembly (clang, -O0):
<open_pcm_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <strstr@plt>
cmp    -0x18(%rbp),%rax
je     119e <open_pcm_read+0x5e>
mov    -0x18(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <strstr@plt>
cmp    -0x18(%rbp),%rax
je     119e <open_pcm_read+0x5e>
mov    -0x18(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1060 <strstr@plt>
cmp    -0x18(%rbp),%rax
jne    11b3 <open_pcm_read+0x73>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <open_alsa_read@plt>
mov    %eax,-0x4(%rbp)
jmp    1221 <open_pcm_read+0xe1>
mov    -0x18(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    0xe2e(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    %eax,%esi
mov    -0x20(%rbp),%rax
sub    %esi,%edx
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jne    121a <open_pcm_read+0xda>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <open_wav_read@plt>
mov    %eax,-0x4(%rbp)
jmp    1221 <open_pcm_read+0xe1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_pcm_read>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe9b(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1204 <open_pcm_read+0xb4>
lea    0xe7a(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1204 <open_pcm_read+0xb4>
lea    0xe5d(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1204 <open_pcm_read+0xb4>
lea    0xe44(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebp
movslq %ebp,%rax
add    %r15,%rax
cmp    %rax,%rbx
je     1217 <open_pcm_read+0xc7>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <open_alsa_read@plt>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <open_wav_read@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_read(%struct.pcm** %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.pcm**
%5 = alloca i8*
store %struct.pcm** %0, %struct.pcm*** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i8* @strstr(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %5
%9 = icmp eq i8* %7, %8
br i1 %9, label %20, label %10
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %5
%14 = icmp eq i8* %12, %13
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = call i8* @strstr(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %5
%19 = icmp eq i8* %17, %18
br i1 %19, label %20, label %24
20: ; preds = %15, %10, %2
%21 = load %struct.pcm**, %struct.pcm*** %4
%22 = load i8*, i8** %5
%23 = call i32 @open_alsa_read(%struct.pcm** %21, i8* %22)
store i32 %23, i32* %3
br label %40
24: ; preds = %15
%25 = load i8*, i8** %5
%26 = call i8* @strstr(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%27 = load i8*, i8** %5
%28 = load i8*, i8** %5
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%31 = sub nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %27, i64 %32
%34 = icmp eq i8* %26, %33
br i1 %34, label %35, label %39
35: ; preds = %24
%36 = load %struct.pcm**, %struct.pcm*** %4
%37 = load i8*, i8** %5
%38 = call i32 @open_wav_read(%struct.pcm** %36, i8* %37)
store i32 %38, i32* %3
br label %40
39: ; preds = %24
store i32 0, i32* %3
br label %40
40: ; preds = %39, %35, %20
%41 = load i32, i32* %3
ret i32 %41
}

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_read(%struct.pcm** %0, i8* %1) {
%3 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = 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))
%8 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = 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))
%12 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10, %6, %2
%15 = tail call i32 @open_alsa_read(%struct.pcm** %0, i8* %1)
br label %26
16: ; preds = %10
%17 = 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))
%18 = tail call i32 @strlen(i8* %1)
%19 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = sub nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = icmp eq i8* %17, %22
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = tail call i32 @open_wav_read(%struct.pcm** %0, i8* %1)
br label %26
26: ; preds = %16, %24, %14
%27 = phi i32 [ %15, %14 ], [ %25, %24 ], [ 0, %16 ]
ret i32 %27
}