#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*/ drawline(int, int, int, int);
int /*<<< orphan*/ drawtext(int, int, char *);
int log10(double);
int /*<<< orphan*/ sprintf(char *, char *, int);
void draw_revlogscale(int ox, int oy, int axes_point_up) {
  int f, x, orient;
  double a;
  orient = (axes_point_up ? -1 : 1);
  for (f = 0, a = 1.; f <= 900; f++, a += 0.01) {
    x = (int)(log10(a) * (480 - 4 * 8));
    if (x >= (480 - 4 * 8))
      x = (480 - 4 * 8) - 1;
    x = ox + (480 - 4 * 8) - 1 - x;
    if (f < 100 && f % 2 == 0)
      drawline(x, oy, x, oy + orient * (1 - 1));
    if (f >= 100 && f < 4 * 100 && f % 5 == 0)
      drawline(x, oy, x, oy + orient * (1 - 1));
    if (f % 10 == 0)
      drawline(x, oy, x, oy + orient * (2 - 1));
    if (f % 50 == 0)
      drawline(x, oy, x, oy + orient * (3 - 1));
    if (f % 100 == 0) {
      static char buf[10];
      drawline(x, oy, x, oy + orient * (4 - 1));
      sprintf(buf, "%d", 1 + f / 100);
      drawtext(x - 1, oy + orient * (4 - 1) + (orient == 1 ? 2 : -6), buf);
    }
  }
}


