#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 *, int, int);
void set_char_pix(unsigned char *buf, int x, int y, int xsize, int ysize) {
  int bitoffset;
  if ((x < xsize) && (y < ysize)) {
    bitoffset = (xsize * y) + x;
    buf[bitoffset / 8] |= (0x80 >> (bitoffset & 7));
  } else {
    printf("set_char_pix : outside bitmap area ! : %d x %d\n", x, y);
  }
}


x86 assembly (clang, -O0):
<set_char_pix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1185 <set_char_pix+0x75>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1185 <set_char_pix+0x75>
mov    -0x14(%rbp),%eax
imul   -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
and    $0x7,%ecx
mov    $0x80,%esi
sar    %cl,%esi
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
or     %esi,%edx
mov    %dl,(%rax,%rcx,1)
jmp    1197 <set_char_pix+0x87>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_char_pix>:
cmp    %ecx,%esi
jge    1143 <set_char_pix+0x33>
cmp    %r8d,%edx
jge    1143 <set_char_pix+0x33>
mov    %ecx,%eax
imul   %edx,%eax
lea    (%rax,%rsi,1),%edx
mov    %edx,%ecx
and    $0x7,%cl
mov    $0x80,%r8d
shr    %cl,%r8d
add    %esi,%eax
add    $0x7,%eax
test   %edx,%edx
cmovns %edx,%eax
sar    $0x3,%eax
cltq
or     %r8b,(%rdi,%rax,1)
ret
lea    0xeb6(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"set_char_pix : outside bitmap area ! : %d x %d\0A\00"
define void @set_char_pix(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %7
%13 = load i32, i32* %9
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %5
%16 = load i32, i32* %8
%17 = load i32, i32* %10
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %37
19: ; preds = %15
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %7
%24 = add nsw i32 %22, %23
store i32 %24, i32* %11
%25 = load i32, i32* %11
%26 = and i32 %25, 7
%27 = ashr i32 128, %26
%28 = load i8*, i8** %6
%29 = load i32, i32* %11
%30 = sdiv i32 %29, 8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = or i32 %34, %27
%36 = trunc i32 %35 to i8
store i8 %36, i8* %32
br label %41
37: ; preds = %15, %5
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %39)
br label %41
41: ; preds = %37, %19
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"set_char_pix : outside bitmap area ! : %d x %d\0A\00"
define void @set_char_pix(i8* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %1, %3
%7 = icmp slt i32 %2, %4
%8 = and i1 %6, %7
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = mul nsw i32 %3, %2
%11 = add nsw i32 %10, %1
%12 = and i32 %11, 7
%13 = lshr i32 128, %12
%14 = sdiv i32 %11, 8
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = trunc i32 %13 to i8
%19 = or i8 %17, %18
store i8 %19, i8* %16
br label %22
20: ; preds = %5
%21 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
br label %22
22: ; preds = %20, %9
ret void
}