#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 *, int, char *);
scalar_t__ strstr(char const *, char *);
int get_link_category(const char *link, char *type, int size) {
  if (NULL == link) {
    snprintf(type, size, "mp3");
    return -1;
  }
  if (strstr(link, ".rm")) {
    snprintf(type, size, "rm");
  } else if (strstr(link, ".ram")) {
    snprintf(type, size, "ram");
  } else if (strstr(link, ".mp3")) {
    snprintf(type, size, "mp3");
  } else if (strstr(link, ".wma")) {
    snprintf(type, size, "wma");
  } else if (strstr(link, ".asf")) {
    snprintf(type, size, "asf");
  } else if (strstr(link, ".swf") || strstr(link, ".flash")) {
    snprintf(type, size, "swf");
  } else if (strstr(link, ".rtsp")) {
    snprintf(type, size, "rtsp");
  } else {
    snprintf(type, size, "mp3");
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_link_category>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    115e <get_link_category+0x3e>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xebd(%rip),%rdx
call   1030 <snprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    130e <get_link_category+0x1ee>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1190 <get_link_category+0x70>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xe7b(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1307 <get_link_category+0x1e7>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11c2 <get_link_category+0xa2>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xe4d(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1302 <get_link_category+0x1e2>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11f4 <get_link_category+0xd4>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xe20(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12fd <get_link_category+0x1dd>
mov    -0x10(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1226 <get_link_category+0x106>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xdf3(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12f8 <get_link_category+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1258 <get_link_category+0x138>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xdc6(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12f3 <get_link_category+0x1d3>
mov    -0x10(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
jne    128c <get_link_category+0x16c>
mov    -0x10(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     12a4 <get_link_category+0x184>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xd7f(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12ee <get_link_category+0x1ce>
mov    -0x10(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     12d6 <get_link_category+0x1b6>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xd59(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12e9 <get_link_category+0x1c9>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xd26(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12ee <get_link_category+0x1ce>
jmp    12f3 <get_link_category+0x1d3>
jmp    12f8 <get_link_category+0x1d8>
jmp    12fd <get_link_category+0x1dd>
jmp    1302 <get_link_category+0x1e2>
jmp    1307 <get_link_category+0x1e7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_link_category>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
lea    0xed5(%rip),%rbx
test   %rdi,%rdi
je     115d <get_link_category+0x3d>
mov    %rdi,%rbp
lea    0xebc(%rip),%rsi
call   1040 <strstr@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     1168 <get_link_category+0x48>
lea    0xea9(%rip),%rbx
jmp    122d <get_link_category+0x10d>
mov    $0xffffffff,%r12d
jmp    122d <get_link_category+0x10d>
lea    0xe95(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1188 <get_link_category+0x68>
lea    0xe82(%rip),%rbx
jmp    122d <get_link_category+0x10d>
lea    0xe7a(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
jne    122d <get_link_category+0x10d>
lea    0xe67(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11bd <get_link_category+0x9d>
lea    0xe54(%rip),%rbx
jmp    122d <get_link_category+0x10d>
lea    0xe4f(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     11da <get_link_category+0xba>
lea    0xe3c(%rip),%rbx
jmp    122d <get_link_category+0x10d>
lea    0xe37(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
lea    0xe29(%rip),%rbx
test   %rax,%rax
jne    122d <get_link_category+0x10d>
lea    0xe21(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
jne    122d <get_link_category+0x10d>
lea    0xe14(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
lea    0xde8(%rip),%rax
lea    0xdfc(%rip),%rbx
cmove  %rax,%rbx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1030 <snprintf@plt>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"mp3\00"
@.str.1 = [4 x i8] c".rm\00"
@.str.2 = [3 x i8] c"rm\00"
@.str.3 = [5 x i8] c".ram\00"
@.str.4 = [4 x i8] c"ram\00"
@.str.5 = [5 x i8] c".mp3\00"
@.str.6 = [5 x i8] c".wma\00"
@.str.7 = [4 x i8] c"wma\00"
@.str.8 = [5 x i8] c".asf\00"
@.str.9 = [4 x i8] c"asf\00"
@.str.10 = [5 x i8] c".swf\00"
@.str.11 = [7 x i8] c".flash\00"
@.str.12 = [4 x i8] c"swf\00"
@.str.13 = [6 x i8] c".rtsp\00"
@.str.14 = [5 x i8] c"rtsp\00"
define i32 @get_link_category(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = icmp eq i8* null, %8
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i32 @snprintf(i8* %11, i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %85
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = call i32 @snprintf(i8* %19, i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %84
22: ; preds = %14
%23 = load i8*, i8** %5
%24 = call i64 @strstr(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = call i32 @snprintf(i8* %27, i32 %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %83
30: ; preds = %22
%31 = load i8*, i8** %5
%32 = call i64 @strstr(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i8*, i8** %6
%36 = load i32, i32* %7
%37 = call i32 @snprintf(i8* %35, i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %82
38: ; preds = %30
%39 = load i8*, i8** %5
%40 = call i64 @strstr(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i8*, i8** %6
%44 = load i32, i32* %7
%45 = call i32 @snprintf(i8* %43, i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %81
46: ; preds = %38
%47 = load i8*, i8** %5
%48 = call i64 @strstr(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i8*, i8** %6
%52 = load i32, i32* %7
%53 = call i32 @snprintf(i8* %51, i32 %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %80
54: ; preds = %46
%55 = load i8*, i8** %5
%56 = call i64 @strstr(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%57 = icmp ne i64 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %54
%59 = load i8*, i8** %5
%60 = call i64 @strstr(i8* %59, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %58, %54
%63 = load i8*, i8** %6
%64 = load i32, i32* %7
%65 = call i32 @snprintf(i8* %63, i32 %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
br label %79
66: ; preds = %58
%67 = load i8*, i8** %5
%68 = call i64 @strstr(i8* %67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %66
%71 = load i8*, i8** %6
%72 = load i32, i32* %7
%73 = call i32 @snprintf(i8* %71, i32 %72, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %78
74: ; preds = %66
%75 = load i8*, i8** %6
%76 = load i32, i32* %7
%77 = call i32 @snprintf(i8* %75, i32 %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %78
78: ; preds = %74, %70
br label %79
79: ; preds = %78, %62
br label %80
80: ; preds = %79, %50
br label %81
81: ; preds = %80, %42
br label %82
82: ; preds = %81, %34
br label %83
83: ; preds = %82, %26
br label %84
84: ; preds = %83, %18
store i32 0, i32* %4
br label %85
85: ; preds = %84, %10
%86 = load i32, i32* %4
ret i32 %86
}

LLVM IR (-O2):
@.str = [4 x i8] c"mp3\00"
@.str.1 = [4 x i8] c".rm\00"
@.str.2 = [3 x i8] c"rm\00"
@.str.3 = [5 x i8] c".ram\00"
@.str.4 = [4 x i8] c"ram\00"
@.str.5 = [5 x i8] c".mp3\00"
@.str.6 = [5 x i8] c".wma\00"
@.str.7 = [4 x i8] c"wma\00"
@.str.8 = [5 x i8] c".asf\00"
@.str.9 = [4 x i8] c"asf\00"
@.str.10 = [5 x i8] c".swf\00"
@.str.11 = [7 x i8] c".flash\00"
@.str.12 = [4 x i8] c"swf\00"
@.str.13 = [6 x i8] c".rtsp\00"
@.str.14 = [5 x i8] c"rtsp\00"
define i32 @get_link_category(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %30, label %5
5: ; preds = %3
%6 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %30
8: ; preds = %5
%9 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0)
br label %30
30: ; preds = %26, %20, %23, %17, %14, %11, %8, %5, %3
%31 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %17 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), %23 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), %20 ], [ %29, %26 ]
%32 = phi i32 [ -1, %3 ], [ 0, %5 ], [ 0, %8 ], [ 0, %11 ], [ 0, %14 ], [ 0, %17 ], [ 0, %23 ], [ 0, %20 ], [ 0, %26 ]
%33 = tail call i32 @snprintf(i8* %1, i32 %2, i8* %31)
ret i32 %32
}