#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ rankWriteNoMore(int /*<<< orphan*/ *, int, int, int);
int powerWriteNoMore(FILE *fp, int start, int value, int len) {
  int i;
  value = value < 0 ? -value : value;
  for (i = 0; value > 0; i++) {
    value /= 2;
  }
  rankWriteNoMore(fp, start, i, len);
  return 1;
}


x86 assembly (clang, -O0):
<powerWriteNoMore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    113c <powerWriteNoMore+0x2c>
xor    %eax,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <powerWriteNoMore+0x32>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1175 <powerWriteNoMore+0x65>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114f <powerWriteNoMore+0x3f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <rankWriteNoMore@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<powerWriteNoMore>:
test   %edx,%edx
je     1140 <powerWriteNoMore+0x30>
mov    %edx,%r8d
neg    %r8d
cmovs  %edx,%r8d
xor    %edx,%edx
mov    %r8d,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
shr    %eax
add    $0x1,%edx
cmp    $0x1,%r8d
mov    %eax,%r8d
ja     1130 <powerWriteNoMore+0x20>
jmp    1142 <powerWriteNoMore+0x32>
xor    %edx,%edx
push   %rax
call   1030 <rankWriteNoMore@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @powerWriteNoMore(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i32, i32* %7
%14 = sub nsw i32 0, %13
br label %17
15: ; preds = %4
%16 = load i32, i32* %7
br label %17
17: ; preds = %15, %12
%18 = phi i32 [ %14, %12 ], [ %16, %15 ]
store i32 %18, i32* %7
store i32 0, i32* %9
br label %19
19: ; preds = %25, %17
%20 = load i32, i32* %7
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %7
%24 = sdiv i32 %23, 2
store i32 %24, i32* %7
br label %25
25: ; preds = %22
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %19
28: ; preds = %19
%29 = load i32*, i32** %5
%30 = load i32, i32* %6
%31 = load i32, i32* %9
%32 = load i32, i32* %8
%33 = call i32 @rankWriteNoMore(i32* %29, i32 %30, i32 %31, i32 %32)
ret i32 1
}

LLVM IR (-O2):
define i32 @powerWriteNoMore(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %14, label %6
6: ; preds = %4
%7 = tail call i32 @llvm.abs.i32(i32 %2, i1 true)
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %12, %8 ], [ 0, %6 ]
%10 = phi i32 [ %11, %8 ], [ %7, %6 ]
%11 = lshr i32 %10, 1
%12 = add nuw nsw i32 %9, 1
%13 = icmp ult i32 %10, 2
br i1 %13, label %14, label %8
14: ; preds = %8, %4
%15 = phi i32 [ 0, %4 ], [ %12, %8 ]
%16 = tail call i32 @rankWriteNoMore(i32* %0, i32 %1, i32 %15, i32 %3)
ret i32 1
}