#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 char uint8_t;
typedef size_t int32_t;

/* Variables and functions */
size_t encode_stream(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  uint8_t buf[(3 * 4 * 8) + 1];
  while (1) {
    int32_t ret = encode_stream(stdin, (3 * 4 * 8) + 1, buf);
    if (ret < 0) {
      exit(1);
    }
    buf[ret] = '\0';
    printf("%s\n", (char *)buf);
    if (ret < (3 * 4 * 8)) {
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rdx
mov    $0x61,%esi
call   1040 <encode_stream@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jae    117f <main+0x4f>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x88(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
cmpq   $0x60,-0x88(%rbp)
60
jae    11ae <main+0x7e>
jmp    11b3 <main+0x83>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    0x2eb6(%rip),%r12
mov    %rsp,%r15
lea    0xec4(%rip),%r14
nopl   0x0(%rax)
mov    (%r12),%edi
mov    $0x61,%esi
mov    %r15,%rdx
call   1040 <encode_stream@plt>
mov    %rax,%rbx
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
cmp    $0x5f,%rbx
ja     1140 <main+0x20>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [97 x i8]
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %2, %24
%9 = load i32, i32* @stdin
%10 = getelementptr inbounds [97 x i8], [97 x i8]* %6, i64 0, i64 0
%11 = call i64 @encode_stream(i32 %9, i32 97, i8* %10)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp ult i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %8
%17 = load i64, i64* %7
%18 = getelementptr inbounds [97 x i8], [97 x i8]* %6, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [97 x i8], [97 x i8]* %6, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i64, i64* %7
%22 = icmp ult i64 %21, 96
br i1 %22, label %23, label %24
23: ; preds = %16
br label %25
24: ; preds = %16
br label %8
25: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [97 x i8]
%4 = getelementptr inbounds [97 x i8], [97 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %5, %2
%6 = load i32, i32* @stdin
%7 = call i64 @encode_stream(i32 %6, i32 97, i8* %4)
%8 = getelementptr inbounds [97 x i8], [97 x i8]* %3, i64 0, i64 %7
store i8 0, i8* %8
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%10 = icmp ult i64 %7, 96
br i1 %10, label %11, label %5
11: ; preds = %5
ret i32 0
}