#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_lit(int /*<<< orphan*/ *, int *);
int main(int argc, char **argv) {
  if (argc <= 1) {
    printf("c %s needs one argument: an input in compressed LRAT format\n",
           argv[0]);
    return 0;
  }
  FILE *input = fopen(argv[1], "r");
  if (input == NULL) {
    printf("c ERROR opening %s\n", argv[1]);
    exit(1);
  }
  int lit, index;
  while (1) {
    read_lit(input, &lit);
    if (lit == -48) {
      int zeros = 0;
      read_lit(input, &lit);
      index = lit;
      printf("%i ", index);
      while (zeros < 1) {
        read_lit(input, &lit);
        if (lit == 0)
          zeros++;
        if (zeros == 1)
          printf("0\n");
        else
          printf("%i ", lit);
      }
    } else if (lit == 50) {
      if (1 == 2)
        printf("%i ", index);
      printf("d ");
      int zeros = 0;
      while (zeros < 1) {
        read_lit(input, &lit);
        if (lit == 0)
          zeros++;
        if (zeros == 1)
          printf("0\n");
        else
          printf("%i ", lit);
      }
    } else
      break;
  }
}


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)
cmpl   $0x1,-0x8(%rbp)
jg     1181 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fd <main+0x1bd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c4 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11c9 <main+0x89>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <read_lit@plt>
cmpl   $0xffffffd0,-0x1c(%rbp)
jne    126d <main+0x12d>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <read_lit@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x24(%rbp)
jge    1268 <main+0x128>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <read_lit@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    1235 <main+0xf5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1252 <main+0x112>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1263 <main+0x123>
mov    -0x1c(%rbp),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120b <main+0xcb>
jmp    12f8 <main+0x1b8>
cmpl   $0x32,-0x1c(%rbp)
jne    12ee <main+0x1ae>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jge    12e9 <main+0x1a9>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <read_lit@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12b6 <main+0x176>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    12d3 <main+0x193>
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e4 <main+0x1a4>
mov    -0x1c(%rbp),%esi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128c <main+0x14c>
jmp    12f3 <main+0x1b3>
jmp    12fd <main+0x1bd>
jmp    12f8 <main+0x1b8>
jmp    11c9 <main+0x89>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jg     1186 <main+0x36>
mov    (%r14),%rsi
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x8(%r14),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     123f <main+0xef>
mov    %rax,%rbx
lea    0xc(%rsp),%r14
lea    0xea9(%rip),%r15
lea    0xe9e(%rip),%r12
lea    0xe9e(%rip),%r13
jmp    11c8 <main+0x78>
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <read_lit@plt>
mov    0xc(%rsp),%eax
cmp    $0x32,%eax
je     1210 <main+0xc0>
cmp    $0xffffffd0,%eax
jne    1176 <main+0x26>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <read_lit@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <read_lit@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jne    11f0 <main+0xa0>
jmp    11c0 <main+0x70>
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <read_lit@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11c0 <main+0x70>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1220 <main+0xd0>
mov    0x8(%r14),%rsi
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [61 x i8] c"c %s needs one argument: an input in compressed LRAT format\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"c ERROR opening %s\0A\00"
@.str.3 = [4 x i8] c"%i \00"
@.str.4 = [3 x i8] c"0\0A\00"
@.str.5 = [3 x i8] c"d \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 i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 0, i32* %3
br label %93
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %18
br label %32
32: ; preds = %31, %92
%33 = load i32*, i32** %6
%34 = call i32 @read_lit(i32* %33, i32* %7)
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, -48
br i1 %36, label %37, label %64
37: ; preds = %32
store i32 0, i32* %9
%38 = load i32*, i32** %6
%39 = call i32 @read_lit(i32* %38, i32* %7)
%40 = load i32, i32* %7
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %62, %37
%44 = load i32, i32* %9
%45 = icmp slt i32 %44, 1
br i1 %45, label %46, label %63
46: ; preds = %43
%47 = load i32*, i32** %6
%48 = call i32 @read_lit(i32* %47, i32* %7)
%49 = load i32, i32* %7
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %54
54: ; preds = %51, %46
%55 = load i32, i32* %9
%56 = icmp eq i32 %55, 1
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %62
59: ; preds = %54
%60 = load i32, i32* %7
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %59, %57
br label %43
63: ; preds = %43
br label %92
64: ; preds = %32
%65 = load i32, i32* %7
%66 = icmp eq i32 %65, 50
br i1 %66, label %67, label %90
67: ; preds = %64
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %69
69: ; preds = %88, %67
%70 = load i32, i32* %10
%71 = icmp slt i32 %70, 1
br i1 %71, label %72, label %89
72: ; preds = %69
%73 = load i32*, i32** %6
%74 = call i32 @read_lit(i32* %73, i32* %7)
%75 = load i32, i32* %7
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = load i32, i32* %10
%79 = add nsw i32 %78, 1
store i32 %79, i32* %10
br label %80
80: ; preds = %77, %72
%81 = load i32, i32* %10
%82 = icmp eq i32 %81, 1
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %88
85: ; preds = %80
%86 = load i32, i32* %7
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %85, %83
br label %69
89: ; preds = %69
br label %91
90: ; preds = %64
br label %93
91: ; preds = %89
br label %92
92: ; preds = %91, %63
br label %32
93: ; preds = %13, %90
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
@.str = [61 x i8] c"c %s needs one argument: an input in compressed LRAT format\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"c ERROR opening %s\0A\00"
@.str.3 = [4 x i8] c"%i \00"
@.str.5 = [3 x i8] c"d \00"
@str.6 = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %46
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %8
%18 = bitcast i32* %3 to i8*
br label %19
19: ; preds = %42, %17
%20 = call i32 @read_lit(i32* %11, i32* %3)
%21 = load i32, i32* %3
switch i32 %21, label %45 [
i32 -48, label %22
i32 50, label %31
]
22: ; preds = %19
%23 = call i32 @read_lit(i32* %11, i32* %3)
%24 = load i32, i32* %3
br label %25
25: ; preds = %25, %22
%26 = phi i32 [ %24, %22 ], [ %29, %25 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = call i32 @read_lit(i32* %11, i32* %3)
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 0
br i1 %30, label %42, label %25
31: ; preds = %19
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @read_lit(i32* %11, i32* %3)
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %31, %36
%37 = phi i32 [ %40, %36 ], [ %34, %31 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = call i32 @read_lit(i32* %11, i32* %3)
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %36
42: ; preds = %36, %25, %31
%43 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0), %31 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0), %25 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0), %36 ]
%44 = call i32 @puts(i8* dereferenceable(1) %43)
br label %19
45: ; preds = %19
br label %46
46: ; preds = %45, %5
ret i32 0
}