#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 */
short cos(short);
int /*<<< orphan*/ putPixel(short, short, char);
short sin(short);
void drawCircle(short centerX, short centerY, short radius, char color) {
  short angle = 0;
  while (angle < 628) {
    short xVal = centerX + (radius * cos(angle / 100));
    short yVal = centerY + (radius * sin(angle / 100));
    putPixel(xVal, yVal, color);
    angle++;
  }
}


x86 assembly (clang, -O0):
<drawCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dx,%cx
mov    %si,%dx
mov    %di,%si
mov    %si,-0x2(%rbp)
mov    %dx,-0x4(%rbp)
mov    %cx,-0x6(%rbp)
mov    %al,-0x7(%rbp)
movw   $0x0,-0xa(%rbp)
movswl -0xa(%rbp),%eax
cmp    $0x274,%eax
jge    11fd <drawCircle+0xcd>
movswl -0x2(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movswl -0x6(%rbp),%eax
mov    %eax,-0x20(%rbp)
movswl -0xa(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
movswl %ax,%edi
call   1040 <cos@plt>
mov    -0x20(%rbp),%ecx
mov    %ax,%dx
mov    -0x1c(%rbp),%eax
movswl %dx,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %ax,-0xc(%rbp)
movswl -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
movswl -0x6(%rbp),%eax
mov    %eax,-0x18(%rbp)
movswl -0xa(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
movswl %ax,%edi
call   1030 <sin@plt>
mov    -0x18(%rbp),%ecx
mov    %ax,%dx
mov    -0x14(%rbp),%eax
movswl %dx,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %ax,-0xe(%rbp)
mov    -0xc(%rbp),%cx
mov    -0xe(%rbp),%ax
movswl %cx,%edi
movswl %ax,%esi
movsbl -0x7(%rbp),%edx
call   1050 <putPixel@plt>
mov    -0xa(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa(%rbp)
jmp    1158 <drawCircle+0x28>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawCircle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %esi,0x4(%rsp)
mov    %edi,%r15d
xor    %r14d,%r14d
movsbl %cl,%r12d
nopl   0x0(%rax)
movzwl %r14w,%r14d
mov    %r14d,%eax
shr    $0x2,%eax
imul   $0x147b,%eax,%ebp
shr    $0x11,%ebp
mov    %ebp,%edi
call   1040 <cos@plt>
mov    %eax,%ebx
imul   %r13d,%ebx
add    %r15d,%ebx
mov    %ebp,%edi
call   1030 <sin@plt>
imul   %r13d,%eax
add    0x4(%rsp),%eax
movswl %bx,%edi
movswl %ax,%esi
mov    %r12d,%edx
call   1050 <putPixel@plt>
add    $0x1,%r14d
movzwl %r14w,%eax
cmp    $0x274,%eax
jne    1150 <drawCircle+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @drawCircle(i16 signext %0, i16 signext %1, i16 signext %2, i8 signext %3) {
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i8
%9 = alloca i16
%10 = alloca i16
%11 = alloca i16
store i16 %0, i16* %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i8 %3, i8* %8
store i16 0, i16* %9
br label %12
12: ; preds = %16, %4
%13 = load i16, i16* %9
%14 = sext i16 %13 to i32
%15 = icmp slt i32 %14, 628
br i1 %15, label %16, label %49
16: ; preds = %12
%17 = load i16, i16* %5
%18 = sext i16 %17 to i32
%19 = load i16, i16* %7
%20 = sext i16 %19 to i32
%21 = load i16, i16* %9
%22 = sext i16 %21 to i32
%23 = sdiv i32 %22, 100
%24 = trunc i32 %23 to i16
%25 = call signext i16 @cos(i16 signext %24)
%26 = sext i16 %25 to i32
%27 = mul nsw i32 %20, %26
%28 = add nsw i32 %18, %27
%29 = trunc i32 %28 to i16
store i16 %29, i16* %10
%30 = load i16, i16* %6
%31 = sext i16 %30 to i32
%32 = load i16, i16* %7
%33 = sext i16 %32 to i32
%34 = load i16, i16* %9
%35 = sext i16 %34 to i32
%36 = sdiv i32 %35, 100
%37 = trunc i32 %36 to i16
%38 = call signext i16 @sin(i16 signext %37)
%39 = sext i16 %38 to i32
%40 = mul nsw i32 %33, %39
%41 = add nsw i32 %31, %40
%42 = trunc i32 %41 to i16
store i16 %42, i16* %11
%43 = load i16, i16* %10
%44 = load i16, i16* %11
%45 = load i8, i8* %8
%46 = call i32 @putPixel(i16 signext %43, i16 signext %44, i8 signext %45)
%47 = load i16, i16* %9
%48 = add i16 %47, 1
store i16 %48, i16* %9
br label %12
49: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @drawCircle(i16 signext %0, i16 signext %1, i16 signext %2, i8 signext %3) {
br label %5
5: ; preds = %4, %5
%6 = phi i16 [ 0, %4 ], [ %15, %5 ]
%7 = udiv i16 %6, 100
%8 = tail call signext i16 @cos(i16 signext %7)
%9 = mul i16 %8, %2
%10 = add i16 %9, %0
%11 = tail call signext i16 @sin(i16 signext %7)
%12 = mul i16 %11, %2
%13 = add i16 %12, %1
%14 = tail call i32 @putPixel(i16 signext %10, i16 signext %13, i8 signext %3)
%15 = add nuw nsw i16 %6, 1
%16 = icmp eq i16 %15, 628
br i1 %16, label %17, label %5
17: ; preds = %5
ret void
}