#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 */
typedef size_t j;
typedef scalar_t__ *dimx;

/* Variables and functions */
unsigned char UCHAR_MAX;
int /*<<< orphan*/ p3dGetElapsedTime_min();
int /*<<< orphan*/ p3dGetElapsedTime_sec();
int /*<<< orphan*/ p3dResetStartTime();
int const sqrt(double);
int p3dCreateBinaryCircle(unsigned char *out_im, const int dimx, const int dimy,
                          const int cenx, const int ceny, const int radius,
                          int (*wr_log)(const char *, ...)) {
  int i, j;
  if (wr_log != NULL) {
    p3dResetStartTime();
    wr_log("Pore3D - Creating binary circle...");
    wr_log("\tCenter: [%d, %d].", cenx, ceny);
    wr_log("\tRadius: %d.", radius);
  }
  for (j = 0; j < dimy; j++) {
    for (i = 0; i < dimx; i++) {
      if (sqrt((double)((i - cenx) * (i - cenx) + (j - ceny) * (j - ceny))) <=
          radius) {
        out_im[((j) * (dimx) + (i))] = UCHAR_MAX;
      } else {
        out_im[((j) * (dimx) + (i))] = 0;
      }
    }
  }
  if (wr_log != NULL) {
    wr_log("Pore3D - Binary circle created successfully in %dm%0.3fs.",
           p3dGetElapsedTime_min(), p3dGetElapsedTime_sec());
  }
  return 2;
}


