#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*/ fflush(int /*<<< orphan*/);
int fscanf(int /*<<< orphan*/, char *, char *, char *, char *);
double handleInput(char const *, char const *, char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, const char **argv) {
  int readStdIn = 1;
  if (argc > 1) {
    readStdIn = 0;
    if (argc != 4) {
      printf("usage: %s hexsting1 hexstring2 bitcount\n", argv[0]);
      return 1;
    }
  }
  if (!readStdIn) {
    double res = handleInput(argv[1], argv[2], argv[3]);
    if (res >= 0) {
      printf("%f\n", res);
      return 0;
    }
    return 1;
  }
  for (;;) {
    char a[1024], b[1024], c[1024];
    double res;
    if (fscanf(stdin, "%s %s %s", a, b, c) != 3)
      return 0;
    res = handleInput(a, b, c);
    if (res >= 0) {
      printf("%f\n", res);
      fflush(stdout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a1 <main+0x61>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     119c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ae <main+0x16e>
jmp    11a1 <main+0x61>
cmpl   $0x0,-0x14(%rbp)
jne    120a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
call   1060 <handleInput@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11fe <main+0xbe>
movsd  -0x20(%rbp),%xmm0
lea    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ae <main+0x16e>
movl   $0x1,-0x4(%rbp)
jmp    12ae <main+0x16e>
jmp    120f <main+0xcf>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
lea    -0x820(%rbp),%rcx
lea    -0xc20(%rbp),%r8
lea    0xdf9(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x3,%eax
je     124e <main+0x10e>
movl   $0x0,-0x4(%rbp)
jmp    12ae <main+0x16e>
lea    -0x420(%rbp),%rdi
lea    -0x820(%rbp),%rsi
lea    -0xc20(%rbp),%rdx
call   1060 <handleInput@plt>
movsd  %xmm0,-0xc28(%rbp)
ff
movsd  -0xc28(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12a9 <main+0x169>
movsd  -0xc28(%rbp),%xmm0
ff
lea    0xd95(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    120f <main+0xcf>
mov    -0x4(%rbp),%eax
add    $0xc30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc08,%rsp
cmp    $0x2,%edi
jl     1176 <main+0x36>
cmp    $0x4,%edi
je     1176 <main+0x36>
mov    (%rsi),%rsi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    125c <main+0x11c>
cmp    $0x1,%edi
jle    11b5 <main+0x75>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rax
mov    0x18(%rsi),%rdx
mov    %rax,%rsi
call   1060 <handleInput@plt>
mov    $0x1,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     125c <main+0x11c>
lea    0xe88(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    125a <main+0x11a>
mov    0x2e2c(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe6f(%rip),%rsi
lea    0x800(%rsp),%rdx
lea    0x400(%rsp),%rcx
mov    %rsp,%r8
call   1040 <fscanf@plt>
cmp    $0x3,%eax
jne    125a <main+0x11a>
lea    0x800(%rsp),%r14
lea    0x400(%rsp),%r15
mov    %rsp,%rbx
lea    0xe38(%rip),%r12
mov    0x2dd4(%rip),%r13
jmp    1229 <main+0xe9>
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
call   1040 <fscanf@plt>
cmp    $0x3,%eax
jne    125a <main+0x11a>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <handleInput@plt>
ucomisd 0xdc1(%rip),%xmm0
jb     1210 <main+0xd0>
lea    0xde9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
jmp    1210 <main+0xd0>
xor    %eax,%eax
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"usage: %s hexsting1 hexstring2 bitcount\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"%s %s %s\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %23
14: ; preds = %2
store i32 0, i32* %6
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %65
22: ; preds = %14
br label %23
23: ; preds = %22, %2
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %43, label %26
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
%36 = call double @handleInput(i8* %29, i8* %32, i8* %35)
store double %36, double* %7
%37 = load double, double* %7
%38 = fcmp oge double %37, 0.000000e+00
br i1 %38, label %39, label %42
39: ; preds = %26
%40 = load double, double* %7
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %40)
store i32 0, i32* %3
br label %65
42: ; preds = %26
store i32 1, i32* %3
br label %65
43: ; preds = %23
br label %44
44: ; preds = %64, %43
%45 = load i32, i32* @stdin
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%49 = call i32 @fscanf(i32 %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %47, i8* %48)
%50 = icmp ne i32 %49, 3
br i1 %50, label %51, label %52
51: ; preds = %44
store i32 0, i32* %3
br label %65
52: ; preds = %44
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%56 = call double @handleInput(i8* %53, i8* %54, i8* %55)
store double %56, double* %11
%57 = load double, double* %11
%58 = fcmp oge double %57, 0.000000e+00
br i1 %58, label %59, label %64
59: ; preds = %52
%60 = load double, double* %11
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %60)
%62 = load i32, i32* @stdout
%63 = call i32 @fflush(i32 %62)
br label %64
64: ; preds = %59, %52
br label %44
65: ; preds = %51, %42, %39, %17
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [41 x i8] c"usage: %s hexsting1 hexstring2 bitcount\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"%s %s %s\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = icmp sgt i32 %0, 1
%7 = icmp ne i32 %0, 4
%8 = and i1 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %43
12: ; preds = %2
br i1 %6, label %20, label %13
13: ; preds = %12
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i32 @fscanf(i32 %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %15, i8* %16)
%19 = icmp eq i32 %18, 3
br i1 %19, label %31, label %42
20: ; preds = %12
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call double @handleInput(i8* %22, i8* %24, i8* %26)
%28 = fcmp ult double %27, 0.000000e+00
br i1 %28, label %43, label %29
29: ; preds = %20
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %27)
br label %43
31: ; preds = %13, %38
%32 = call double @handleInput(i8* %14, i8* %15, i8* %16)
%33 = fcmp ult double %32, 0.000000e+00
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %32)
%36 = load i32, i32* @stdout
%37 = call i32 @fflush(i32 %36)
br label %38
38: ; preds = %31, %34
%39 = load i32, i32* @stdin
%40 = call i32 @fscanf(i32 %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %15, i8* %16)
%41 = icmp eq i32 %40, 3
br i1 %41, label %31, label %42
42: ; preds = %38, %13
br label %43
43: ; preds = %42, %29, %20, %9
%44 = phi i32 [ 1, %9 ], [ 0, %29 ], [ 1, %20 ], [ 0, %42 ]
ret i32 %44
}