#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*/ printf(char *);
void print_a2d(int intvalue, int precision) {
  int i;
  float resist = 0, resist2;
  if (precision > 8)
    precision = 8;
  if (precision < 2)
    precision = 7;
  for (i = 1; i <= precision; i++) {
    resist2 = 1.0 / ((resist > 0 ? 1.0 / resist : 0.0) + 1.0 / (1 << i) -
                     1.0 / (1 << (precision + 1)));
    if (intvalue > (int)(0.5 + 1023.0 / (1 + resist2))) {
      resist = 1.0 / ((resist > 0 ? 1.0 / resist : 0.0) + 1.0 / (1 << i));
      printf("1");
    } else {
      printf("0");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_a2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
cmpl   $0x8,-0x8(%rbp)
jle    1137 <print_a2d+0x27>
movl   $0x8,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1148 <print_a2d+0x38>
movl   $0x7,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12ce <print_a2d+0x1be>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    118b <print_a2d+0x7b>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe83(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1198 <print_a2d+0x88>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1198 <print_a2d+0x88>
movsd  -0x20(%rbp),%xmm1
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe4d(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe2c(%rip),%xmm0
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  0xe1c(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
movss  0xe1c(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe03(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xdef(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
cmp    %ecx,%eax
jle    12af <print_a2d+0x19f>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1259 <print_a2d+0x149>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdb5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1266 <print_a2d+0x156>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1266 <print_a2d+0x156>
movsd  -0x28(%rbp),%xmm1
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm2
movsd  0xd7f(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  0xd6f(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xd77(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_a2d+0x1ab>
lea    0xd68(%rip),%rdi
call   1030 <printf@plt>
jmp    12c0 <print_a2d+0x1b0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <print_a2d+0x3f>
lea    0xd4b(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_a2d>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x8,%esi
mov    $0x8,%eax
cmovl  %esi,%eax
cmp    $0x2,%eax
mov    $0x7,%ebp
cmovge %eax,%ebp
lea    0x1(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %edi,%r14d
mov    $0x1,%ebx
cvtsi2sd %eax,%xmm0
movsd  0xeb4(%rip),%xmm3
movapd %xmm3,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
neg    %ebp
xorps  %xmm4,%xmm4
jmp    11b7 <print_a2d+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x31,%edi
call   1030 <putchar@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
movsd  0xe55(%rip),%xmm3
movss  0x4(%rsp),%xmm4
je     126b <print_a2d+0x15b>
xorpd  %xmm1,%xmm1
ucomiss 0xe5a(%rip),%xmm4
jbe    11d3 <print_a2d+0xc3>
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
movapd %xmm3,%xmm1
divsd  %xmm0,%xmm1
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movapd %xmm3,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
subsd  0x8(%rsp),%xmm1
movapd %xmm3,%xmm2
divsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
addss  0xe0c(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xdf0(%rip),%xmm2
divsd  %xmm1,%xmm2
addsd  0xdec(%rip),%xmm2
cvttsd2si %xmm2,%eax
mov    $0x30,%edi
cmp    %r14d,%eax
jge    1260 <print_a2d+0x150>
xorpd  %xmm1,%xmm1
ucomiss 0xddf(%rip),%xmm4
jbe    1170 <print_a2d+0x60>
xorps  %xmm2,%xmm2
cvtss2sd %xmm4,%xmm2
movapd %xmm3,%xmm1
divsd  %xmm2,%xmm1
jmp    1170 <print_a2d+0x60>
nopw   0x0(%rax,%rax,1)
movss  %xmm4,0x4(%rsp)
jmp    118e <print_a2d+0x7e>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_a2d(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
store i32 %0, i32* %3
store i32 %1, i32* %4
store float 0.000000e+00, float* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 8
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 8, i32* %4
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 7, i32* %4
br label %15
15: ; preds = %14, %11
store i32 1, i32* %5
br label %16
16: ; preds = %72, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %75
20: ; preds = %16
%21 = load float, float* %6
%22 = fcmp ogt float %21, 0.000000e+00
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load float, float* %6
%25 = fpext float %24 to double
%26 = fdiv double 1.000000e+00, %25
br label %28
27: ; preds = %20
br label %28
28: ; preds = %27, %23
%29 = phi double [ %26, %23 ], [ 0.000000e+00, %27 ]
%30 = load i32, i32* %5
%31 = shl i32 1, %30
%32 = sitofp i32 %31 to double
%33 = fdiv double 1.000000e+00, %32
%34 = fadd double %29, %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
%37 = shl i32 1, %36
%38 = sitofp i32 %37 to double
%39 = fdiv double 1.000000e+00, %38
%40 = fsub double %34, %39
%41 = fdiv double 1.000000e+00, %40
%42 = fptrunc double %41 to float
store float %42, float* %7
%43 = load i32, i32* %3
%44 = load float, float* %7
%45 = fadd float 1.000000e+00, %44
%46 = fpext float %45 to double
%47 = fdiv double 1.023000e+03, %46
%48 = fadd double 5.000000e-01, %47
%49 = fptosi double %48 to i32
%50 = icmp sgt i32 %43, %49
br i1 %50, label %51, label %69
51: ; preds = %28
%52 = load float, float* %6
%53 = fcmp ogt float %52, 0.000000e+00
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load float, float* %6
%56 = fpext float %55 to double
%57 = fdiv double 1.000000e+00, %56
br label %59
58: ; preds = %51
br label %59
59: ; preds = %58, %54
%60 = phi double [ %57, %54 ], [ 0.000000e+00, %58 ]
%61 = load i32, i32* %5
%62 = shl i32 1, %61
%63 = sitofp i32 %62 to double
%64 = fdiv double 1.000000e+00, %63
%65 = fadd double %60, %64
%66 = fdiv double 1.000000e+00, %65
%67 = fptrunc double %66 to float
store float %67, float* %6
%68 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %71
69: ; preds = %28
%70 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %71
71: ; preds = %69, %59
br label %72
72: ; preds = %71
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
store i32 %74, i32* %5
br label %16
75: ; preds = %16
%76 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @print_a2d(i32 %0, i32 %1) {
%3 = icmp slt i32 %1, 8
%4 = select i1 %3, i32 %1, i32 8
%5 = icmp slt i32 %4, 2
%6 = select i1 %5, i32 7, i32 %4
%7 = add nuw nsw i32 %6, 1
%8 = shl nuw nsw i32 1, %7
%9 = sitofp i32 %8 to double
%10 = fdiv double 1.000000e+00, %9
br label %11
11: ; preds = %2, %42
%12 = phi float [ 0.000000e+00, %2 ], [ %44, %42 ]
%13 = phi i32 [ 1, %2 ], [ %46, %42 ]
%14 = fcmp ogt float %12, 0.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = fpext float %12 to double
%17 = fdiv double 1.000000e+00, %16
br label %18
18: ; preds = %11, %15
%19 = phi double [ %17, %15 ], [ 0.000000e+00, %11 ]
%20 = shl nuw i32 1, %13
%21 = sitofp i32 %20 to double
%22 = fdiv double 1.000000e+00, %21
%23 = fadd double %22, %19
%24 = fsub double %23, %10
%25 = fdiv double 1.000000e+00, %24
%26 = fptrunc double %25 to float
%27 = fadd float %26, 1.000000e+00
%28 = fpext float %27 to double
%29 = fdiv double 1.023000e+03, %28
%30 = fadd double %29, 5.000000e-01
%31 = fptosi double %30 to i32
%32 = icmp slt i32 %31, %0
br i1 %32, label %33, label %42
33: ; preds = %18
br i1 %14, label %34, label %37
34: ; preds = %33
%35 = fpext float %12 to double
%36 = fdiv double 1.000000e+00, %35
br label %37
37: ; preds = %33, %34
%38 = phi double [ %36, %34 ], [ 0.000000e+00, %33 ]
%39 = fadd double %22, %38
%40 = fdiv double 1.000000e+00, %39
%41 = fptrunc double %40 to float
br label %42
42: ; preds = %18, %37
%43 = phi i32 [ 49, %37 ], [ 48, %18 ]
%44 = phi float [ %41, %37 ], [ %12, %18 ]
%45 = tail call i32 @putchar(i32 %43)
%46 = add nuw i32 %13, 1
%47 = icmp eq i32 %13, %6
br i1 %47, label %48, label %11
48: ; preds = %42
%49 = tail call i32 @putchar(i32 10)
ret void
}