x86 assembly (clang, -O0):
<p3dCreateBinaryCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
cmpq   $0x0,0x10(%rbp)
je     11a6 <p3dCreateBinaryCircle+0x66>
mov    $0x0,%al
call   1050 <p3dResetStartTime@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   *0x10(%rbp)
mov    0x10(%rbp),%rcx
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   *%rcx
mov    0x10(%rbp),%rcx
mov    -0x1c(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   *%rcx
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    125b <p3dCreateBinaryCircle+0x11b>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1248 <p3dCreateBinaryCircle+0x108>
mov    -0x20(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    -0x14(%rbp),%ecx
imul   %ecx,%eax
mov    -0x24(%rbp),%ecx
sub    -0x18(%rbp),%ecx
mov    -0x24(%rbp),%edx
sub    -0x18(%rbp),%edx
imul   %edx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
call   1060 <sqrt@plt>
cmp    -0x1c(%rbp),%eax
jg     1220 <p3dCreateBinaryCircle+0xe0>
mov    0x2deb(%rip),%rax
mov    (%rax),%dl
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1235 <p3dCreateBinaryCircle+0xf5>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    123a <p3dCreateBinaryCircle+0xfa>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c0 <p3dCreateBinaryCircle+0x80>
jmp    124d <p3dCreateBinaryCircle+0x10d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <p3dCreateBinaryCircle+0x6d>
cmpq   $0x0,0x10(%rbp)
je     1293 <p3dCreateBinaryCircle+0x153>
mov    0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <p3dGetElapsedTime_min@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <p3dGetElapsedTime_sec@plt>
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%rcx
mov    %eax,%edx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   *%rcx
mov    $0x2,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p3dCreateBinaryCircle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9d,%ebx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,0x8(%rsp)
mov    %rdi,0x20(%rsp)
mov    0x90(%rsp),%rbp
test   %rbp,%rbp
je     11a0 <p3dCreateBinaryCircle+0x60>
xor    %eax,%eax
call   1050 <p3dResetStartTime@plt>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   *%rbp
lea    0xe9a(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   *%rbp
lea    0xe9c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   *%rbp
mov    %ebx,0x10(%rsp)
mov    %r15d,0xc(%rsp)
mov    %r14d,0x1c(%rsp)
test   %r12d,%r12d
jle    132b <p3dCreateBinaryCircle+0x1eb>
movslq 0x8(%rsp),%rax
mov    %r12d,%ecx
mov    %rcx,0x40(%rsp)
mov    %rax,0x28(%rsp)
mov    %eax,%eax
mov    %rax,0x38(%rsp)
and    $0xfffffffe,%eax
mov    %rax,0x50(%rsp)
mov    0xc(%rsp),%eax
neg    %eax
mov    %eax,0x18(%rsp)
mov    0x20(%rsp),%rax
lea    0x1(%rax),%r14
xor    %eax,%eax
jmp    1204 <p3dCreateBinaryCircle+0xc4>
nop
add    $0x1,%rax
add    0x28(%rsp),%r14
cmp    0x40(%rsp),%rax
je     132b <p3dCreateBinaryCircle+0x1eb>
cmpl   $0x0,0x8(%rsp)
jle    11f0 <p3dCreateBinaryCircle+0xb0>
mov    %eax,%ebp
sub    0x1c(%rsp),%ebp
imul   %ebp,%ebp
cmpl   $0x1,0x8(%rsp)
mov    %rax,0x48(%rsp)
mov    %r14,0x30(%rsp)
mov    %ebp,0x14(%rsp)
jne    1240 <p3dCreateBinaryCircle+0x100>
xor    %r13d,%r13d
jmp    12c4 <p3dCreateBinaryCircle+0x184>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%eax
mov    %eax,%r12d
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %r12d,%eax
imul   %r12d,%eax
mov    0x14(%rsp),%r15d
add    %r15d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <sqrt@plt>
mov    0x10(%rsp),%ebp
cmp    %ebp,%eax
mov    0x2d78(%rip),%rbx
movzbl (%rbx),%eax
mov    $0x0,%ecx
cmovg  %ecx,%eax
mov    0x30(%rsp),%r14
mov    %al,-0x1(%r14,%r13,1)
lea    0x1(%r12),%eax
imul   %eax,%eax
add    %r15d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <sqrt@plt>
cmp    %ebp,%eax
movzbl (%rbx),%eax
mov    $0x0,%ecx
cmovg  %ecx,%eax
mov    %al,(%r14,%r13,1)
add    $0x2,%r13
add    $0x2,%r12d
cmp    %r13,0x50(%rsp)
jne    1250 <p3dCreateBinaryCircle+0x110>
mov    0x14(%rsp),%ecx
testb  $0x1,0x38(%rsp)
mov    0x2d1c(%rip),%rbx
mov    0x48(%rsp),%rax
mov    0x30(%rsp),%r14
je     11f0 <p3dCreateBinaryCircle+0xb0>
mov    %rax,%rbp
mov    %rax,%r12
imul   0x28(%rsp),%r12
mov    %r13d,%eax
sub    0xc(%rsp),%eax
imul   %eax,%eax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <sqrt@plt>
cmp    0x10(%rsp),%eax
movzbl (%rbx),%eax
mov    $0x0,%ecx
cmovg  %ecx,%eax
add    %r13,%r12
mov    0x20(%rsp),%rcx
mov    %al,(%rcx,%r12,1)
mov    %rbp,%rax
jmp    11f0 <p3dCreateBinaryCircle+0xb0>
mov    0x90(%rsp),%rbp
test   %rbp,%rbp
je     1357 <p3dCreateBinaryCircle+0x217>
xor    %eax,%eax
call   1040 <p3dGetElapsedTime_min@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <p3dGetElapsedTime_sec@plt>
lea    0xcf4(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   *%rbp
mov    $0x2,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Pore3D - Creating binary circle...\00"
@.str.1 = [19 x i8] c"\09Center: [%d, %d].\00"
@.str.2 = [13 x i8] c"\09Radius: %d.\00"
@UCHAR_MAX = global i8 0
@.str.3 = [58 x i8] c"Pore3D - Binary circle created successfully in %dm%0.3fs.\00"
define i32 @p3dCreateBinaryCircle(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 (i8*, ...)* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32 (i8*, ...)*
%15 = alloca i32
%16 = 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 i32 %5, i32* %13
store i32 (i8*, ...)* %6, i32 (i8*, ...)** %14
%17 = load i32 (i8*, ...)*, i32 (i8*, ...)** %14
%18 = icmp ne i32 (i8*, ...)* %17, null
br i1 %18, label %19, label %30
19: ; preds = %7
%20 = call i32 (...) @p3dResetStartTime()
%21 = load i32 (i8*, ...)*, i32 (i8*, ...)** %14
%22 = call i32 (i8*, ...) %21(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%23 = load i32 (i8*, ...)*, i32 (i8*, ...)** %14
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = call i32 (i8*, ...) %23(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32 (i8*, ...)*, i32 (i8*, ...)** %14
%28 = load i32, i32* %13
%29 = call i32 (i8*, ...) %27(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %19, %7
store i32 0, i32* %16
br label %31
31: ; preds = %84, %30
%32 = load i32, i32* %16
%33 = load i32, i32* %10
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %87
35: ; preds = %31
store i32 0, i32* %15
br label %36
36: ; preds = %80, %35
%37 = load i32, i32* %15
%38 = load i32, i32* %9
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %83
40: ; preds = %36
%41 = load i32, i32* %15
%42 = load i32, i32* %11
%43 = sub nsw i32 %41, %42
%44 = load i32, i32* %15
%45 = load i32, i32* %11
%46 = sub nsw i32 %44, %45
%47 = mul nsw i32 %43, %46
%48 = load i32, i32* %16
%49 = load i32, i32* %12
%50 = sub nsw i32 %48, %49
%51 = load i32, i32* %16
%52 = load i32, i32* %12
%53 = sub nsw i32 %51, %52
%54 = mul nsw i32 %50, %53
%55 = add nsw i32 %47, %54
%56 = sitofp i32 %55 to double
%57 = call i32 @sqrt(double %56)
%58 = load i32, i32* %13
%59 = icmp sle i32 %57, %58
br i1 %59, label %60, label %70
60: ; preds = %40
%61 = load i8, i8* @UCHAR_MAX
%62 = load i8*, i8** %8
%63 = load i32, i32* %16
%64 = load i32, i32* %9
%65 = mul nsw i32 %63, %64
%66 = load i32, i32* %15
%67 = add nsw i32 %65, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %62, i64 %68
store i8 %61, i8* %69
br label %79
70: ; preds = %40
%71 = load i8*, i8** %8
%72 = load i32, i32* %16
%73 = load i32, i32* %9
%74 = mul nsw i32 %72, %73
%75 = load i32, i32* %15
%76 = add nsw i32 %74, %75
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %71, i64 %77
store i8 0, i8* %78
br label %79
79: ; preds = %70, %60
br label %80
80: ; preds = %79
%81 = load i32, i32* %15
%82 = add nsw i32 %81, 1
store i32 %82, i32* %15
br label %36
83: ; preds = %36
br label %84
84: ; preds = %83
%85 = load i32, i32* %16
%86 = add nsw i32 %85, 1
store i32 %86, i32* %16
br label %31
87: ; preds = %31
%88 = load i32 (i8*, ...)*, i32 (i8*, ...)** %14
%89 = icmp ne i32 (i8*, ...)* %88, null
br i1 %89, label %90, label %95
90: ; preds = %87
%91 = load i32 (i8*, ...)*, i32 (i8*, ...)** %14
%92 = call i32 (...) @p3dGetElapsedTime_min()
%93 = call i32 (...) @p3dGetElapsedTime_sec()
%94 = call i32 (i8*, ...) %91(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %92, i32 %93)
br label %95
95: ; preds = %90, %87
ret i32 2
}

LLVM IR (-O2):
@.str = [35 x i8] c"Pore3D - Creating binary circle...\00"
@.str.1 = [19 x i8] c"\09Center: [%d, %d].\00"
@.str.2 = [13 x i8] c"\09Radius: %d.\00"
@UCHAR_MAX = global i8 0
@.str.3 = [58 x i8] c"Pore3D - Binary circle created successfully in %dm%0.3fs.\00"
define i32 @p3dCreateBinaryCircle(i8* nocapture writeonly %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 (i8*, ...)* %6) {
%8 = icmp eq i32 (i8*, ...)* %6, null
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = tail call i32 (...) @p3dResetStartTime()
%11 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4)
%13 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %14
14: ; preds = %9, %7
%15 = icmp sgt i32 %2, 0
br i1 %15, label %16, label %78
16: ; preds = %14
%17 = icmp sgt i32 %1, 0
%18 = sext i32 %1 to i64
%19 = zext i32 %2 to i64
%20 = zext i32 %1 to i64
%21 = and i64 %20, 1
%22 = icmp eq i32 %1, 1
%23 = and i64 %20, 4294967294
%24 = icmp eq i64 %21, 0
br label %25
25: ; preds = %16, %75
%26 = phi i64 [ 0, %16 ], [ %76, %75 ]
br i1 %17, label %27, label %75
27: ; preds = %25
%28 = trunc i64 %26 to i32
%29 = sub i32 %28, %4
%30 = mul nsw i32 %29, %29
%31 = mul nsw i64 %26, %18
br i1 %22, label %61, label %32
32: ; preds = %27, %32
%33 = phi i64 [ %58, %32 ], [ 0, %27 ]
%34 = phi i64 [ %59, %32 ], [ 0, %27 ]
%35 = trunc i64 %33 to i32
%36 = sub nsw i32 %35, %3
%37 = mul nsw i32 %36, %36
%38 = add nuw nsw i32 %37, %30
%39 = sitofp i32 %38 to double
%40 = tail call i32 @sqrt(double %39)
%41 = icmp sgt i32 %40, %5
%42 = load i8, i8* @UCHAR_MAX
%43 = select i1 %41, i8 0, i8 %42
%44 = add nsw i64 %33, %31
%45 = getelementptr inbounds i8, i8* %0, i64 %44
store i8 %43, i8* %45
%46 = or i64 %33, 1
%47 = trunc i64 %46 to i32
%48 = sub nsw i32 %47, %3
%49 = mul nsw i32 %48, %48
%50 = add nuw nsw i32 %49, %30
%51 = sitofp i32 %50 to double
%52 = tail call i32 @sqrt(double %51)
%53 = icmp sgt i32 %52, %5
%54 = load i8, i8* @UCHAR_MAX
%55 = select i1 %53, i8 0, i8 %54
%56 = add nsw i64 %46, %31
%57 = getelementptr inbounds i8, i8* %0, i64 %56
store i8 %55, i8* %57
%58 = add nuw nsw i64 %33, 2
%59 = add i64 %34, 2
%60 = icmp eq i64 %59, %23
br i1 %60, label %61, label %32
61: ; preds = %32, %27
%62 = phi i64 [ 0, %27 ], [ %58, %32 ]
br i1 %24, label %75, label %63
63: ; preds = %61
%64 = trunc i64 %62 to i32
%65 = sub nsw i32 %64, %3
%66 = mul nsw i32 %65, %65
%67 = add nuw nsw i32 %66, %30
%68 = sitofp i32 %67 to double
%69 = tail call i32 @sqrt(double %68)
%70 = icmp sgt i32 %69, %5
%71 = load i8, i8* @UCHAR_MAX
%72 = select i1 %70, i8 0, i8 %71
%73 = add nsw i64 %62, %31
%74 = getelementptr inbounds i8, i8* %0, i64 %73
store i8 %72, i8* %74
br label %75
75: ; preds = %63, %61, %25
%76 = add nuw nsw i64 %26, 1
%77 = icmp eq i64 %76, %19
br i1 %77, label %78, label %25
78: ; preds = %75, %14
br i1 %8, label %83, label %79
79: ; preds = %78
%80 = tail call i32 (...) @p3dGetElapsedTime_min()
%81 = tail call i32 (...) @p3dGetElapsedTime_sec()
%82 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %80, i32 %81)
br label %83
83: ; preds = %79, %78
ret i32 2
}