#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*/ draw_pt(unsigned char *, int const, int const, int const,
                           int const, char);
void draw_hexagon(unsigned char *pixelbuf, const int image_width,
                  const int image_height, unsigned char *scaled_hexagon,
                  const int hex_width, const int hex_height, const int xposn,
                  const int yposn) {
  int i, j;
  for (i = 0; i < hex_height; i++) {
    for (j = 0; j < hex_width; j++) {
      if (scaled_hexagon[(i * hex_width) + j] == '1') {
        draw_pt(pixelbuf, image_width, image_height, xposn + j, yposn + i, '1');
      }
    }
  }
}


x86 assembly (clang, -O0):
<draw_hexagon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11c1 <draw_hexagon+0xb1>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ae <draw_hexagon+0x9e>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    119b <draw_hexagon+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
mov    0x18(%rbp),%r8d
add    -0x24(%rbp),%r8d
mov    $0x31,%r9d
call   1030 <draw_pt@plt>
jmp    11a0 <draw_hexagon+0x90>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114e <draw_hexagon+0x3e>
jmp    11b3 <draw_hexagon+0xa3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113b <draw_hexagon+0x2b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_hexagon>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,0x4(%rsp)
mov    %edx,0x14(%rsp)
test   %r9d,%r9d
jle    11d2 <draw_hexagon+0xc2>
mov    %rcx,%rbx
mov    %esi,%r12d
mov    %rdi,%r13
movslq 0x4(%rsp),%rax
mov    %r9d,%ecx
mov    %rcx,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    %eax,%r14d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    117d <draw_hexagon+0x6d>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rcx
add    $0x1,%rcx
add    0x20(%rsp),%rbx
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
cmp    0x18(%rsp),%rcx
je     11d2 <draw_hexagon+0xc2>
cmpl   $0x0,0x4(%rsp)
jle    1160 <draw_hexagon+0x50>
mov    0x68(%rsp),%eax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,1),%ebp
xor    %r15d,%r15d
jmp    11a9 <draw_hexagon+0x99>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15
cmp    %r15,%r14
je     1160 <draw_hexagon+0x50>
cmpb   $0x31,(%rbx,%r15,1)
jne    11a0 <draw_hexagon+0x90>
mov    0x60(%rsp),%eax
lea    (%rax,%r15,1),%ecx
mov    %r13,%rdi
mov    %r12d,%esi
mov    0x14(%rsp),%edx
mov    %ebp,%r8d
mov    $0x31,%r9d
call   1030 <draw_pt@plt>
jmp    11a0 <draw_hexagon+0x90>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @draw_hexagon(i8* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store i32 0, i32* %17
br label %19
19: ; preds = %56, %8
%20 = load i32, i32* %17
%21 = load i32, i32* %14
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %59
23: ; preds = %19
store i32 0, i32* %18
br label %24
24: ; preds = %52, %23
%25 = load i32, i32* %18
%26 = load i32, i32* %13
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %55
28: ; preds = %24
%29 = load i8*, i8** %12
%30 = load i32, i32* %17
%31 = load i32, i32* %13
%32 = mul nsw i32 %30, %31
%33 = load i32, i32* %18
%34 = add nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %29, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = icmp eq i32 %38, 49
br i1 %39, label %40, label %51
40: ; preds = %28
%41 = load i8*, i8** %9
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = load i32, i32* %15
%45 = load i32, i32* %18
%46 = add nsw i32 %44, %45
%47 = load i32, i32* %16
%48 = load i32, i32* %17
%49 = add nsw i32 %47, %48
%50 = call i32 @draw_pt(i8* %41, i32 %42, i32 %43, i32 %46, i32 %49, i8 signext 49)
br label %51
51: ; preds = %40, %28
br label %52
52: ; preds = %51
%53 = load i32, i32* %18
%54 = add nsw i32 %53, 1
store i32 %54, i32* %18
br label %24
55: ; preds = %24
br label %56
56: ; preds = %55
%57 = load i32, i32* %17
%58 = add nsw i32 %57, 1
store i32 %58, i32* %17
br label %19
59: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @draw_hexagon(i8* %0, i32 %1, i32 %2, i8* nocapture %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %37
10: ; preds = %8
%11 = icmp sgt i32 %4, 0
%12 = sext i32 %4 to i64
%13 = zext i32 %5 to i64
%14 = zext i32 %4 to i64
br label %15
15: ; preds = %10, %34
%16 = phi i64 [ 0, %10 ], [ %35, %34 ]
br i1 %11, label %17, label %34
17: ; preds = %15
%18 = mul nsw i64 %16, %12
%19 = trunc i64 %16 to i32
%20 = add i32 %19, %7
br label %21
21: ; preds = %17, %31
%22 = phi i64 [ 0, %17 ], [ %32, %31 ]
%23 = add nsw i64 %22, %18
%24 = getelementptr inbounds i8, i8* %3, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 49
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = trunc i64 %22 to i32
%29 = add i32 %28, %6
%30 = tail call i32 @draw_pt(i8* %0, i32 %1, i32 %2, i32 %29, i32 %20, i8 signext 49)
br label %31
31: ; preds = %21, %27
%32 = add nuw nsw i64 %22, 1
%33 = icmp eq i64 %32, %14
br i1 %33, label %34, label %21
34: ; preds = %31, %15
%35 = add nuw nsw i64 %16, 1
%36 = icmp eq i64 %35, %13
br i1 %36, label %37, label %15
37: ; preds = %34, %8
ret void
}