#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 atof(char *);
double evaluate_expression(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, double);
int /*<<< orphan*/ generate_expression(char *, char *);
int /*<<< orphan*/ init();
int /*<<< orphan*/ printf(char *, char *, double);
int /*<<< orphan*/ stderr;
int main(int c, char **v) {
  char expr[64];
  double goal = c >= 2 ? atof(v[1]) : 10958;
  char *digits = c == 3 ? v[2] : "123456789";
  double result = -1;
  init();
  while (result != goal) {
    generate_expression(expr, digits);
    result = evaluate_expression(expr);
    if (result == goal) {
      printf("%s= %f\n", expr, result);
    } else if ((result > goal && result < goal + 1) ||
               (result < goal && result > goal - 1)) {
      fprintf(stderr, "%s= %f (CLOSE)\n", expr, result);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1198 <main+0x38>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
mov    %eax,-0x6c(%rbp)
jmp    11a5 <main+0x45>
mov    $0x2ace,%eax
mov    %eax,-0x6c(%rbp)
jmp    11a5 <main+0x45>
mov    -0x6c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x58(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11cc <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
jmp    11dc <main+0x7c>
lea    0xe3d(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    11dc <main+0x7c>
mov    -0x78(%rbp),%rax
mov    %rax,-0x60(%rbp)
movsd  0xe14(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    $0x0,%al
call   1060 <init@plt>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x58(%rbp),%xmm0
jne    1213 <main+0xb3>
jp     1213 <main+0xb3>
jmp    12e6 <main+0x186>
lea    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1070 <generate_expression@plt>
lea    -0x50(%rbp),%rdi
call   1080 <evaluate_expression@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
ucomisd -0x58(%rbp),%xmm0
jne    125e <main+0xfe>
jp     125e <main+0xfe>
lea    -0x50(%rbp),%rsi
movsd  -0x68(%rbp),%xmm0
lea    0xdc6(%rip),%rdi
call   1040 <printf@plt>
jmp    12e1 <main+0x181>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    128a <main+0x12a>
movsd  -0x68(%rbp),%xmm1
movsd  0xd8d(%rip),%xmm0
addsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     12be <main+0x15e>
movsd  -0x68(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12dc <main+0x17c>
movsd  -0x68(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  0xd58(%rip),%xmm2
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    12dc <main+0x17c>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
movsd  -0x68(%rbp),%xmm0
lea    0xd4b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    12e1 <main+0x181>
jmp    11f8 <main+0x98>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
cmp    $0x1,%edi
jle    118d <main+0x2d>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
mov    %eax,%r15d
cmp    $0x3,%ebp
jne    11a5 <main+0x45>
mov    0x10(%rbx),%r14
jmp    11ac <main+0x4c>
xor    %eax,%eax
call   1060 <init@plt>
movsd  0xe64(%rip),%xmm2
lea    0xe75(%rip),%r14
jmp    11c2 <main+0x62>
lea    0xe6c(%rip),%r14
xor    %eax,%eax
call   1060 <init@plt>
cmp    $0xffffffff,%r15d
je     1280 <main+0x120>
cvtsi2sd %r15d,%xmm2
movsd  0xe3e(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xe34(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0x20(%rsp),%rbx
lea    0xe30(%rip),%r15
mov    0x2de7(%rip),%rbp
lea    0xe2a(%rip),%r12
movsd  %xmm2,(%rsp)
jmp    122e <main+0xce>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm2
ucomisd %xmm2,%xmm0
jne    122e <main+0xce>
jnp    1280 <main+0x120>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <generate_expression@plt>
mov    %rbx,%rdi
call   1080 <evaluate_expression@plt>
movsd  (%rsp),%xmm2
ucomisd %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
jne    1254 <main+0xf4>
jnp    1210 <main+0xb0>
jbe    1262 <main+0x102>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1270 <main+0x110>
ucomisd %xmm0,%xmm2
jbe    1226 <main+0xc6>
ucomisd 0x10(%rsp),%xmm0
jbe    1226 <main+0xc6>
mov    0x0(%rbp),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
jmp    121b <main+0xbb>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"123456789\00"
@.str.1 = [8 x i8] c"%s= %f\0A\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"%s= %f (CLOSE)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8]
%7 = alloca double
%8 = alloca i8*
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atof(i8* %15)
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %12
%19 = phi i32 [ %16, %12 ], [ 10958, %17 ]
%20 = sitofp i32 %19 to double
store double %20, double* %7
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
br label %28
27: ; preds = %18
br label %28
28: ; preds = %27, %23
%29 = phi i8* [ %26, %23 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %27 ]
store i8* %29, i8** %8
store double -1.000000e+00, double* %9
%30 = call i32 (...) @init()
br label %31
31: ; preds = %72, %28
%32 = load double, double* %9
%33 = load double, double* %7
%34 = fcmp une double %32, %33
br i1 %34, label %35, label %73
35: ; preds = %31
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%37 = load i8*, i8** %8
%38 = call i32 @generate_expression(i8* %36, i8* %37)
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%40 = call double @evaluate_expression(i8* %39)
store double %40, double* %9
%41 = load double, double* %9
%42 = load double, double* %7
%43 = fcmp oeq double %41, %42
br i1 %43, label %44, label %48
44: ; preds = %35
%45 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%46 = load double, double* %9
%47 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %45, double %46)
br label %72
48: ; preds = %35
%49 = load double, double* %9
%50 = load double, double* %7
%51 = fcmp ogt double %49, %50
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load double, double* %9
%54 = load double, double* %7
%55 = fadd double %54, 1.000000e+00
%56 = fcmp olt double %53, %55
br i1 %56, label %66, label %57
57: ; preds = %52, %48
%58 = load double, double* %9
%59 = load double, double* %7
%60 = fcmp olt double %58, %59
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = load double, double* %9
%63 = load double, double* %7
%64 = fsub double %63, 1.000000e+00
%65 = fcmp ogt double %62, %64
br i1 %65, label %66, label %71
66: ; preds = %61, %52
%67 = load i32, i32* @stderr
%68 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%69 = load double, double* %9
%70 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %68, double %69)
br label %71
71: ; preds = %66, %61, %57
br label %72
72: ; preds = %71, %44
br label %31
73: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"123456789\00"
@.str.1 = [8 x i8] c"%s= %f\0A\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"%s= %f (CLOSE)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 (...) @init()
br label %21
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atof(i8* %10)
%12 = sitofp i32 %11 to double
%13 = icmp eq i32 %0, 3
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
br label %17
17: ; preds = %8, %14
%18 = phi i8* [ %16, %14 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %8 ]
%19 = tail call i32 (...) @init()
%20 = icmp eq i32 %11, -1
br i1 %20, label %45, label %21
21: ; preds = %6, %17
%22 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %6 ], [ %18, %17 ]
%23 = phi double [ 1.095800e+04, %6 ], [ %12, %17 ]
%24 = fadd double %23, 1.000000e+00
%25 = fadd double %23, -1.000000e+00
br label %26
26: ; preds = %21, %43
%27 = call i32 @generate_expression(i8* %4, i8* %22)
%28 = call double @evaluate_expression(i8* %4)
%29 = fcmp oeq double %28, %23
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %4, double %28)
br label %43
32: ; preds = %26
%33 = fcmp ogt double %28, %23
%34 = fcmp olt double %28, %24
%35 = and i1 %33, %34
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = fcmp olt double %28, %23
%38 = fcmp ogt double %28, %25
%39 = and i1 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36, %32
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %4, double %28)
br label %43
43: ; preds = %36, %40, %30
%44 = fcmp une double %28, %23
br i1 %44, label %26, label %45
45: ; preds = %43, %17
ret i32 0
}