#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int FS460_get_alpha_mask(unsigned short *, int, int);
int /*<<< orphan*/ OS_file_close(unsigned long);
int /*<<< orphan*/ OS_file_create(unsigned long *, char *);
int /*<<< orphan*/ OS_file_write(unsigned long, unsigned short *, int);
void read_alpha(void) {
  int err;
  unsigned short buf[32768];
  unsigned long hf;
  err = FS460_get_alpha_mask(buf, sizeof(buf), 0);
  if (!err) {
    OS_file_create(&hf, "alpha_out_even");
    OS_file_write(hf, buf, sizeof(buf));
    OS_file_close(hf);
  }
  err = FS460_get_alpha_mask(buf, sizeof(buf), 1);
  if (!err) {
    OS_file_create(&hf, "alpha_out_odd");
    OS_file_write(hf, buf, sizeof(buf));
    OS_file_close(hf);
  }
}


x86 assembly (clang, -O0):
<read_alpha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
lea    -0x10010(%rbp),%rdi
mov    $0x10000,%esi
xor    %edx,%edx
call   1060 <FS460_get_alpha_mask@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11a2 <read_alpha+0x62>
lea    -0x10018(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <OS_file_create@plt>
mov    -0x10018(%rbp),%rdi
lea    -0x10010(%rbp),%rsi
mov    $0x10000,%edx
call   1050 <OS_file_write@plt>
mov    -0x10018(%rbp),%rdi
call   1040 <OS_file_close@plt>
lea    -0x10010(%rbp),%rdi
mov    $0x10000,%esi
mov    $0x1,%edx
call   1060 <FS460_get_alpha_mask@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11fc <read_alpha+0xbc>
lea    -0x10018(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <OS_file_create@plt>
mov    -0x10018(%rbp),%rdi
lea    -0x10010(%rbp),%rsi
mov    $0x10000,%edx
call   1050 <OS_file_write@plt>
mov    -0x10018(%rbp),%rdi
call   1040 <OS_file_close@plt>
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_alpha>:
sub    $0x10018,%rsp
lea    0x10(%rsp),%rdi
mov    $0x10000,%esi
xor    %edx,%edx
call   1060 <FS460_get_alpha_mask@plt>
test   %eax,%eax
jne    118b <read_alpha+0x4b>
lea    0xe9d(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1030 <OS_file_create@plt>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x10000,%edx
call   1050 <OS_file_write@plt>
mov    0x8(%rsp),%rdi
call   1040 <OS_file_close@plt>
lea    0x10(%rsp),%rdi
mov    $0x10000,%esi
mov    $0x1,%edx
call   1060 <FS460_get_alpha_mask@plt>
test   %eax,%eax
je     11ab <read_alpha+0x6b>
add    $0x10018,%rsp
ret
lea    0xe5d(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1030 <OS_file_create@plt>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x10000,%edx
call   1050 <OS_file_write@plt>
mov    0x8(%rsp),%rdi
call   1040 <OS_file_close@plt>
add    $0x10018,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"alpha_out_even\00"
@.str.1 = [14 x i8] c"alpha_out_odd\00"
define void @read_alpha() {
%1 = alloca i32
%2 = alloca [32768 x i16]
%3 = alloca i64
%4 = getelementptr inbounds [32768 x i16], [32768 x i16]* %2, i64 0, i64 0
%5 = call i32 @FS460_get_alpha_mask(i16* %4, i32 65536, i32 0)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %0
%9 = call i32 @OS_file_create(i64* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %3
%11 = getelementptr inbounds [32768 x i16], [32768 x i16]* %2, i64 0, i64 0
%12 = call i32 @OS_file_write(i64 %10, i16* %11, i32 65536)
%13 = load i64, i64* %3
%14 = call i32 @OS_file_close(i64 %13)
br label %15
15: ; preds = %8, %0
%16 = getelementptr inbounds [32768 x i16], [32768 x i16]* %2, i64 0, i64 0
%17 = call i32 @FS460_get_alpha_mask(i16* %16, i32 65536, i32 1)
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = icmp ne i32 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %15
%21 = call i32 @OS_file_create(i64* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = load i64, i64* %3
%23 = getelementptr inbounds [32768 x i16], [32768 x i16]* %2, i64 0, i64 0
%24 = call i32 @OS_file_write(i64 %22, i16* %23, i32 65536)
%25 = load i64, i64* %3
%26 = call i32 @OS_file_close(i64 %25)
br label %27
27: ; preds = %20, %15
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"alpha_out_even\00"
@.str.1 = [14 x i8] c"alpha_out_odd\00"
define void @read_alpha() {
%1 = alloca [32768 x i16]
%2 = alloca i64
%3 = bitcast [32768 x i16]* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = getelementptr inbounds [32768 x i16], [32768 x i16]* %1, i64 0, i64 0
%6 = call i32 @FS460_get_alpha_mask(i16* %5, i32 65536, i32 0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = call i32 @OS_file_create(i64* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %2
%11 = call i32 @OS_file_write(i64 %10, i16* %5, i32 65536)
%12 = load i64, i64* %2
%13 = call i32 @OS_file_close(i64 %12)
br label %14
14: ; preds = %8, %0
%15 = call i32 @FS460_get_alpha_mask(i16* %5, i32 65536, i32 1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = call i32 @OS_file_create(i64* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%19 = load i64, i64* %2
%20 = call i32 @OS_file_write(i64 %19, i16* %5, i32 65536)
%21 = load i64, i64* %2
%22 = call i32 @OS_file_close(i64 %21)
br label %23
23: ; preds = %17, %14
ret void
}