#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*/ memset(char *, int /*<<< orphan*/, int);
char *make_bmp_head(char *p, long w, long h) {
  *p++ = 'B';
  *p++ = 'M';
  *(long *)p = (0x3E + w * h / 8);
  p += sizeof(long);
  ;
  *(short *)p = (0);
  p += sizeof(short);
  ;
  *(short *)p = (0);
  p += sizeof(short);
  ;
  *(long *)p = (0x3E);
  p += sizeof(long);
  ;
  *(long *)p = (0x28);
  p += sizeof(long);
  ;
  *(long *)p = (w);
  p += sizeof(long);
  ;
  *(long *)p = (h);
  p += sizeof(long);
  ;
  *(short *)p = (1);
  p += sizeof(short);
  ;
  *(short *)p = (1);
  p += sizeof(short);
  ;
  *(long *)p = (0);
  p += sizeof(long);
  ;
  *(long *)p = (w * h / 8);
  p += sizeof(long);
  ;
  memset(p, 0, 0x14);
  p += 0x14;
  *(long *)p = (0xFFFFFF);
  p += sizeof(long);
  ;
  return p;
}


x86 assembly (clang, -O0):
<make_bmp_head>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x42,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x4d,(%rax)
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    $0x8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
add    $0x3e,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movw   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movw   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x3e,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x28,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movw   $0x1,(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movw   $0x1,(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    $0x8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movq   $0xffffff,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_bmp_head>:
push   %rbx
mov    %rdi,%rbx
movw   $0x4d42,(%rdi)
mov    %rdx,%rax
imul   %rsi,%rax
lea    0x7(%rax),%rcx
test   %rax,%rax
cmovns %rax,%rcx
sar    $0x3,%rcx
lea    0x3e(%rcx),%rax
mov    %rax,0x2(%rdi)
movl   $0x0,0xa(%rdi)
movaps 0xebb(%rip),%xmm0
movups %xmm0,0xe(%rdi)
mov    %rsi,0x1e(%rdi)
mov    %rdx,0x26(%rdi)
movl   $0x10001,0x2e(%rdi)
movq   $0x0,0x32(%rdi)
mov    %rcx,0x3a(%rdi)
add    $0x42,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
movq   $0xffffff,0x56(%rbx)
add    $0x5e,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @make_bmp_head(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %4
store i8 66, i8* %7
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %4
store i8 77, i8* %9
%11 = load i64, i64* %5
%12 = load i64, i64* %6
%13 = mul nsw i64 %11, %12
%14 = sdiv i64 %13, 8
%15 = add nsw i64 62, %14
%16 = load i8*, i8** %4
%17 = bitcast i8* %16 to i64*
store i64 %15, i64* %17
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 8
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = bitcast i8* %20 to i16*
store i16 0, i16* %21
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = bitcast i8* %24 to i16*
store i16 0, i16* %25
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = bitcast i8* %28 to i64*
store i64 62, i64* %29
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 8
store i8* %31, i8** %4
%32 = load i8*, i8** %4
%33 = bitcast i8* %32 to i64*
store i64 40, i64* %33
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 8
store i8* %35, i8** %4
%36 = load i64, i64* %5
%37 = load i8*, i8** %4
%38 = bitcast i8* %37 to i64*
store i64 %36, i64* %38
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 8
store i8* %40, i8** %4
%41 = load i64, i64* %6
%42 = load i8*, i8** %4
%43 = bitcast i8* %42 to i64*
store i64 %41, i64* %43
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 8
store i8* %45, i8** %4
%46 = load i8*, i8** %4
%47 = bitcast i8* %46 to i16*
store i16 1, i16* %47
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 2
store i8* %49, i8** %4
%50 = load i8*, i8** %4
%51 = bitcast i8* %50 to i16*
store i16 1, i16* %51
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 2
store i8* %53, i8** %4
%54 = load i8*, i8** %4
%55 = bitcast i8* %54 to i64*
store i64 0, i64* %55
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i64 8
store i8* %57, i8** %4
%58 = load i64, i64* %5
%59 = load i64, i64* %6
%60 = mul nsw i64 %58, %59
%61 = sdiv i64 %60, 8
%62 = load i8*, i8** %4
%63 = bitcast i8* %62 to i64*
store i64 %61, i64* %63
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i64 8
store i8* %65, i8** %4
%66 = load i8*, i8** %4
%67 = call i32 @memset(i8* %66, i32 0, i32 20)
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i64 20
store i8* %69, i8** %4
%70 = load i8*, i8** %4
%71 = bitcast i8* %70 to i64*
store i64 16777215, i64* %71
%72 = load i8*, i8** %4
%73 = getelementptr inbounds i8, i8* %72, i64 8
store i8* %73, i8** %4
%74 = load i8*, i8** %4
ret i8* %74
}

LLVM IR (-O2):
define i8* @make_bmp_head(i8* %0, i64 %1, i64 %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 1
store i8 66, i8* %0
%5 = getelementptr inbounds i8, i8* %0, i64 2
store i8 77, i8* %4
%6 = mul nsw i64 %2, %1
%7 = sdiv i64 %6, 8
%8 = add nsw i64 %7, 62
%9 = bitcast i8* %5 to i64*
store i64 %8, i64* %9
%10 = getelementptr inbounds i8, i8* %0, i64 10
%11 = bitcast i8* %10 to i16*
store i16 0, i16* %11
%12 = getelementptr inbounds i8, i8* %0, i64 12
%13 = bitcast i8* %12 to i16*
store i16 0, i16* %13
%14 = getelementptr inbounds i8, i8* %0, i64 14
%15 = bitcast i8* %14 to <2 x i64>*
store <2 x i64> <i64 62, i64 40>, <2 x i64>* %15
%16 = getelementptr inbounds i8, i8* %0, i64 30
%17 = bitcast i8* %16 to i64*
store i64 %1, i64* %17
%18 = getelementptr inbounds i8, i8* %0, i64 38
%19 = bitcast i8* %18 to i64*
store i64 %2, i64* %19
%20 = getelementptr inbounds i8, i8* %0, i64 46
%21 = bitcast i8* %20 to i16*
store i16 1, i16* %21
%22 = getelementptr inbounds i8, i8* %0, i64 48
%23 = bitcast i8* %22 to i16*
store i16 1, i16* %23
%24 = getelementptr inbounds i8, i8* %0, i64 50
%25 = bitcast i8* %24 to i64*
store i64 0, i64* %25
%26 = getelementptr inbounds i8, i8* %0, i64 58
%27 = bitcast i8* %26 to i64*
store i64 %7, i64* %27
%28 = getelementptr inbounds i8, i8* %0, i64 66
%29 = tail call i32 @memset(i8* %28, i32 0, i32 20)
%30 = getelementptr inbounds i8, i8* %0, i64 86
%31 = bitcast i8* %30 to i64*
store i64 16777215, i64* %31
%32 = getelementptr inbounds i8, i8* %0, i64 94
ret i8* %32
}