#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*/ printf(char *);
void output_maskinfo(const unsigned char *mask_buf, size_t bytes_per_line,
                     int x, int y) {
  const unsigned char *ptr;
  ptr = mask_buf + bytes_per_line * y;
  ptr += x / 8;
  if ((*ptr & ((unsigned char)1) << (7 - (x % 8))))
    printf("0x00,");
  else
    printf("0xff,");
  return;
}


x86 assembly (clang, -O0):
<output_maskinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
imul   %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
mov    $0x7,%ecx
sub    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     119c <output_maskinfo+0x8c>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
jmp    11a8 <output_maskinfo+0x98>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_maskinfo>:
movslq %ecx,%rax
imul   %rsi,%rax
add    %rdi,%rax
lea    0x7(%rdx),%ecx
test   %edx,%edx
cmovns %edx,%ecx
mov    %ecx,%esi
sar    $0x3,%esi
movslq %esi,%rsi
movzbl (%rsi,%rax,1),%eax
and    $0xfffffff8,%ecx
sub    %ecx,%edx
mov    $0x7,%cl
sub    %dl,%cl
movzbl %cl,%ecx
bt     %ecx,%eax
lea    0xec2(%rip),%rax
lea    0xeb5(%rip),%rdi
cmovae %rax,%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"0x00,\00"
@.str.1 = [6 x i8] c"0xff,\00"
define void @output_maskinfo(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = load i32, i32* %8
%13 = sext i32 %12 to i64
%14 = mul i64 %11, %13
%15 = getelementptr inbounds i8, i8* %10, i64 %14
store i8* %15, i8** %9
%16 = load i32, i32* %7
%17 = sdiv i32 %16, 8
%18 = load i8*, i8** %9
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = load i32, i32* %7
%25 = srem i32 %24, 8
%26 = sub nsw i32 7, %25
%27 = shl i32 1, %26
%28 = and i32 %23, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %4
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %34
32: ; preds = %4
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"0x00,\00"
@.str.1 = [6 x i8] c"0xff,\00"
define void @output_maskinfo(i8* nocapture %0, i64 %1, i32 %2, i32 %3) {
%5 = sext i32 %3 to i64
%6 = mul i64 %5, %1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = sdiv i32 %2, 8
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = srem i32 %2, 8
%14 = sub nsw i32 7, %13
%15 = shl nuw nsw i32 1, %14
%16 = and i32 %15, %12
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
%19 = tail call i32 @printf(i8* dereferenceable(1) %18)
ret void
}