#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 */
double atof(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fscanf(int /*<<< orphan*/, char *, double *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  double val, threshold;
  if (argc < 2) {
    fprintf(stderr, "usage: %s <threshold> < inFile\n", argv[0]);
    fprintf(stderr, "It coverts a real sequence into a binary sequence given a "
                    "threshold.\n");
    exit(1);
  }
  threshold = atof(argv[1]);
  while (fscanf(stdin, "%lf", &val) == 1) {
    if (val > threshold) {
      fprintf(stdout, "1\n");
    } else {
      fprintf(stdout, "0\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119f <main+0x5f>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    121b <main+0xdb>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11ff <main+0xbf>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1216 <main+0xd6>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11b1 <main+0x71>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jle    11f2 <main+0xb2>
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x2e7b(%rip),%r15
mov    (%r15),%edi
lea    0xeef(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11e1 <main+0xa1>
mov    0x2e43(%rip),%r12
lea    0xed6(%rip),%r13
lea    0xed2(%rip),%rbp
lea    0xec4(%rip),%r14
lea    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
ucomisd 0x10(%rsp),%xmm0
mov    (%r12),%edi
mov    %rbp,%rsi
cmova  %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     11b0 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ddf(%rip),%rbx
mov    (%rbx),%edi
mov    (%rsi),%rdx
lea    0xdfb(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe0b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"usage: %s <threshold> < inFile\0A\00"
@.str.1 = [70 x i8] c"It coverts a real sequence into a binary sequence given a threshold.\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%lf\00"
@stdout = global i32 0
@.str.3 = [3 x i8] c"1\0A\00"
@.str.4 = [3 x i8] c"0\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call double @atof(i8* %22)
store double %23, double* %7
br label %24
24: ; preds = %38, %19
%25 = load i32, i32* @stdin
%26 = call i32 @fscanf(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %39
28: ; preds = %24
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* @stdout
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %38
35: ; preds = %28
%36 = load i32, i32* @stdout
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %35, %32
br label %24
39: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"usage: %s <threshold> < inFile\0A\00"
@.str.1 = [70 x i8] c"It coverts a real sequence into a binary sequence given a threshold.\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%lf\00"
@stdout = global i32 0
@.str.3 = [3 x i8] c"1\0A\00"
@.str.4 = [3 x i8] c"0\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call double @atof(i8* %15)
%17 = load i32, i32* @stdin
%18 = call i32 @fscanf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %29
20: ; preds = %13, %20
%21 = load double, double* %3
%22 = fcmp ogt double %21, %16
%23 = load i32, i32* @stdout
%24 = select i1 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* %24)
%26 = load i32, i32* @stdin
%27 = call i32 @fscanf(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%28 = icmp eq i32 %27, 1
br i1 %28, label %20, label %29
29: ; preds = %20, %13
ret i32 0
}