#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*/ PutNum(long, int, int, int);
int /*<<< orphan*/ write(int, char *, int);
void WriteAiff(int f, long int bytes) {
  long size = bytes + 54;
  long frames = bytes / 4;
  write(f, "FORM", 4);
  PutNum(size - 8, f, 1, 4);
  write(f, "AIFF", 4);
  write(f, "COMM", 4);
  PutNum(18, f, 1, 4);
  PutNum(2, f, 1, 2);
  PutNum(frames, f, 1, 4);
  PutNum(16, f, 1, 2);
  write(f, "@\016\254D\0\0\0\0\0\0", 10);
  write(f, "SSND", 4);
  PutNum(bytes + 8, f, 1, 4);
  PutNum(0, f, 1, 4);
  PutNum(0, f, 1, 4);
}


x86 assembly (clang, -O0):
<WriteAiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x36,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
lea    0xea9(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%rdi
sub    $0x8,%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    -0x4(%rbp),%edi
lea    0xe80(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    0xe71(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%esi
mov    $0x12,%edi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    -0x4(%rbp),%esi
mov    $0x2,%edi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1040 <PutNum@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    -0x4(%rbp),%esi
mov    $0x10,%edi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1040 <PutNum@plt>
mov    -0x4(%rbp),%edi
lea    0xe0c(%rip),%rsi
mov    $0xa,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    0xdf3(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    -0x4(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    -0x4(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteAiff>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    0x3(%rsi),%r15
test   %rsi,%rsi
cmovns %rsi,%r15
sar    $0x2,%r15
lea    0xec0(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
lea    0x2e(%r14),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
lea    0xe9f(%rip),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <write@plt>
lea    0xe91(%rip),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <write@plt>
mov    $0x12,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    $0x2,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1040 <PutNum@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
mov    $0x10,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1040 <PutNum@plt>
lea    0xe32(%rip),%rsi
mov    %ebx,%edi
mov    $0xa,%edx
call   1030 <write@plt>
lea    0xe1a(%rip),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0x8,%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1040 <PutNum@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <PutNum@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"FORM\00"
@.str.1 = [5 x i8] c"AIFF\00"
@.str.2 = [5 x i8] c"COMM\00"
@.str.3 = [11 x i8] c"@\0E\ACD\00\00\00\00\00\00\00"
@.str.4 = [5 x i8] c"SSND\00"
define void @WriteAiff(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 %0, i32* %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = add nsw i64 %7, 54
store i64 %8, i64* %5
%9 = load i64, i64* %4
%10 = sdiv i64 %9, 4
store i64 %10, i64* %6
%11 = load i32, i32* %3
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%13 = load i64, i64* %5
%14 = sub nsw i64 %13, 8
%15 = load i32, i32* %3
%16 = call i32 @PutNum(i64 %14, i32 %15, i32 1, i32 4)
%17 = load i32, i32* %3
%18 = call i32 @write(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%19 = load i32, i32* %3
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%21 = load i32, i32* %3
%22 = call i32 @PutNum(i64 18, i32 %21, i32 1, i32 4)
%23 = load i32, i32* %3
%24 = call i32 @PutNum(i64 2, i32 %23, i32 1, i32 2)
%25 = load i64, i64* %6
%26 = load i32, i32* %3
%27 = call i32 @PutNum(i64 %25, i32 %26, i32 1, i32 4)
%28 = load i32, i32* %3
%29 = call i32 @PutNum(i64 16, i32 %28, i32 1, i32 2)
%30 = load i32, i32* %3
%31 = call i32 @write(i32 %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%32 = load i32, i32* %3
%33 = call i32 @write(i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%34 = load i64, i64* %4
%35 = add nsw i64 %34, 8
%36 = load i32, i32* %3
%37 = call i32 @PutNum(i64 %35, i32 %36, i32 1, i32 4)
%38 = load i32, i32* %3
%39 = call i32 @PutNum(i64 0, i32 %38, i32 1, i32 4)
%40 = load i32, i32* %3
%41 = call i32 @PutNum(i64 0, i32 %40, i32 1, i32 4)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"FORM\00"
@.str.1 = [5 x i8] c"AIFF\00"
@.str.2 = [5 x i8] c"COMM\00"
@.str.3 = [11 x i8] c"@\0E\ACD\00\00\00\00\00\00\00"
@.str.4 = [5 x i8] c"SSND\00"
define void @WriteAiff(i32 %0, i64 %1) {
%3 = sdiv i64 %1, 4
%4 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%5 = add nsw i64 %1, 46
%6 = tail call i32 @PutNum(i64 %5, i32 %0, i32 1, i32 4)
%7 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%8 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%9 = tail call i32 @PutNum(i64 18, i32 %0, i32 1, i32 4)
%10 = tail call i32 @PutNum(i64 2, i32 %0, i32 1, i32 2)
%11 = tail call i32 @PutNum(i64 %3, i32 %0, i32 1, i32 4)
%12 = tail call i32 @PutNum(i64 16, i32 %0, i32 1, i32 2)
%13 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%14 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%15 = add nsw i64 %1, 8
%16 = tail call i32 @PutNum(i64 %15, i32 %0, i32 1, i32 4)
%17 = tail call i32 @PutNum(i64 0, i32 %0, i32 1, i32 4)
%18 = tail call i32 @PutNum(i64 0, i32 %0, i32 1, i32 4)
ret void
}