#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: %s [input binary file] [output lithuania file]\n", argv[0]);
    exit(0);
  }
  FILE *input;
  input = fopen(argv[1], "r");
  if (!input) {
    printf("Failed to open %s. Check if it exists\n", argv[1]);
    exit(0);
  }
  printf("Warning, this will overwrite %s, beginning in 3 seconds\n", argv[2]);
  for (int i = 3; i > 0; i--) {
    printf("%d...", i);
    fflush(stdout);
    sleep(1);
  }
  putchar('\n');
  FILE *output;
  output = fopen(argv[2], "w");
  char c;
  while ((c = fgetc(input)) != EOF) {
    for (int i = 7; i >= 0; i--) {
      if (c & (1 << i))
        fprintf(output, "KEBABAS");
      else
        fprintf(output, "ALUS");
      if (i != 0)
        fprintf(output, " ");
      ;
    }
    fprintf(output, "\n");
  }
}


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   $0x3,-0x8(%rbp)
je     11bc <main+0x3c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    125a <main+0xda>
mov    -0x1c(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1219 <main+0x99>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl %al,%eax
mov    0x2d56(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1330 <main+0x1b0>
movl   $0x7,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     131b <main+0x19b>
movsbl -0x29(%rbp),%eax
mov    -0x30(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     12de <main+0x15e>
mov    -0x28(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12ee <main+0x16e>
mov    -0x28(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1060 <fprintf@plt>
cmpl   $0x0,-0x30(%rbp)
je     1308 <main+0x188>
mov    -0x28(%rbp),%rdi
lea    0xdab(%rip),%rsi
call   1060 <fprintf@plt>
jmp    130d <main+0x18d>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    12a4 <main+0x124>
mov    -0x28(%rbp),%rdi
lea    0xd0f(%rip),%rsi
call   1060 <fprintf@plt>
jmp    127c <main+0xfc>
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
mov    %rsi,%r14
cmp    $0x3,%edi
jne    1310 <main+0x180>
mov    0x8(%r14),%rdi
lea    0xe85(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     131c <main+0x18c>
mov    %rax,%r15
mov    0x10(%r14),%rsi
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2de6(%rip),%rbp
mov    0x0(%rbp),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%r14),%rdi
lea    0xe44(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    0x2d76(%rip),%rcx
cmp    (%rcx),%al
jne    1287 <main+0xf7>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1b(%rip),%r14
lea    0xe0c(%rip),%r12
jmp    12c0 <main+0x130>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    0x2d2c(%rip),%rcx
cmp    (%rcx),%al
je     1276 <main+0xe6>
movsbl %al,%ebp
mov    $0x7,%r13d
bt     %r13d,%ebp
jae    12e0 <main+0x150>
nop
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r12,%rdi
jmp    12ed <main+0x15d>
nop
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
sub    $0x1,%r13d
jb     12a0 <main+0x110>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
bt     %r13d,%ebp
jb     12d0 <main+0x140>
jmp    12e0 <main+0x150>
mov    (%r14),%rsi
lea    0xce6(%rip),%rdi
jmp    1327 <main+0x197>
mov    0x8(%r14),%rsi
lea    0xd12(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"Usage: %s [input binary file] [output lithuania file]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"Failed to open %s. Check if it exists\0A\00"
@.str.3 = [57 x i8] c"Warning, this will overwrite %s, beginning in 3 seconds\0A\00"
@.str.4 = [6 x i8] c"%d...\00"
@stdout = global i32 0
@.str.5 = [2 x i8] c"w\00"
@EOF = global i8 0
@.str.6 = [8 x i8] c"KEBABAS\00"
@.str.7 = [5 x i8] c"ALUS\00"
@.str.8 = [2 x i8] c" \00"
@.str.9 = [2 x i8] c"\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 i32*
%9 = alloca i8
%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 ne i32 %11, 3
br i1 %12, label %13, label %19
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 ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp ne i32* %24, null
br i1 %25, label %32, label %26
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %19
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i8* %35)
store i32 3, i32* %7
br label %37
37: ; preds = %46, %32
%38 = load i32, i32* %7
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i32, i32* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* @stdout
%44 = call i32 @fflush(i32 %43)
%45 = call i32 @sleep(i32 1)
br label %46
46: ; preds = %40
%47 = load i32, i32* %7
%48 = add nsw i32 %47, -1
store i32 %48, i32* %7
br label %37
49: ; preds = %37
%50 = call i32 @putchar(i8 signext 10)
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %54, i32** %8
br label %55
55: ; preds = %89, %49
%56 = load i32*, i32** %6
%57 = call signext i8 @fgetc(i32* %56)
store i8 %57, i8* %9
%58 = sext i8 %57 to i32
%59 = load i8, i8* @EOF
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %58, %60
br i1 %61, label %62, label %92
62: ; preds = %55
store i32 7, i32* %10
br label %63
63: ; preds = %86, %62
%64 = load i32, i32* %10
%65 = icmp sge i32 %64, 0
br i1 %65, label %66, label %89
66: ; preds = %63
%67 = load i8, i8* %9
%68 = sext i8 %67 to i32
%69 = load i32, i32* %10
%70 = shl i32 1, %69
%71 = and i32 %68, %70
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = load i32*, i32** %8
%75 = call i32 @fprintf(i32* %74, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %79
76: ; preds = %66
%77 = load i32*, i32** %8
%78 = call i32 @fprintf(i32* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %79
79: ; preds = %76, %73
%80 = load i32, i32* %10
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32*, i32** %8
%84 = call i32 @fprintf(i32* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %85
85: ; preds = %82, %79
br label %86
86: ; preds = %85
%87 = load i32, i32* %10
%88 = add nsw i32 %87, -1
store i32 %88, i32* %10
br label %63
89: ; preds = %63
%90 = load i32*, i32** %8
%91 = call i32 @fprintf(i32* %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %55
92: ; preds = %55
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@.str = [55 x i8] c"Usage: %s [input binary file] [output lithuania file]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"Failed to open %s. Check if it exists\0A\00"
@.str.3 = [57 x i8] c"Warning, this will overwrite %s, beginning in 3 seconds\0A\00"
@.str.4 = [6 x i8] c"%d...\00"
@stdout = global i32 0
@.str.5 = [2 x i8] c"w\00"
@EOF = global i8 0
@.str.6 = [8 x i8] c"KEBABAS\00"
@.str.7 = [5 x i8] c"ALUS\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 0)
unreachable
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 ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %8
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 3)
%22 = load i32, i32* @stdout
%23 = tail call i32 @fflush(i32 %22)
%24 = tail call i32 @sleep(i32 1)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 2)
%26 = load i32, i32* @stdout
%27 = tail call i32 @fflush(i32 %26)
%28 = tail call i32 @sleep(i32 1)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 1)
%30 = load i32, i32* @stdout
%31 = tail call i32 @fflush(i32 %30)
%32 = tail call i32 @sleep(i32 1)
%33 = tail call i32 @putchar(i8 signext 10)
%34 = load i8*, i8** %18
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%36 = tail call signext i8 @fgetc(i32* %11)
%37 = load i8, i8* @EOF
%38 = icmp eq i8 %36, %37
br i1 %38, label %61, label %39
39: ; preds = %17, %42
%40 = phi i8 [ %44, %42 ], [ %36, %17 ]
%41 = sext i8 %40 to i32
br label %47
42: ; preds = %56
%43 = tail call i32 @fputc(i32 10, i32* %35)
%44 = tail call signext i8 @fgetc(i32* %11)
%45 = load i8, i8* @EOF
%46 = icmp eq i8 %44, %45
br i1 %46, label %61, label %39
47: ; preds = %58, %39
%48 = phi i32 [ 7, %39 ], [ %60, %58 ]
%49 = shl nuw i32 1, %48
%50 = and i32 %49, %41
%51 = icmp eq i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %47
%53 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %35)
br label %56
54: ; preds = %47
%55 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 4, i64 1, i32* %35)
br label %56
56: ; preds = %54, %52
%57 = icmp eq i32 %48, 0
br i1 %57, label %42, label %58
58: ; preds = %56
%59 = tail call i32 @fputc(i32 32, i32* %35)
%60 = add nsw i32 %48, -1
br label %47
61: ; preds = %42, %17
ret i32 0
}