#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ help(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
double pow(int, double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  if (argc != 3) {
    if ((argc == 2) && (strcmp(argv[1], "help") == 0))
      help(argv[0]);
    else
      fprintf(stderr, "Error: no operation specified. See './dexinary help'\n");
    exit(0);
  } else {
    char *operation = argv[1];
    char *number = argv[2];
    double result = 0;
    if (strcmp(operation, "bin2dec") == 0) {
      if (strncmp(number, "0b", 2) != 0) {
        help(argv[0]);
      }
      char buff[strlen(number) - 2];
      memcpy(buff, &number[2], strlen(number) - 2);
      buff[strlen(number) - 2] = '\0';
      double decimal = 0;
      for (int i = 0; i < strlen(buff); i++) {
        if (buff[i] == '1') {
          double loc = strlen(buff) - (i + 1);
          double power = pow(2, loc);
          decimal += power;
        }
      }
      result = decimal;
      printf("Result: %f\n", result);
    } else if (strcmp(operation, "dec2bin") == 0) {
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1205 <main+0x75>
cmpl   $0x2,-0x8(%rbp)
jne    11e9 <main+0x59>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e9 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <help@plt>
jmp    11fe <main+0x6e>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1390 <main+0x200>
mov    -0x20(%rbp),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     126a <main+0xda>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <help@plt>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
add    $0xfffffffe,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rsi
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
sub    $0x2,%edx
call   1080 <memcpy@plt>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x44(%rbp),%eax
mov    %eax,-0x6c(%rbp)
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    1369 <main+0x1d9>
mov    -0x60(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    1356 <main+0x1c6>
mov    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    $0x2,%edi
call   1090 <pow@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    135b <main+0x1cb>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12e8 <main+0x158>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xcc7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    13b4 <main+0x224>
mov    -0x18(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    13af <main+0x21f>
jmp    13af <main+0x21f>
jmp    13b4 <main+0x224>
jmp    13b9 <main+0x229>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x3,%edi
jne    12e5 <main+0x155>
mov    0x8(%r15),%rbx
mov    0x10(%r15),%r14
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11da <main+0x4a>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
jmp    12d4 <main+0x144>
lea    0xe62(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11fb <main+0x6b>
mov    (%r15),%rdi
call   10a0 <help@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rsp,%r12
add    $0xfffffffe,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0x2(%r14),%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    -0x2(%rax),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1080 <memcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x2(%rax,%r13,1)
mov    %r13,%rdi
call   1040 <strlen@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
jle    12bb <main+0x12b>
movsd  %xmm0,-0x30(%rbp)
mov    $0xffffffff,%r14d
xor    %ebx,%ebx
jmp    1287 <main+0xf7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
add    $0xffffffff,%r14d
cmp    %rax,%rbx
jge    12c0 <main+0x130>
cmpb   $0x31,0x0(%r13,%rbx,1)
jne    1270 <main+0xe0>
mov    %r13,%rdi
call   1040 <strlen@plt>
add    %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0x2,%edi
call   1090 <pow@plt>
movsd  -0x30(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x30(%rbp)
jmp    1270 <main+0xe0>
movsd  %xmm0,-0x30(%rbp)
lea    0xd7f(%rip),%rdi
movsd  -0x30(%rbp),%xmm0
call   1050 <printf@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x2,%edi
jne    130e <main+0x17e>
mov    0x8(%r15),%rdi
lea    0xd0b(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    130e <main+0x17e>
mov    (%r15),%rdi
call   10a0 <help@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xce7(%rip),%rsi
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"Error: no operation specified. See './dexinary help'\0A\00"
@.str.2 = [8 x i8] c"bin2dec\00"
@.str.3 = [3 x i8] c"0b\00"
@.str.4 = [12 x i8] c"Result: %f\0A\00"
@.str.5 = [8 x i8] c"dec2bin\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca double
%9 = alloca i8*
%10 = alloca i64
%11 = alloca double
%12 = alloca i32
%13 = alloca double
%14 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %36
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @help(i8* %29)
br label %34
31: ; preds = %20, %17
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %31, %26
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %2
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
store i8* %39, i8** %6
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
store i8* %42, i8** %7
store double 0.000000e+00, double* %8
%43 = load i8*, i8** %6
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %104
46: ; preds = %36
%47 = load i8*, i8** %7
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 0
%53 = load i8*, i8** %52
%54 = call i32 @help(i8* %53)
br label %55
55: ; preds = %50, %46
%56 = load i8*, i8** %7
%57 = call i32 @strlen(i8* %56)
%58 = sub nsw i32 %57, 2
%59 = zext i32 %58 to i64
%60 = call i8* @llvm.stacksave()
store i8* %60, i8** %9
%61 = alloca i8, i64 %59
store i64 %59, i64* %10
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i64 2
%64 = load i8*, i8** %7
%65 = call i32 @strlen(i8* %64)
%66 = sub nsw i32 %65, 2
%67 = call i32 @memcpy(i8* %61, i8* %63, i32 %66)
%68 = load i8*, i8** %7
%69 = call i32 @strlen(i8* %68)
%70 = sub nsw i32 %69, 2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %61, i64 %71
store i8 0, i8* %72
store double 0.000000e+00, double* %11
store i32 0, i32* %12
br label %73
73: ; preds = %96, %55
%74 = load i32, i32* %12
%75 = call i32 @strlen(i8* %61)
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %99
77: ; preds = %73
%78 = load i32, i32* %12
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %61, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 49
br i1 %83, label %84, label %95
84: ; preds = %77
%85 = call i32 @strlen(i8* %61)
%86 = load i32, i32* %12
%87 = add nsw i32 %86, 1
%88 = sub nsw i32 %85, %87
%89 = sitofp i32 %88 to double
store double %89, double* %13
%90 = load double, double* %13
%91 = call double @pow(i32 2, double %90)
store double %91, double* %14
%92 = load double, double* %14
%93 = load double, double* %11
%94 = fadd double %93, %92
store double %94, double* %11
br label %95
95: ; preds = %84, %77
br label %96
96: ; preds = %95
%97 = load i32, i32* %12
%98 = add nsw i32 %97, 1
store i32 %98, i32* %12
br label %73
99: ; preds = %73
%100 = load double, double* %11
store double %100, double* %8
%101 = load double, double* %8
%102 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %101)
%103 = load i8*, i8** %9
br label %110
104: ; preds = %36
%105 = load i8*, i8** %6
%106 = call i64 @strcmp(i8* %105, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%107 = icmp eq i64 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %104
br label %109
109: ; preds = %108, %104
br label %110
110: ; preds = %109, %99
br label %111
111: ; preds = %110
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"Error: no operation specified. See './dexinary help'\0A\00"
@.str.2 = [8 x i8] c"bin2dec\00"
@.str.3 = [3 x i8] c"0b\00"
@.str.4 = [12 x i8] c"Result: %f\0A\00"
@.str.5 = [8 x i8] c"dec2bin\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %11 [
i32 3, label %16
i32 2, label %3
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i8*, i8** %1
%10 = tail call i32 @help(i8* %9)
br label %14
11: ; preds = %2, %3
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %68
23: ; preds = %16
%24 = tail call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i8*, i8** %1
%28 = tail call i32 @help(i8* %27)
br label %29
29: ; preds = %26, %23
%30 = tail call i32 @strlen(i8* %20)
%31 = add nsw i32 %30, -2
%32 = zext i32 %31 to i64
%33 = tail call i8* @llvm.stacksave()
%34 = alloca i8, i64 %32
%35 = getelementptr inbounds i8, i8* %20, i64 2
%36 = tail call i32 @strlen(i8* %20)
%37 = add nsw i32 %36, -2
%38 = call i32 @memcpy(i8* %34, i8* %35, i32 %37)
%39 = call i32 @strlen(i8* %20)
%40 = add nsw i32 %39, -2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %34, i64 %41
store i8 0, i8* %42
%43 = call i32 @strlen(i8* %34)
%44 = icmp sgt i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %62, %29
%46 = phi double [ 0.000000e+00, %29 ], [ %63, %62 ]
%47 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %46)
br label %70
48: ; preds = %29, %62
%49 = phi i64 [ %64, %62 ], [ 0, %29 ]
%50 = phi double [ %63, %62 ], [ 0.000000e+00, %29 ]
%51 = getelementptr inbounds i8, i8* %34, i64 %49
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 49
br i1 %53, label %54, label %62
54: ; preds = %48
%55 = trunc i64 %49 to i32
%56 = call i32 @strlen(i8* %34)
%57 = xor i32 %55, -1
%58 = add i32 %56, %57
%59 = sitofp i32 %58 to double
%60 = call double @pow(i32 2, double %59)
%61 = fadd double %50, %60
br label %62
62: ; preds = %48, %54
%63 = phi double [ %61, %54 ], [ %50, %48 ]
%64 = add nuw nsw i64 %49, 1
%65 = call i32 @strlen(i8* %34)
%66 = sext i32 %65 to i64
%67 = icmp slt i64 %64, %66
br i1 %67, label %48, label %45
68: ; preds = %16
%69 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %68, %45
ret i32 0
}