#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ chartobinf(char, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
size_t strlen(char *);
scalar_t__ strtol(char *, char **, int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int c;
  if (argc < 2) {
    usage();
    exit(EXIT_FAILURE);
  } else {
    char *end = &argv[argc - 1][strlen(argv[argc - 1])];
    if (*end == '\n')
      *end = '\0';
  }
  if ((c = getopt(argc, argv, "b:t:")) != -1) {
    switch (c) {
    case 'b': {
      int i = optind - 1;
      while (i < argc) {
        int n = strlen(argv[i]);
        int j = 0;
        while (j < n) {
          chartobinf(argv[i][j], stdout);
          putchar(' ');
          j++;
        }
        i++;
      }
    }
      putchar('\n');
      break;
    case 't': {
      char *endptr = NULL;
      int i = optind - 1;
      while (i < argc) {
        printf("%c", (int)strtol(argv[i], &endptr, 2));
        i++;
      }
      putchar('\n');
      if (*endptr != '\0') {
        fprintf(stderr, "Could not process some binary numbers.\n"
                        "Please verify input is only ones and zeros.\n");
        exit(EXIT_FAILURE);
      }
    } break;
    }
  }
  if (optind == 1) {
    fputs("One flag must be given!\n", stderr);
    usage();
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d5 <main+0x35>
mov    $0x0,%al
call   10a0 <usage@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1225 <main+0x85>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    122a <main+0x8a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdc8(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     13a9 <main+0x209>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x62,%eax
je     126e <main+0xce>
jmp    125d <main+0xbd>
mov    -0x4c(%rbp),%eax
sub    $0x74,%eax
je     1309 <main+0x169>
jmp    13a4 <main+0x204>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fa <main+0x15a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12ec <main+0x14c>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    0x2cfe(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <chartobinf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12a4 <main+0x104>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    127d <main+0xdd>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    13a4 <main+0x204>
movq   $0x0,-0x38(%rbp)
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1362 <main+0x1c2>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x2,%edx
call   1090 <strtol@plt>
mov    %eax,%esi
lea    0xcb6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1320 <main+0x180>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     139f <main+0x1ff>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
lea    0xc7c(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    13a4 <main+0x204>
jmp    13a9 <main+0x209>
mov    0x2c38(%rip),%rax
cmpl   $0x1,(%rax)
jne    13e3 <main+0x243>
mov    0x2c18(%rip),%rax
mov    (%rax),%esi
lea    0xc93(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2bd6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jle    1348 <main+0x1a8>
mov    %rsi,%r12
mov    %edi,%ebp
lea    -0x1(%rbp),%eax
mov    (%rsi,%rax,8),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
cmpb   $0xa,(%r15,%rax,1)
jne    11d7 <main+0x37>
movb   $0x0,(%r15,%rax,1)
lea    0xe22(%rip),%rdx
mov    %ebp,%edi
mov    %r12,%rsi
call   10b0 <getopt@plt>
cmp    $0x74,%eax
je     1212 <main+0x72>
cmp    $0x62,%eax
jne    1327 <main+0x187>
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
cmp    %ebp,%eax
jle    1233 <main+0x93>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1327 <main+0x187>
movq   $0x0,0x8(%rsp)
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
cmp    %ebp,%eax
jle    12c6 <main+0x126>
xor    %ebx,%ebx
jmp    1318 <main+0x178>
add    $0xffffffff,%eax
movslq %eax,%rbx
mov    0x2d88(%rip),%r13
mov    %rbp,0x10(%rsp)
jmp    125d <main+0xbd>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    0x10(%rsp),%rbp
cmp    %ebp,%ebx
je     1203 <main+0x63>
mov    (%r12,%rbx,8),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1250 <main+0xb0>
mov    %eax,%r14d
movsbl (%r15),%edi
mov    0x0(%r13),%esi
call   1040 <chartobinf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    $0x1,%r14
je     1250 <main+0xb0>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rax
movsbl (%rax,%rbp,1),%edi
mov    0x0(%r13),%esi
call   1040 <chartobinf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    12a0 <main+0x100>
jmp    1250 <main+0xb0>
lea    -0x1(%rax),%ecx
movslq %ecx,%rcx
lea    (%r12,%rcx,8),%r14
sub    %eax,%ebp
add    $0x1,%ebp
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
lea    0xd22(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbx,8),%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1090 <strtol@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    12f0 <main+0x150>
mov    0x8(%rsp),%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpb   $0x0,(%rbx)
jne    136b <main+0x1cb>
mov    0x2cba(%rip),%rax
cmpl   $0x1,(%rax)
jne    135d <main+0x1bd>
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
lea    0xd19(%rip),%rdi
call   1070 <fputs@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    0x2c7a(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
lea    0xc8d(%rip),%rsi
call   1080 <fprintf@plt>
jmp    134f <main+0x1af>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [5 x i8] c"b:t:\00"
@optind = global i32 0
@stdout = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@stderr = global i32 0
@.str.2 = [84 x i8] c"Could not process some binary numbers.\0APlease verify input is only ones and zeros.\0A\00"
@.str.3 = [25 x i8] c"One flag must be given!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = call i32 (...) @usage()
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %20, i64 %23
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
%31 = load i8*, i8** %30
%32 = call i64 @strlen(i8* %31)
%33 = getelementptr inbounds i8, i8* %25, i64 %32
store i8* %33, i8** %7
%34 = load i8*, i8** %7
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %40
38: ; preds = %19
%39 = load i8*, i8** %7
store i8 0, i8* %39
br label %40
40: ; preds = %38, %19
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = load i8**, i8*** %5
%44 = call i32 @getopt(i32 %42, i8** %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %44, i32* %6
%45 = icmp ne i32 %44, -1
br i1 %45, label %46, label %118
46: ; preds = %41
%47 = load i32, i32* %6
switch i32 %47, label %117 [
i32 98, label %48
i32 116, label %87
]
48: ; preds = %46
%49 = load i32, i32* @optind
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %8
br label %51
51: ; preds = %82, %48
%52 = load i32, i32* %8
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %85
55: ; preds = %51
%56 = load i8**, i8*** %5
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @strlen(i8* %60)
%62 = trunc i64 %61 to i32
store i32 %62, i32* %9
store i32 0, i32* %10
br label %63
63: ; preds = %67, %55
%64 = load i32, i32* %10
%65 = load i32, i32* %9
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %82
67: ; preds = %63
%68 = load i8**, i8*** %5
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = load i32, i32* %10
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
%76 = load i8, i8* %75
%77 = load i32, i32* @stdout
%78 = call i32 @chartobinf(i8 signext %76, i32 %77)
%79 = call i32 @putchar(i8 signext 32)
%80 = load i32, i32* %10
%81 = add nsw i32 %80, 1
store i32 %81, i32* %10
br label %63
82: ; preds = %63
%83 = load i32, i32* %8
%84 = add nsw i32 %83, 1
store i32 %84, i32* %8
br label %51
85: ; preds = %51
%86 = call i32 @putchar(i8 signext 10)
br label %117
87: ; preds = %46
store i8* null, i8** %11
%88 = load i32, i32* @optind
%89 = sub nsw i32 %88, 1
store i32 %89, i32* %12
br label %90
90: ; preds = %94, %87
%91 = load i32, i32* %12
%92 = load i32, i32* %4
%93 = icmp slt i32 %91, %92
br i1 %93, label %94, label %105
94: ; preds = %90
%95 = load i8**, i8*** %5
%96 = load i32, i32* %12
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %95, i64 %97
%99 = load i8*, i8** %98
%100 = call i64 @strtol(i8* %99, i8** %11, i32 2)
%101 = trunc i64 %100 to i32
%102 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %101)
%103 = load i32, i32* %12
%104 = add nsw i32 %103, 1
store i32 %104, i32* %12
br label %90
105: ; preds = %90
%106 = call i32 @putchar(i8 signext 10)
%107 = load i8*, i8** %11
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %116
111: ; preds = %105
%112 = load i32, i32* @stderr
%113 = call i32 @fprintf(i32 %112, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.2, i64 0, i64 0))
%114 = load i32, i32* @EXIT_FAILURE
%115 = call i32 @exit(i32 %114)
unreachable
116: ; preds = %105
br label %117
117: ; preds = %46, %116, %85
br label %118
118: ; preds = %117, %41
%119 = load i32, i32* @optind
%120 = icmp eq i32 %119, 1
br i1 %120, label %121, label %127
121: ; preds = %118
%122 = load i32, i32* @stderr
%123 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %122)
%124 = call i32 (...) @usage()
%125 = load i32, i32* @EXIT_FAILURE
%126 = call i32 @exit(i32 %125)
unreachable
127: ; preds = %118
%128 = load i32, i32* @EXIT_SUCCESS
%129 = call i32 @exit(i32 %128)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [5 x i8] c"b:t:\00"
@optind = global i32 0
@stdout = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@stderr = global i32 0
@.str.2 = [84 x i8] c"Could not process some binary numbers.\0APlease verify input is only ones and zeros.\0A\00"
@.str.3 = [25 x i8] c"One flag must be given!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 (...) @usage()
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = add nsw i32 %0, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %19
18: ; preds = %9
store i8 0, i8* %15
br label %19
19: ; preds = %18, %9
%20 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %20, label %87 [
i32 116, label %57
i32 98, label %21
]
21: ; preds = %19
%22 = load i32, i32* @optind
%23 = icmp sgt i32 %22, %0
br i1 %23, label %55, label %24
24: ; preds = %21
%25 = add i32 %22, -1
%26 = sext i32 %25 to i64
br label %27
27: ; preds = %24, %51
%28 = phi i64 [ %26, %24 ], [ %52, %51 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i64 @strlen(i8* dereferenceable(1) %30)
%32 = trunc i64 %31 to i32
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %51
34: ; preds = %27
%35 = and i64 %31, 4294967295
%36 = load i8, i8* %30
%37 = load i32, i32* @stdout
%38 = tail call i32 @chartobinf(i8 signext %36, i32 %37)
%39 = tail call i32 @putchar(i8 signext 32)
%40 = icmp eq i64 %35, 1
br i1 %40, label %51, label %41
41: ; preds = %34, %41
%42 = phi i64 [ %49, %41 ], [ 1, %34 ]
%43 = load i8*, i8** %29
%44 = getelementptr inbounds i8, i8* %43, i64 %42
%45 = load i8, i8* %44
%46 = load i32, i32* @stdout
%47 = tail call i32 @chartobinf(i8 signext %45, i32 %46)
%48 = tail call i32 @putchar(i8 signext 32)
%49 = add nuw nsw i64 %42, 1
%50 = icmp eq i64 %49, %35
br i1 %50, label %51, label %41
51: ; preds = %41, %34, %27
%52 = add nsw i64 %28, 1
%53 = trunc i64 %52 to i32
%54 = icmp eq i32 %53, %0
br i1 %54, label %55, label %27
55: ; preds = %51, %21
%56 = tail call i32 @putchar(i8 signext 10)
br label %87
57: ; preds = %19
%58 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%59 = load i32, i32* @optind
%60 = icmp sgt i32 %59, %0
br i1 %60, label %76, label %61
61: ; preds = %57
%62 = add i32 %59, -1
%63 = sext i32 %62 to i64
br label %64
64: ; preds = %61, %64
%65 = phi i64 [ %63, %61 ], [ %71, %64 ]
%66 = getelementptr inbounds i8*, i8** %1, i64 %65
%67 = load i8*, i8** %66
%68 = call i64 @strtol(i8* %67, i8** %3, i32 2)
%69 = trunc i64 %68 to i32
%70 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = add nsw i64 %65, 1
%72 = trunc i64 %71 to i32
%73 = icmp eq i32 %72, %0
br i1 %73, label %74, label %64
74: ; preds = %64
%75 = load i8*, i8** %3
br label %76
76: ; preds = %74, %57
%77 = phi i8* [ %75, %74 ], [ null, %57 ]
%78 = tail call i32 @putchar(i8 signext 10)
%79 = load i8, i8* %77
%80 = icmp eq i8 %79, 0
br i1 %80, label %86, label %81
81: ; preds = %76
%82 = load i32, i32* @stderr
%83 = tail call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.2, i64 0, i64 0))
%84 = load i32, i32* @EXIT_FAILURE
%85 = tail call i32 @exit(i32 %84)
unreachable
86: ; preds = %76
br label %87
87: ; preds = %19, %55, %86
%88 = load i32, i32* @optind
%89 = icmp eq i32 %88, 1
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = load i32, i32* @stderr
%92 = tail call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %91)
%93 = tail call i32 (...) @usage()
%94 = load i32, i32* @EXIT_FAILURE
%95 = tail call i32 @exit(i32 %94)
unreachable
96: ; preds = %87
%97 = load i32, i32* @EXIT_SUCCESS
%98 = tail call i32 @exit(i32 %97)
unreachable
}