#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*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
int f_wave_partition(int mode, unsigned char **sec, float *data,
                     unsigned int ndata, char *inv_out, void **local) {
  int pdt;
  if (mode >= 0) {
    pdt = (((int)((sec[4][7] << 8) + (sec[4][8]))));
    if (pdt == 52) {
      if (sec[4][13] == 255)
        sprintf(inv_out, "wave partition=?");
      else
        sprintf(inv_out, "wave partition=%d", (int)sec[4][13]);
      inv_out += strlen(inv_out);
      if (sec[4][12] == 255)
        sprintf(inv_out, "/?");
      else
        sprintf(inv_out, "/%d", (int)sec[4][12]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_wave_partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     122d <f_wave_partition+0x10d>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0x7(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
mov    0x20(%rcx),%rcx
movzbl 0x8(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x34,-0x34(%rbp)
jne    1228 <f_wave_partition+0x108>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0xd(%rax),%eax
cmp    $0xff,%eax
jne    11a0 <f_wave_partition+0x80>
mov    -0x28(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11be <f_wave_partition+0x9e>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0xd(%rax),%edx
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0xc(%rax),%eax
cmp    $0xff,%eax
jne    1205 <f_wave_partition+0xe5>
mov    -0x28(%rbp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1223 <f_wave_partition+0x103>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0xc(%rax),%edx
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1228 <f_wave_partition+0x108>
jmp    122d <f_wave_partition+0x10d>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_wave_partition>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     11a4 <f_wave_partition+0x84>
mov    %rsi,%r14
mov    0x20(%rsi),%rax
movzwl 0x7(%rax),%ecx
shl    $0x10,%ecx
bswap  %ecx
cmp    $0x34,%ecx
jne    11a4 <f_wave_partition+0x84>
mov    %r8,%rbx
movzbl 0xd(%rax),%edx
cmp    $0xff,%edx
je     115f <f_wave_partition+0x3f>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    116d <f_wave_partition+0x4d>
movups 0xe9a(%rip),%xmm0
movups %xmm0,(%rbx)
movb   $0x0,0x10(%rbx)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
mov    0x20(%r14),%rax
movzbl 0xc(%rax),%edx
cmp    $0xff,%edx
je     119b <f_wave_partition+0x7b>
lea    0xe94(%rip),%rsi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    11a4 <f_wave_partition+0x84>
movb   $0x0,0x2(%rdi)
movw   $0x3f2f,(%rdi)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"wave partition=?\00"
@.str.1 = [18 x i8] c"wave partition=%d\00"
@.str.2 = [3 x i8] c"/?\00"
@.str.3 = [4 x i8] c"/%d\00"
define i32 @f_wave_partition(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%14 = load i32, i32* %7
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %80
16: ; preds = %6
%17 = load i8**, i8*** %8
%18 = getelementptr inbounds i8*, i8** %17, i64 4
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 7
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl i32 %22, 8
%24 = load i8**, i8*** %8
%25 = getelementptr inbounds i8*, i8** %24, i64 4
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 8
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = add nsw i32 %23, %29
store i32 %30, i32* %13
%31 = load i32, i32* %13
%32 = icmp eq i32 %31, 52
br i1 %32, label %33, label %79
33: ; preds = %16
%34 = load i8**, i8*** %8
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 13
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 255
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i8*, i8** %11
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %53
44: ; preds = %33
%45 = load i8*, i8** %11
%46 = load i8**, i8*** %8
%47 = getelementptr inbounds i8*, i8** %46, i64 4
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 13
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %44, %41
%54 = load i8*, i8** %11
%55 = call i32 @strlen(i8* %54)
%56 = load i8*, i8** %11
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds i8, i8* %56, i64 %57
store i8* %58, i8** %11
%59 = load i8**, i8*** %8
%60 = getelementptr inbounds i8*, i8** %59, i64 4
%61 = load i8*, i8** %60
%62 = getelementptr inbounds i8, i8* %61, i64 12
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = icmp eq i32 %64, 255
br i1 %65, label %66, label %69
66: ; preds = %53
%67 = load i8*, i8** %11
%68 = call i32 (i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %78
69: ; preds = %53
%70 = load i8*, i8** %11
%71 = load i8**, i8*** %8
%72 = getelementptr inbounds i8*, i8** %71, i64 4
%73 = load i8*, i8** %72
%74 = getelementptr inbounds i8, i8* %73, i64 12
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = call i32 (i8*, i8*, ...) @sprintf(i8* %70, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %69, %66
br label %79
79: ; preds = %78, %16
br label %80
80: ; preds = %79, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"wave partition=?\00"
@.str.1 = [18 x i8] c"wave partition=%d\00"
@.str.2 = [3 x i8] c"/?\00"
@.str.3 = [4 x i8] c"/%d\00"
define i32 @f_wave_partition(i32 %0, i8** nocapture %1, float* nocapture readnone %2, i32 %3, i8* %4, i8** nocapture readnone %5) {
%7 = icmp sgt i32 %0, -1
br i1 %7, label %8, label %40
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 4
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8, i8* %10, i64 7
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = shl nuw nsw i32 %13, 8
%15 = getelementptr inbounds i8, i8* %10, i64 8
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = or i32 %14, %17
%19 = icmp eq i32 %18, 52
br i1 %19, label %20, label %40
20: ; preds = %8
%21 = getelementptr inbounds i8, i8* %10, i64 13
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %20
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(17) %4, i8* align 1 dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 17, i1 false)
br label %28
25: ; preds = %20
%26 = zext i8 %22 to i32
%27 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %24
%29 = tail call i32 @strlen(i8* %4)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %4, i64 %30
%32 = load i8*, i8** %9
%33 = getelementptr inbounds i8, i8* %32, i64 12
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, -1
br i1 %35, label %36, label %37
36: ; preds = %28
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %31, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 3, i1 false)
br label %40
37: ; preds = %28
%38 = zext i8 %34 to i32
%39 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %31, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %8, %37, %36, %6
ret i32 0
}