#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*/ *getTag(char *, char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, long, long);
long strtol(char *, int /*<<< orphan*/ *, int);
char *getQuality(char *input, char *output, int outSize) {
  long sampleSize;
  long sampleRate;
  char tagData[255];
  if ((input == NULL) || (output == NULL)) {
    return NULL;
  }
  if (outSize < (7 * (int)sizeof(char))) {
    return NULL;
  }
  if ((getTag("samplesize", input, tagData, 255)) == NULL) {
    return NULL;
  }
  if ((sampleSize = strtol(tagData, NULL, 10)) == 0) {
    return NULL;
  }
  if ((getTag("samplerate", input, tagData, 255)) == NULL) {
    return NULL;
  }
  if ((sampleRate = strtol(tagData, NULL, 10)) == 0) {
    return NULL;
  }
  sprintf(output, "%ld/%ld", sampleSize, sampleRate / 1000);
  return output;
}


x86 assembly (clang, -O0):
<getQuality>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115c <getQuality+0x2c>
cmpq   $0x0,-0x18(%rbp)
jne    1169 <getQuality+0x39>
movq   $0x0,-0x8(%rbp)
jmp    1281 <getQuality+0x151>
cmpl   $0x7,-0x1c(%rbp)
jge    1180 <getQuality+0x50>
movq   $0x0,-0x8(%rbp)
jmp    1281 <getQuality+0x151>
mov    -0x10(%rbp),%rsi
lea    -0x130(%rbp),%rdx
lea    0xe6e(%rip),%rdi
mov    $0xff,%ecx
call   1030 <getTag@plt>
cmp    $0x0,%rax
jne    11b3 <getQuality+0x83>
movq   $0x0,-0x8(%rbp)
jmp    1281 <getQuality+0x151>
lea    -0x130(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11e3 <getQuality+0xb3>
movq   $0x0,-0x8(%rbp)
jmp    1281 <getQuality+0x151>
mov    -0x10(%rbp),%rsi
lea    -0x130(%rbp),%rdx
lea    0xe16(%rip),%rdi
mov    $0xff,%ecx
call   1030 <getTag@plt>
cmp    $0x0,%rax
jne    1216 <getQuality+0xe6>
movq   $0x0,-0x8(%rbp)
jmp    1281 <getQuality+0x151>
lea    -0x130(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1246 <getQuality+0x116>
movq   $0x0,-0x8(%rbp)
jmp    1281 <getQuality+0x151>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    -0x138(%rbp),%rdx
mov    %rax,%rcx
lea    0xda2(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getQuality>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
xor    %r12d,%r12d
test   %rdi,%rdi
je     11fb <getQuality+0xcb>
mov    %rsi,%r14
test   %rsi,%rsi
je     11fb <getQuality+0xcb>
cmp    $0x7,%edx
jl     11fb <getQuality+0xcb>
mov    %rdi,%rbx
lea    0xe97(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
mov    $0xff,%ecx
call   1030 <getTag@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     11fb <getQuality+0xcb>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
je     11fb <getQuality+0xcb>
mov    %rax,%r15
lea    0xe6c(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
mov    $0xff,%ecx
call   1030 <getTag@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     11fb <getQuality+0xcb>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
je     11fb <getQuality+0xcb>
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
imul   %rcx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x7,%rdx
add    %rdx,%rcx
lea    0xe29(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1050 <sprintf@plt>
mov    %r14,%r12
mov    %r12,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"samplesize\00"
@.str.1 = [11 x i8] c"samplerate\00"
@.str.2 = [8 x i8] c"%ld/%ld\00"
define i8* @getQuality(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca [255 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %13, %3
store i8* null, i8** %4
br label %50
17: ; preds = %13
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 7
br i1 %19, label %20, label %21
20: ; preds = %17
store i8* null, i8** %4
br label %50
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%24 = call i32* @getTag(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23, i32 255)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %21
store i8* null, i8** %4
br label %50
27: ; preds = %21
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%29 = call i64 @strtol(i8* %28, i32* null, i32 10)
store i64 %29, i64* %8
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i8* null, i8** %4
br label %50
32: ; preds = %27
%33 = load i8*, i8** %5
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%35 = call i32* @getTag(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %34, i32 255)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %38
37: ; preds = %32
store i8* null, i8** %4
br label %50
38: ; preds = %32
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%40 = call i64 @strtol(i8* %39, i32* null, i32 10)
store i64 %40, i64* %9
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i8* null, i8** %4
br label %50
43: ; preds = %38
%44 = load i8*, i8** %6
%45 = load i64, i64* %8
%46 = load i64, i64* %9
%47 = sdiv i64 %46, 1000
%48 = call i32 @sprintf(i8* %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %45, i64 %47)
%49 = load i8*, i8** %6
store i8* %49, i8** %4
br label %50
50: ; preds = %43, %42, %37, %31, %26, %20, %16
%51 = load i8*, i8** %4
ret i8* %51
}

LLVM IR (-O2):
@.str = [11 x i8] c"samplesize\00"
@.str.1 = [11 x i8] c"samplerate\00"
@.str.2 = [8 x i8] c"%ld/%ld\00"
define i8* @getQuality(i8* %0, i8* writeonly %1, i32 %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %0, null
%7 = icmp eq i8* %1, null
%8 = or i1 %6, %7
%9 = icmp slt i32 %2, 7
%10 = or i1 %8, %9
br i1 %10, label %26, label %11
11: ; preds = %3
%12 = call i32* @getTag(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %5, i32 255)
%13 = icmp eq i32* %12, null
br i1 %13, label %26, label %14
14: ; preds = %11
%15 = call i64 @strtol(i8* nocapture %5, i32* null, i32 10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %14
%18 = call i32* @getTag(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %5, i32 255)
%19 = icmp eq i32* %18, null
br i1 %19, label %26, label %20
20: ; preds = %17
%21 = call i64 @strtol(i8* nocapture %5, i32* null, i32 10)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = sdiv i64 %21, 1000
%25 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %15, i64 %24)
br label %26
26: ; preds = %20, %17, %14, %11, %3, %23
%27 = phi i8* [ %1, %23 ], [ null, %3 ], [ null, %11 ], [ null, %14 ], [ null, %17 ], [ null, %20 ]
ret i8* %27
}