#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 */
scalar_t__ ceil(double);
int pow(int, int);
int num_bits(int value) {
  int j;
  for (j = 0; j < 32; j++) {
    if (value < pow(2, j)) {
      double x = (double)j;
      int newj = (int)ceil(x / 4) * 4;
      return newj;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<num_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    11a0 <num_bits+0x80>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    118d <num_bits+0x6d>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
shl    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <num_bits+0x87>
jmp    1192 <num_bits+0x72>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <num_bits+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_bits>:
push   %rbx
mov    %edi,%ebx
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cmp    %ebx,%eax
jg     150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    115a <num_bits+0x3a>
movsd  0xeab(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    117a <num_bits+0x5a>
movsd  0xe93(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    119a <num_bits+0x7a>
movsd  0xe7b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x4,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    11ba <num_bits+0x9a>
movsd  0xe63(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x5,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    11da <num_bits+0xba>
movsd  0xe4b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x6,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    11fa <num_bits+0xda>
movsd  0xe33(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x7,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    121a <num_bits+0xfa>
movsd  0xe1b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x8,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    123a <num_bits+0x11a>
movsd  0xe03(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x9,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    125a <num_bits+0x13a>
movsd  0xdeb(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0xa,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    127a <num_bits+0x15a>
movsd  0xdd3(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0xb,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    129a <num_bits+0x17a>
movsd  0xdbb(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0xc,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    12ba <num_bits+0x19a>
movsd  0xda3(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0xd,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    12da <num_bits+0x1ba>
movsd  0xd8b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0xe,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    12fa <num_bits+0x1da>
movsd  0xd73(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0xf,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    131a <num_bits+0x1fa>
movsd  0xd5b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x10,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    133a <num_bits+0x21a>
movsd  0xd43(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x11,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    135a <num_bits+0x23a>
movsd  0xd2b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x12,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    137a <num_bits+0x25a>
movsd  0xd13(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x13,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    139a <num_bits+0x27a>
movsd  0xcfb(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x14,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    13ba <num_bits+0x29a>
movsd  0xce3(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x15,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    13da <num_bits+0x2ba>
movsd  0xccb(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x16,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    13fa <num_bits+0x2da>
movsd  0xcb3(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x17,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    141a <num_bits+0x2fa>
movsd  0xc9b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x18,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    143a <num_bits+0x31a>
movsd  0xc83(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x19,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    145a <num_bits+0x33a>
movsd  0xc6b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1a,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    147a <num_bits+0x35a>
movsd  0xc53(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1b,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    1497 <num_bits+0x377>
movsd  0xc3b(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1c,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    14b4 <num_bits+0x394>
movsd  0xc26(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1d,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    14d1 <num_bits+0x3b1>
movsd  0xc11(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1e,%esi
call   1040 <pow@plt>
cmp    %ebx,%eax
jle    14ee <num_bits+0x3ce>
movsd  0xbfc(%rip),%xmm0
jmp    150d <num_bits+0x3ed>
mov    $0x2,%edi
mov    $0x1f,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
jle    1515 <num_bits+0x3f5>
movsd  0xbe3(%rip),%xmm0
call   1030 <ceil@plt>
shl    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @num_bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 32
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = call i32 @pow(i32 2, i32 %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
store double %17, double* %5
%18 = load double, double* %5
%19 = fdiv double %18, 4.000000e+00
%20 = call i64 @ceil(double %19)
%21 = trunc i64 %20 to i32
%22 = mul nsw i32 %21, 4
store i32 %22, i32* %6
%23 = load i32, i32* %6
store i32 %23, i32* %2
br label %29
24: ; preds = %10
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %7
28: ; preds = %7
store i32 0, i32* %2
br label %29
29: ; preds = %28, %15
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @num_bits(i32 %0) {
%2 = tail call i32 @pow(i32 2, i32 0)
%3 = icmp sgt i32 %2, %0
br i1 %3, label %4, label %9
4: ; preds = %99, %96, %93, %90, %87, %84, %81, %78, %75, %72, %69, %66, %63, %60, %57, %54, %51, %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %1
%5 = phi double [ 0.000000e+00, %1 ], [ 2.500000e-01, %9 ], [ 5.000000e-01, %12 ], [ 7.500000e-01, %15 ], [ 1.000000e+00, %18 ], [ 1.250000e+00, %21 ], [ 1.500000e+00, %24 ], [ 1.750000e+00, %27 ], [ 2.000000e+00, %30 ], [ 2.250000e+00, %33 ], [ 2.500000e+00, %36 ], [ 2.750000e+00, %39 ], [ 3.000000e+00, %42 ], [ 3.250000e+00, %45 ], [ 3.500000e+00, %48 ], [ 3.750000e+00, %51 ], [ 4.000000e+00, %54 ], [ 4.250000e+00, %57 ], [ 4.500000e+00, %60 ], [ 4.750000e+00, %63 ], [ 5.000000e+00, %66 ], [ 5.250000e+00, %69 ], [ 5.500000e+00, %72 ], [ 5.750000e+00, %75 ], [ 6.000000e+00, %78 ], [ 6.250000e+00, %81 ], [ 6.500000e+00, %84 ], [ 6.750000e+00, %87 ], [ 7.000000e+00, %90 ], [ 7.250000e+00, %93 ], [ 7.500000e+00, %96 ], [ 7.750000e+00, %99 ]
%6 = tail call i64 @ceil(double %5)
%7 = trunc i64 %6 to i32
%8 = shl nsw i32 %7, 2
br label %102
9: ; preds = %1
%10 = tail call i32 @pow(i32 2, i32 1)
%11 = icmp sgt i32 %10, %0
br i1 %11, label %4, label %12
12: ; preds = %9
%13 = tail call i32 @pow(i32 2, i32 2)
%14 = icmp sgt i32 %13, %0
br i1 %14, label %4, label %15
15: ; preds = %12
%16 = tail call i32 @pow(i32 2, i32 3)
%17 = icmp sgt i32 %16, %0
br i1 %17, label %4, label %18
18: ; preds = %15
%19 = tail call i32 @pow(i32 2, i32 4)
%20 = icmp sgt i32 %19, %0
br i1 %20, label %4, label %21
21: ; preds = %18
%22 = tail call i32 @pow(i32 2, i32 5)
%23 = icmp sgt i32 %22, %0
br i1 %23, label %4, label %24
24: ; preds = %21
%25 = tail call i32 @pow(i32 2, i32 6)
%26 = icmp sgt i32 %25, %0
br i1 %26, label %4, label %27
27: ; preds = %24
%28 = tail call i32 @pow(i32 2, i32 7)
%29 = icmp sgt i32 %28, %0
br i1 %29, label %4, label %30
30: ; preds = %27
%31 = tail call i32 @pow(i32 2, i32 8)
%32 = icmp sgt i32 %31, %0
br i1 %32, label %4, label %33
33: ; preds = %30
%34 = tail call i32 @pow(i32 2, i32 9)
%35 = icmp sgt i32 %34, %0
br i1 %35, label %4, label %36
36: ; preds = %33
%37 = tail call i32 @pow(i32 2, i32 10)
%38 = icmp sgt i32 %37, %0
br i1 %38, label %4, label %39
39: ; preds = %36
%40 = tail call i32 @pow(i32 2, i32 11)
%41 = icmp sgt i32 %40, %0
br i1 %41, label %4, label %42
42: ; preds = %39
%43 = tail call i32 @pow(i32 2, i32 12)
%44 = icmp sgt i32 %43, %0
br i1 %44, label %4, label %45
45: ; preds = %42
%46 = tail call i32 @pow(i32 2, i32 13)
%47 = icmp sgt i32 %46, %0
br i1 %47, label %4, label %48
48: ; preds = %45
%49 = tail call i32 @pow(i32 2, i32 14)
%50 = icmp sgt i32 %49, %0
br i1 %50, label %4, label %51
51: ; preds = %48
%52 = tail call i32 @pow(i32 2, i32 15)
%53 = icmp sgt i32 %52, %0
br i1 %53, label %4, label %54
54: ; preds = %51
%55 = tail call i32 @pow(i32 2, i32 16)
%56 = icmp sgt i32 %55, %0
br i1 %56, label %4, label %57
57: ; preds = %54
%58 = tail call i32 @pow(i32 2, i32 17)
%59 = icmp sgt i32 %58, %0
br i1 %59, label %4, label %60
60: ; preds = %57
%61 = tail call i32 @pow(i32 2, i32 18)
%62 = icmp sgt i32 %61, %0
br i1 %62, label %4, label %63
63: ; preds = %60
%64 = tail call i32 @pow(i32 2, i32 19)
%65 = icmp sgt i32 %64, %0
br i1 %65, label %4, label %66
66: ; preds = %63
%67 = tail call i32 @pow(i32 2, i32 20)
%68 = icmp sgt i32 %67, %0
br i1 %68, label %4, label %69
69: ; preds = %66
%70 = tail call i32 @pow(i32 2, i32 21)
%71 = icmp sgt i32 %70, %0
br i1 %71, label %4, label %72
72: ; preds = %69
%73 = tail call i32 @pow(i32 2, i32 22)
%74 = icmp sgt i32 %73, %0
br i1 %74, label %4, label %75
75: ; preds = %72
%76 = tail call i32 @pow(i32 2, i32 23)
%77 = icmp sgt i32 %76, %0
br i1 %77, label %4, label %78
78: ; preds = %75
%79 = tail call i32 @pow(i32 2, i32 24)
%80 = icmp sgt i32 %79, %0
br i1 %80, label %4, label %81
81: ; preds = %78
%82 = tail call i32 @pow(i32 2, i32 25)
%83 = icmp sgt i32 %82, %0
br i1 %83, label %4, label %84
84: ; preds = %81
%85 = tail call i32 @pow(i32 2, i32 26)
%86 = icmp sgt i32 %85, %0
br i1 %86, label %4, label %87
87: ; preds = %84
%88 = tail call i32 @pow(i32 2, i32 27)
%89 = icmp sgt i32 %88, %0
br i1 %89, label %4, label %90
90: ; preds = %87
%91 = tail call i32 @pow(i32 2, i32 28)
%92 = icmp sgt i32 %91, %0
br i1 %92, label %4, label %93
93: ; preds = %90
%94 = tail call i32 @pow(i32 2, i32 29)
%95 = icmp sgt i32 %94, %0
br i1 %95, label %4, label %96
96: ; preds = %93
%97 = tail call i32 @pow(i32 2, i32 30)
%98 = icmp sgt i32 %97, %0
br i1 %98, label %4, label %99
99: ; preds = %96
%100 = tail call i32 @pow(i32 2, i32 31)
%101 = icmp sgt i32 %100, %0
br i1 %101, label %4, label %102
102: ; preds = %99, %4
%103 = phi i32 [ %8, %4 ], [ 0, %99 ]
ret i32 %103
}