#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int g2d(unsigned int);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *fp;
  bool p = true;
  char c;
  unsigned n = 0;
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while ((c = getc(fp)) != EOF || !p) {
    p = false;
    if (c == '0' || c == '1') {
      n = 2 * n + c - '0';
    } else if (c == ' ') {
      printf("%u | ", g2d(n));
      n = 0;
      fseek(fp, 2, SEEK_CUR);
    } else if (c == '\n' || c == EOF) {
      printf("%u\n", g2d(n));
      n = 0;
      p = true;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x4f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e3 <main+0x193>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe59(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%ecx
mov    0x2e08(%rip),%rax
movsbl (%rax),%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x25(%rbp)
jne    11f4 <main+0xa4>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1204 <main+0xb4>
jmp    12dc <main+0x18c>
movl   $0x0,-0x1c(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x30,%eax
je     1225 <main+0xd5>
movsbl -0x1d(%rbp),%eax
cmp    $0x31,%eax
jne    123c <main+0xec>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
movsbl -0x1d(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x24(%rbp)
jmp    12d7 <main+0x187>
movsbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jne    1284 <main+0x134>
mov    -0x24(%rbp),%edi
call   1040 <g2d@plt>
mov    %eax,%esi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d75(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1050 <fseek@plt>
jmp    12d2 <main+0x182>
movsbl -0x1d(%rbp),%eax
cmp    $0xa,%eax
je     12a7 <main+0x157>
movsbl -0x1d(%rbp),%eax
mov    0x2d44(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    12cd <main+0x17d>
mov    -0x24(%rbp),%edi
call   1040 <g2d@plt>
mov    %eax,%esi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    12d2 <main+0x182>
jmp    12d7 <main+0x187>
jmp    11c2 <main+0x72>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1248 <main+0xf8>
mov    0x8(%rsi),%rdi
lea    0xea3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1070 <getc@plt>
mov    0x2e5a(%rip),%r13
mov    0x0(%r13),%dl
xor    %ecx,%ecx
cmp    %dl,%al
je     125e <main+0x10e>
xor    %ebx,%ebx
lea    0xe7d(%rip),%r14
lea    0xe70(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%ecx
and    $0xfe,%cl
cmp    $0x30,%cl
jne    11d0 <main+0x80>
movzbl %al,%eax
lea    (%rax,%rbx,2),%ebx
add    $0xffffffd0,%ebx
mov    $0x1,%bpl
jmp    1226 <main+0xd6>
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%al
je     120f <main+0xbf>
cmp    $0x20,%al
jne    1208 <main+0xb8>
mov    %ebx,%edi
call   1040 <g2d@plt>
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x2,%esi
call   1050 <fseek@plt>
mov    $0x1,%bpl
jmp    1226 <main+0xd6>
mov    $0x1,%bpl
cmp    %dl,%al
jne    1226 <main+0xd6>
mov    %ebx,%edi
call   1040 <g2d@plt>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebx,%ebx
mov    %r12,%rdi
call   1070 <getc@plt>
movzbl 0x0(%r13),%edx
test   %bpl,%bpl
jne    11b0 <main+0x60>
cmp    %dl,%al
jne    11b0 <main+0x60>
xor    %ecx,%ecx
jmp    125e <main+0x10e>
mov    (%rsi),%rsi
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [6 x i8] c"%u | \00"
@SEEK_CUR = global i32 0
@.str.3 = [4 x i8] c"%u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne 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 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %79
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
br label %22
22: ; preds = %77, %17
%23 = load i32*, i32** %6
%24 = call signext i8 @getc(i32* %23)
store i8 %24, i8* %8
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %33, label %29
29: ; preds = %22
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br label %33
33: ; preds = %29, %22
%34 = phi i1 [ true, %22 ], [ %32, %29 ]
br i1 %34, label %35, label %78
35: ; preds = %33
store i32 0, i32* %7
%36 = load i8, i8* %8
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 48
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 49
br i1 %42, label %43, label %50
43: ; preds = %39, %35
%44 = load i32, i32* %9
%45 = mul i32 2, %44
%46 = load i8, i8* %8
%47 = sext i8 %46 to i32
%48 = add i32 %45, %47
%49 = sub i32 %48, 48
store i32 %49, i32* %9
br label %77
50: ; preds = %39
%51 = load i8, i8* %8
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 32
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = load i32, i32* %9
%56 = call i32 @g2d(i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %56)
store i32 0, i32* %9
%58 = load i32*, i32** %6
%59 = load i32, i32* @SEEK_CUR
%60 = call i32 @fseek(i32* %58, i32 2, i32 %59)
br label %76
61: ; preds = %50
%62 = load i8, i8* %8
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 10
br i1 %64, label %71, label %65
65: ; preds = %61
%66 = load i8, i8* %8
%67 = sext i8 %66 to i32
%68 = load i8, i8* @EOF
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %67, %69
br i1 %70, label %71, label %75
71: ; preds = %65, %61
%72 = load i32, i32* %9
%73 = call i32 @g2d(i32 %72)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %73)
store i32 0, i32* %9
store i32 1, i32* %7
br label %75
75: ; preds = %71, %65
br label %76
76: ; preds = %75, %54
br label %77
77: ; preds = %76, %43
br label %22
78: ; preds = %33
store i32 0, i32* %3
br label %79
79: ; preds = %78, %12
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [6 x i8] c"%u | \00"
@SEEK_CUR = global i32 0
@.str.3 = [4 x i8] c"%u\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %43
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call signext i8 @getc(i32* %10)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %43, label %14
14: ; preds = %7, %36
%15 = phi i8 [ %40, %36 ], [ %12, %7 ]
%16 = phi i8 [ %39, %36 ], [ %11, %7 ]
%17 = phi i32 [ %38, %36 ], [ 0, %7 ]
%18 = and i8 %16, -2
%19 = icmp eq i8 %18, 48
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = zext i8 %16 to i32
%22 = shl i32 %17, 1
%23 = add i32 %22, -48
%24 = add i32 %23, %21
br label %36
25: ; preds = %14
switch i8 %16, label %31 [
i8 32, label %26
i8 10, label %33
]
26: ; preds = %25
%27 = tail call i32 @g2d(i32 %17)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @SEEK_CUR
%30 = tail call i32 @fseek(i32* %10, i32 2, i32 %29)
br label %36
31: ; preds = %25
%32 = icmp eq i8 %16, %15
br i1 %32, label %33, label %36
33: ; preds = %25, %31
%34 = tail call i32 @g2d(i32 %17)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %26, %33, %31, %20
%37 = phi i1 [ true, %26 ], [ false, %33 ], [ true, %31 ], [ true, %20 ]
%38 = phi i32 [ 0, %26 ], [ 0, %33 ], [ %17, %31 ], [ %24, %20 ]
%39 = tail call signext i8 @getc(i32* %10)
%40 = load i8, i8* @EOF
%41 = icmp ne i8 %39, %40
%42 = or i1 %37, %41
br i1 %42, label %14, label %43
43: ; preds = %36, %7, %4
%44 = phi i32 [ 1, %4 ], [ 0, %7 ], [ 0, %36 ]
ret i32 %44
}