#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__ pow(double, double);
int /*<<< orphan*/ printf(char *);
void SET_BITS_TO(int LOW_BIT, int HIGH_BIT, int VALUE, char *CODE) {
  int I;
  int BIT;
  int VALUE_BIT;
  if ((HIGH_BIT < LOW_BIT) || (HIGH_BIT >= 32))
    (void)printf("SET_BITS_TO called improperly.\n");
  else {
    BIT = HIGH_BIT;
    for (I = ((int)pow(2.0, 1.0 * (HIGH_BIT - LOW_BIT))); I > 0; I /= 2) {
      VALUE_BIT = VALUE - (VALUE / 2) * 2;
      VALUE /= 2;
      CODE[BIT] = ((char)VALUE_BIT) + '0';
      BIT--;
    }
    if (VALUE != 0)
      (void)printf("SET_BITS_TO called improperly, VALUE too large.\n");
  }
}


x86 assembly (clang, -O0):
<SET_BITS_TO>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     114b <SET_BITS_TO+0x2b>
cmpl   $0x20,-0x8(%rbp)
jl     115c <SET_BITS_TO+0x3c>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <SET_BITS_TO+0xeb>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe94(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe80(%rip),%xmm0
call   1040 <pow@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11f0 <SET_BITS_TO+0xd0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x24(%rbp),%eax
movsbl %al,%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    1188 <SET_BITS_TO+0x68>
cmpl   $0x0,-0xc(%rbp)
je     1206 <SET_BITS_TO+0xe6>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <SET_BITS_TO+0xeb>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SET_BITS_TO>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%rbx
mov    %edi,%eax
mov    %esi,%ecx
lea    0xf06(%rip),%rdi
sub    %eax,%ecx
jl     1194 <SET_BITS_TO+0x74>
mov    %esi,%r14d
cmp    $0x1f,%esi
jg     1194 <SET_BITS_TO+0x74>
mov    %edx,%ebp
cvtsi2sd %ecx,%xmm1
movsd  0xeb4(%rip),%xmm0
call   1040 <pow@plt>
test   %eax,%eax
jle    119d <SET_BITS_TO+0x7d>
movslq %r14d,%rcx
add    %rcx,%rbx
mov    %eax,%ecx
nopl   (%rax)
mov    %ebp,%esi
shr    $0x1f,%esi
add    %ebp,%esi
mov    %esi,%edx
sar    %edx
and    $0xfe,%esi
sub    %esi,%ebp
add    $0x30,%bpl
mov    %bpl,(%rbx)
shr    %ecx
add    $0xffffffffffffffff,%rbx
mov    %edx,%ebp
cmp    $0x1,%eax
mov    %ecx,%eax
ja     1160 <SET_BITS_TO+0x40>
test   %edx,%edx
je     11a3 <SET_BITS_TO+0x83>
lea    0xe74(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
mov    %ebp,%edx
test   %edx,%edx
jne    118d <SET_BITS_TO+0x6d>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"SET_BITS_TO called improperly.\0A\00"
@.str.1 = [49 x i8] c"SET_BITS_TO called improperly, VALUE too large.\0A\00"
define void @SET_BITS_TO(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %18, label %15
15: ; preds = %4
%16 = load i32, i32* %6
%17 = icmp sge i32 %16, 32
br i1 %17, label %18, label %20
18: ; preds = %15, %4
%19 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %60
20: ; preds = %15
%21 = load i32, i32* %6
store i32 %21, i32* %10
%22 = load i32, i32* %6
%23 = load i32, i32* %5
%24 = sub nsw i32 %22, %23
%25 = sitofp i32 %24 to double
%26 = fmul double 1.000000e+00, %25
%27 = call i64 @pow(double 2.000000e+00, double %26)
%28 = trunc i64 %27 to i32
store i32 %28, i32* %9
br label %29
29: ; preds = %51, %20
%30 = load i32, i32* %9
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %54
32: ; preds = %29
%33 = load i32, i32* %7
%34 = load i32, i32* %7
%35 = sdiv i32 %34, 2
%36 = mul nsw i32 %35, 2
%37 = sub nsw i32 %33, %36
store i32 %37, i32* %11
%38 = load i32, i32* %7
%39 = sdiv i32 %38, 2
store i32 %39, i32* %7
%40 = load i32, i32* %11
%41 = trunc i32 %40 to i8
%42 = sext i8 %41 to i32
%43 = add nsw i32 %42, 48
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %8
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 %44, i8* %48
%49 = load i32, i32* %10
%50 = add nsw i32 %49, -1
store i32 %50, i32* %10
br label %51
51: ; preds = %32
%52 = load i32, i32* %9
%53 = sdiv i32 %52, 2
store i32 %53, i32* %9
br label %29
54: ; preds = %29
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %59
59: ; preds = %57, %54
br label %60
60: ; preds = %59, %18
ret void
}

LLVM IR (-O2):
@str = [48 x i8] c"SET_BITS_TO called improperly, VALUE too large.\00"
@str.2 = [31 x i8] c"SET_BITS_TO called improperly.\00"
define void @SET_BITS_TO(i32 %0, i32 %1, i32 %2, i8* nocapture writeonly %3) {
%5 = icmp slt i32 %1, %0
%6 = icmp sgt i32 %1, 31
%7 = or i1 %5, %6
br i1 %7, label %32, label %8
8: ; preds = %4
%9 = sub nsw i32 %1, %0
%10 = sitofp i32 %9 to double
%11 = tail call i64 @pow(double 2.000000e+00, double %10)
%12 = trunc i64 %11 to i32
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %8
%15 = sext i32 %1 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ %15, %14 ], [ %26, %16 ]
%18 = phi i32 [ %2, %14 ], [ %20, %16 ]
%19 = phi i32 [ %12, %14 ], [ %27, %16 ]
%20 = sdiv i32 %18, 2
%21 = mul i32 %20, -2
%22 = add i32 %21, %18
%23 = trunc i32 %22 to i8
%24 = add i8 %23, 48
%25 = getelementptr inbounds i8, i8* %3, i64 %17
store i8 %24, i8* %25
%26 = add nsw i64 %17, -1
%27 = lshr i32 %19, 1
%28 = icmp ult i32 %19, 2
br i1 %28, label %29, label %16
29: ; preds = %16, %8
%30 = phi i32 [ %2, %8 ], [ %20, %16 ]
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29, %4
%33 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0), %29 ]
%34 = tail call i32 @puts(i8* dereferenceable(1) %33)
br label %35
35: ; preds = %32, %29
ret void
}