#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 */
double M_PI;
double cos(double);
int round(double);
double sin(double);
void clock_set_content(char *clock, double degrees, double length,
                       double radius, char value) {
  int size = round(radius * 2);
  int posx = round(sin(degrees / 180.0 * M_PI) * length + radius);
  int posy = round(cos(degrees / 180.0 * M_PI) * length + radius);
  if (posx >= 0 && posx < size && posy >= 0 && posy < size) {
    *(clock + posx * size + posy) = value;
  }
}


x86 assembly (clang, -O0):
<clock_set_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %al,-0x21(%rbp)
movsd  0xeaf(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <round@plt>
mov    %eax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    0x2e6a(%rip),%rax
mulsd  (%rax),%xmm0
call   1030 <sin@plt>
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <round@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe52(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    0x2e2f(%rip),%rax
mulsd  (%rax),%xmm0
call   1040 <cos@plt>
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <round@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     1223 <clock_set_content+0xf3>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1223 <clock_set_content+0xf3>
cmpl   $0x0,-0x30(%rbp)
jl     1223 <clock_set_content+0xf3>
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1223 <clock_set_content+0xf3>
mov    -0x21(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x28(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_set_content>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%r15
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
call   1050 <round@plt>
movsd  0x8(%rsp),%xmm1
divsd  0xe91(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %eax,%r12d
mov    0x2e69(%rip),%rbp
movsd  0x0(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
call   1050 <round@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
mulsd  0x0(%rbp),%xmm0
call   1040 <cos@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
call   1050 <round@plt>
test   %ebx,%ebx
js     11e3 <clock_set_content+0xb3>
cmp    %r12d,%ebx
jge    11e3 <clock_set_content+0xb3>
test   %eax,%eax
js     11e3 <clock_set_content+0xb3>
cmp    %r12d,%eax
jge    11e3 <clock_set_content+0xb3>
imul   %r12d,%ebx
movslq %ebx,%rcx
add    %rcx,%r15
mov    %eax,%eax
mov    %r14b,(%rax,%r15,1)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @clock_set_content(i8* %0, double %1, double %2, double %3, i8 signext %4) {
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i8 %4, i8* %10
%14 = load double, double* %9
%15 = fmul double %14, 2.000000e+00
%16 = call i32 @round(double %15)
store i32 %16, i32* %11
%17 = load double, double* %7
%18 = fdiv double %17, 1.800000e+02
%19 = load double, double* @M_PI
%20 = fmul double %18, %19
%21 = call double @sin(double %20)
%22 = load double, double* %8
%23 = load double, double* %9
%24 = call double @llvm.fmuladd.f64(double %21, double %22, double %23)
%25 = call i32 @round(double %24)
store i32 %25, i32* %12
%26 = load double, double* %7
%27 = fdiv double %26, 1.800000e+02
%28 = load double, double* @M_PI
%29 = fmul double %27, %28
%30 = call double @cos(double %29)
%31 = load double, double* %8
%32 = load double, double* %9
%33 = call double @llvm.fmuladd.f64(double %30, double %31, double %32)
%34 = call i32 @round(double %33)
store i32 %34, i32* %13
%35 = load i32, i32* %12
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %59
37: ; preds = %5
%38 = load i32, i32* %12
%39 = load i32, i32* %11
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %59
41: ; preds = %37
%42 = load i32, i32* %13
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %59
44: ; preds = %41
%45 = load i32, i32* %13
%46 = load i32, i32* %11
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %59
48: ; preds = %44
%49 = load i8, i8* %10
%50 = load i8*, i8** %6
%51 = load i32, i32* %12
%52 = load i32, i32* %11
%53 = mul nsw i32 %51, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %50, i64 %54
%56 = load i32, i32* %13
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 %49, i8* %58
br label %59
59: ; preds = %48, %44, %41, %37, %5
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @clock_set_content(i8* nocapture writeonly %0, double %1, double %2, double %3, i8 signext %4) {
%6 = fmul double %3, 2.000000e+00
%7 = tail call i32 @round(double %6)
%8 = fdiv double %1, 1.800000e+02
%9 = load double, double* @M_PI
%10 = fmul double %8, %9
%11 = tail call double @sin(double %10)
%12 = tail call double @llvm.fmuladd.f64(double %11, double %2, double %3)
%13 = tail call i32 @round(double %12)
%14 = load double, double* @M_PI
%15 = fmul double %8, %14
%16 = tail call double @cos(double %15)
%17 = tail call double @llvm.fmuladd.f64(double %16, double %2, double %3)
%18 = tail call i32 @round(double %17)
%19 = icmp sgt i32 %13, -1
br i1 %19, label %20, label %32
20: ; preds = %5
%21 = icmp slt i32 %13, %7
%22 = icmp sgt i32 %18, -1
%23 = select i1 %21, i1 %22, i1 false
%24 = icmp slt i32 %18, %7
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = mul nsw i32 %13, %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = zext i32 %18 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8 %4, i8* %31
br label %32
32: ; preds = %26, %20, %5
ret void
}