#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 const);
scalar_t__ floorf(float const);
void draw_circle(unsigned char *pixelbuf, const int image_width,
                 const int image_height, const int x0, const int y0,
                 const float radius, const char fill) {
  int x, y;
  const int radius_i = (int)floorf(radius);
  const int radius_squared = radius_i * radius_i;
  for (y = -radius_i; y <= radius_i; y++) {
    const int y_squared = y * y;
    for (x = -radius_i; x <= radius_i; x++) {
      if ((x * x) + y_squared <= radius_squared) {
        draw_pt(pixelbuf, image_width, image_height, x0 + x, y0 + y, fill);
      }
    }
  }
}


x86 assembly (clang, -O0):
<draw_circle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r9b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <floorf@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     11e8 <draw_circle+0xc8>
mov    -0x28(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     11d5 <draw_circle+0xb5>
mov    -0x24(%rbp),%eax
imul   -0x24(%rbp),%eax
add    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jg     11c2 <draw_circle+0xa2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%r8d
add    -0x28(%rbp),%r8d
movsbl -0x1d(%rbp),%r9d
call   1030 <draw_pt@plt>
jmp    11c7 <draw_circle+0xa7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1181 <draw_circle+0x61>
jmp    11da <draw_circle+0xba>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1163 <draw_circle+0x43>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_circle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,0x30(%rsp)
mov    %edx,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %rdi,%rbp
call   1040 <floorf@plt>
mov    %rax,0x18(%rsp)
test   %eax,%eax
js     11f9 <draw_circle+0xd9>
mov    0x18(%rsp),%rax
mov    %eax,%r15d
imul   %eax,%r15d
mov    %eax,%ecx
neg    %ecx
add    %eax,%eax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
mov    %ecx,0x8(%rsp)
jmp    1190 <draw_circle+0x70>
nopl   0x0(%rax)
mov    0x28(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    0x18(%rsp),%ecx
mov    %eax,%ecx
je     11f9 <draw_circle+0xd9>
mov    %ecx,%r12d
imul   %ecx,%r12d
mov    0x20(%rsp),%rax
mov    %rcx,0x28(%rsp)
lea    (%rcx,%rax,1),%r14d
mov    0x4(%rsp),%r13d
mov    0x8(%rsp),%eax
mov    %eax,%ebx
jmp    11c9 <draw_circle+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
add    $0xffffffff,%r13d
je     1180 <draw_circle+0x60>
mov    %ebx,%eax
imul   %ebx,%eax
add    %r12d,%eax
cmp    %r15d,%eax
ja     11c0 <draw_circle+0xa0>
mov    0x30(%rsp),%rax
lea    (%rax,%rbx,1),%ecx
movsbl 0x14(%rsp),%r9d
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %r14d,%r8d
call   1030 <draw_pt@plt>
jmp    11c0 <draw_circle+0xa0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @draw_circle(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, float %5, i8 signext %6) {
%8 = tail call i64 @floorf(float %5)
%9 = trunc i64 %8 to i32
%10 = mul nsw i32 %9, %9
%11 = sub i32 0, %9
%12 = icmp slt i32 %9, 0
br i1 %12, label %31, label %13
13: ; preds = %7, %28
%14 = phi i32 [ %29, %28 ], [ %11, %7 ]
%15 = mul nsw i32 %14, %14
%16 = add nsw i32 %14, %4
br label %17
17: ; preds = %13, %25
%18 = phi i32 [ %11, %13 ], [ %26, %25 ]
%19 = mul nsw i32 %18, %18
%20 = add nuw nsw i32 %19, %15
%21 = icmp ugt i32 %20, %10
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = add nsw i32 %18, %3
%24 = tail call i32 @draw_pt(i8* %0, i32 %1, i32 %2, i32 %23, i32 %16, i8 signext %6)
br label %25
25: ; preds = %17, %22
%26 = add i32 %18, 1
%27 = icmp eq i32 %18, %9
br i1 %27, label %28, label %17
28: ; preds = %25
%29 = add i32 %14, 1
%30 = icmp eq i32 %14, %9
br i1 %30, label %31, label %13
31: ; preds = %28, %7
ret void
}