x86 assembly (clang, -O0):
<draw_revlogscale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x384,-0x10(%rbp)
jg     1334 <draw_revlogscale+0x1f4>
movsd  -0x20(%rbp),%xmm0
call   1040 <log10@plt>
imul   $0x1c0,%eax,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1c0,-0x14(%rbp)
jl     11af <draw_revlogscale+0x6f>
movl   $0x1bf,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1c0,%eax
sub    $0x1,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0x10(%rbp)
jge    11f5 <draw_revlogscale+0xb5>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f5 <draw_revlogscale+0xb5>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   $0x0,-0x18(%rbp),%eax
add    %eax,%ecx
call   1060 <drawline@plt>
cmpl   $0x64,-0x10(%rbp)
jl     1237 <draw_revlogscale+0xf7>
cmpl   $0x190,-0x10(%rbp)
jge    1237 <draw_revlogscale+0xf7>
mov    -0x10(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1237 <draw_revlogscale+0xf7>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   $0x0,-0x18(%rbp),%eax
add    %eax,%ecx
call   1060 <drawline@plt>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1264 <draw_revlogscale+0x124>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%eax
shl    $0x0,%eax
add    %eax,%ecx
call   1060 <drawline@plt>
mov    -0x10(%rbp),%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1291 <draw_revlogscale+0x151>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
add    %eax,%ecx
call   1060 <drawline@plt>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    130f <draw_revlogscale+0x1cf>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   $0x3,-0x18(%rbp),%eax
add    %eax,%ecx
call   1060 <drawline@plt>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x1,%edx
lea    0x2d6e(%rip),%rdi
lea    0xd36(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
imul   $0x3,-0x18(%rbp),%eax
add    %eax,%esi
mov    -0x18(%rbp),%edx
mov    $0xfffffffa,%eax
mov    $0x2,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
add    %eax,%esi
lea    0x2d37(%rip),%rdx
call   1030 <drawtext@plt>
jmp    1314 <draw_revlogscale+0x1d4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movsd  0xce3(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    117b <draw_revlogscale+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_revlogscale>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r12d
mov    %edi,%r14d
xor    %eax,%eax
test   %edx,%edx
sete   %al
neg    %edx
sbb    %ecx,%ecx
or     $0x1,%ecx
add    $0x1bf,%r14d
lea    (%r12,%rcx,2),%edx
mov    %edx,0x1c(%rsp)
lea    (%rcx,%rcx,2),%edx
add    %esi,%ecx
mov    %ecx,0x18(%rsp)
add    %esi,%edx
mov    %rdx,0x20(%rsp)
lea    (%rdx,%rax,8),%eax
add    $0xfffffffa,%eax
mov    %eax,0x14(%rsp)
xor    %r13d,%r13d
movsd  0xe6a(%rip),%xmm0
mov    $0x1bf,%ebx
jmp    11b9 <draw_revlogscale+0x79>
nopl   (%rax)
add    $0x1,%r13d
addsd  0xe5c(%rip),%xmm0
cmp    $0x385,%r13d
je     12f0 <draw_revlogscale+0x1b0>
movsd  %xmm0,0x8(%rsp)
call   1040 <log10@plt>
imul   $0x1c0,%eax,%eax
cmp    $0x1bf,%eax
cmovge %ebx,%eax
mov    %r14d,%ebp
sub    %eax,%ebp
cmp    $0x63,%r13d
ja     11e5 <draw_revlogscale+0xa5>
mov    %r13d,%eax
and    $0x1,%eax
je     120d <draw_revlogscale+0xcd>
lea    -0x64(%r13),%eax
cmp    $0x12b,%eax
ja     121c <draw_revlogscale+0xdc>
movzwl %r13w,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
lea    (%rax,%rax,4),%eax
neg    %eax
movzwl %ax,%eax
add    %r13d,%eax
test   %ax,%ax
jne    121c <draw_revlogscale+0xdc>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1060 <drawline@plt>
movsd  0x8(%rsp),%xmm0
imul   $0xffffcccd,%r13d,%eax
ror    %ax
movzwl %ax,%eax
cmp    $0x1999,%eax
ja     124c <draw_revlogscale+0x10c>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    0x18(%rsp),%ecx
call   1060 <drawline@plt>
movsd  0x8(%rsp),%xmm0
imul   $0x5c29,%r13d,%eax
ror    %ax
movzwl %ax,%eax
cmp    $0x51e,%eax
ja     1276 <draw_revlogscale+0x136>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    0x1c(%rsp),%ecx
call   1060 <drawline@plt>
movsd  0x8(%rsp),%xmm0
movzwl %r13w,%eax
imul   $0x5c29,%eax,%ecx
ror    $0x2,%cx
movzwl %cx,%ecx
cmp    $0x28f,%ecx
ja     11a0 <draw_revlogscale+0x60>
shr    $0x2,%eax
imul   $0x147b,%eax,%r15d
shr    $0x11,%r15d
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    0x20(%rsp),%rcx
call   1060 <drawline@plt>
movzwl %r15w,%edx
add    $0x1,%edx
lea    0x2d81(%rip),%rbx
mov    %rbx,%rdi
lea    0xd46(%rip),%rsi
call   1050 <sprintf@plt>
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    0x14(%rsp),%esi
mov    %rbx,%rdx
mov    $0x1bf,%ebx
call   1030 <drawtext@plt>
movsd  0x8(%rsp),%xmm0
jmp    11a0 <draw_revlogscale+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@draw_revlogscale.buf = internal global [10 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define void @draw_revlogscale(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 -1, i32 1
store i32 %14, i32* %9
store i32 0, i32* %7
store double 1.000000e+00, double* %10
br label %15
15: ; preds = %121, %3
%16 = load i32, i32* %7
%17 = icmp sle i32 %16, 900
br i1 %17, label %18, label %126
18: ; preds = %15
%19 = load double, double* %10
%20 = call i32 @log10(double %19)
%21 = mul nsw i32 %20, 448
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp sge i32 %22, 448
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 447, i32* %8
br label %25
25: ; preds = %24, %18
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 448
%28 = sub nsw i32 %27, 1
%29 = load i32, i32* %8
%30 = sub nsw i32 %28, %29
store i32 %30, i32* %8
%31 = load i32, i32* %7
%32 = icmp slt i32 %31, 100
br i1 %32, label %33, label %46
33: ; preds = %25
%34 = load i32, i32* %7
%35 = srem i32 %34, 2
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i32, i32* %8
%39 = load i32, i32* %5
%40 = load i32, i32* %8
%41 = load i32, i32* %5
%42 = load i32, i32* %9
%43 = mul nsw i32 %42, 0
%44 = add nsw i32 %41, %43
%45 = call i32 @drawline(i32 %38, i32 %39, i32 %40, i32 %44)
br label %46
46: ; preds = %37, %33, %25
%47 = load i32, i32* %7
%48 = icmp sge i32 %47, 100
br i1 %48, label %49, label %65
49: ; preds = %46
%50 = load i32, i32* %7
%51 = icmp slt i32 %50, 400
br i1 %51, label %52, label %65
52: ; preds = %49
%53 = load i32, i32* %7
%54 = srem i32 %53, 5
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %52
%57 = load i32, i32* %8
%58 = load i32, i32* %5
%59 = load i32, i32* %8
%60 = load i32, i32* %5
%61 = load i32, i32* %9
%62 = mul nsw i32 %61, 0
%63 = add nsw i32 %60, %62
%64 = call i32 @drawline(i32 %57, i32 %58, i32 %59, i32 %63)
br label %65
65: ; preds = %56, %52, %49, %46
%66 = load i32, i32* %7
%67 = srem i32 %66, 10
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %78
69: ; preds = %65
%70 = load i32, i32* %8
%71 = load i32, i32* %5
%72 = load i32, i32* %8
%73 = load i32, i32* %5
%74 = load i32, i32* %9
%75 = mul nsw i32 %74, 1
%76 = add nsw i32 %73, %75
%77 = call i32 @drawline(i32 %70, i32 %71, i32 %72, i32 %76)
br label %78
78: ; preds = %69, %65
%79 = load i32, i32* %7
%80 = srem i32 %79, 50
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %91
82: ; preds = %78
%83 = load i32, i32* %8
%84 = load i32, i32* %5
%85 = load i32, i32* %8
%86 = load i32, i32* %5
%87 = load i32, i32* %9
%88 = mul nsw i32 %87, 2
%89 = add nsw i32 %86, %88
%90 = call i32 @drawline(i32 %83, i32 %84, i32 %85, i32 %89)
br label %91
91: ; preds = %82, %78
%92 = load i32, i32* %7
%93 = srem i32 %92, 100
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %120
95: ; preds = %91
%96 = load i32, i32* %8
%97 = load i32, i32* %5
%98 = load i32, i32* %8
%99 = load i32, i32* %5
%100 = load i32, i32* %9
%101 = mul nsw i32 %100, 3
%102 = add nsw i32 %99, %101
%103 = call i32 @drawline(i32 %96, i32 %97, i32 %98, i32 %102)
%104 = load i32, i32* %7
%105 = sdiv i32 %104, 100
%106 = add nsw i32 1, %105
%107 = call i32 @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @draw_revlogscale.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %8
%109 = sub nsw i32 %108, 1
%110 = load i32, i32* %5
%111 = load i32, i32* %9
%112 = mul nsw i32 %111, 3
%113 = add nsw i32 %110, %112
%114 = load i32, i32* %9
%115 = icmp eq i32 %114, 1
%116 = zext i1 %115 to i64
%117 = select i1 %115, i32 2, i32 -6
%118 = add nsw i32 %113, %117
%119 = call i32 @drawtext(i32 %109, i32 %118, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @draw_revlogscale.buf, i64 0, i64 0))
br label %120
120: ; preds = %95, %91
br label %121
121: ; preds = %120
%122 = load i32, i32* %7
%123 = add nsw i32 %122, 1
store i32 %123, i32* %7
%124 = load double, double* %10
%125 = fadd double %124, 1.000000e-02
store double %125, double* %10
br label %15
126: ; preds = %15
ret void
}

LLVM IR (-O2):
@draw_revlogscale.buf = internal global [10 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define void @draw_revlogscale(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i32 1, i32 -1
%6 = add nsw i32 %0, 447
%7 = add nsw i32 %5, %1
%8 = shl nsw i32 %5, 1
%9 = add nsw i32 %8, %1
%10 = mul nsw i32 %5, 3
%11 = add nsw i32 %10, %1
%12 = select i1 %4, i32 2, i32 -6
%13 = add nsw i32 %11, %12
br label %14
14: ; preds = %3, %60
%15 = phi double [ 1.000000e+00, %3 ], [ %62, %60 ]
%16 = phi i32 [ 0, %3 ], [ %61, %60 ]
%17 = tail call i32 @log10(double %15)
%18 = mul nsw i32 %17, 448
%19 = icmp slt i32 %18, 447
%20 = select i1 %19, i32 %18, i32 447
%21 = sub i32 %6, %20
%22 = icmp ult i32 %16, 100
%23 = and i32 %16, 1
%24 = icmp eq i32 %23, 0
%25 = and i1 %22, %24
br i1 %25, label %26, label %29
26: ; preds = %14
%27 = tail call i32 @drawline(i32 %21, i32 %1, i32 %21, i32 %1)
%28 = trunc i32 %16 to i16
br label %38
29: ; preds = %14
%30 = add nsw i32 %16, -100
%31 = icmp ult i32 %30, 300
%32 = trunc i32 %16 to i16
%33 = urem i16 %32, 5
%34 = icmp eq i16 %33, 0
%35 = and i1 %31, %34
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = tail call i32 @drawline(i32 %21, i32 %1, i32 %21, i32 %1)
br label %38
38: ; preds = %26, %36, %29
%39 = phi i16 [ %28, %26 ], [ %32, %36 ], [ %32, %29 ]
%40 = urem i16 %39, 10
%41 = icmp eq i16 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = tail call i32 @drawline(i32 %21, i32 %1, i32 %21, i32 %7)
br label %44
44: ; preds = %42, %38
%45 = urem i16 %39, 50
%46 = icmp eq i16 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = tail call i32 @drawline(i32 %21, i32 %1, i32 %21, i32 %9)
br label %49
49: ; preds = %47, %44
%50 = urem i16 %39, 100
%51 = udiv i16 %39, 100
%52 = icmp eq i16 %50, 0
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = tail call i32 @drawline(i32 %21, i32 %1, i32 %21, i32 %11)
%55 = add nuw nsw i16 %51, 1
%56 = zext i16 %55 to i32
%57 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @draw_revlogscale.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = add nsw i32 %21, -1
%59 = tail call i32 @drawtext(i32 %58, i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @draw_revlogscale.buf, i64 0, i64 0))
br label %60
60: ; preds = %49, %53
%61 = add nuw nsw i32 %16, 1
%62 = fadd double %15, 1.000000e-02
%63 = icmp eq i32 %61, 901
br i1 %63, label %64, label %14
64: ; preds = %60
ret void
}