#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 EOF;
int ascii2gsm(int);
int /*<<< orphan*/ base16(int);
int getchar();
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
int main() {
  int tmp = 0, bits = 0;
  for (int c = getchar(); c != EOF; c = getchar()) {
    tmp |= ascii2gsm(c) << bits;
    bits += 7;
    if (bits >= 8) {
      putchar(base16((tmp >> 4) & 15));
      putchar(base16(tmp & 15));
      tmp >>= 8;
      bits -= 8;
    }
  }
  if (bits == 1)
    tmp |= 0x0d << 1;
  if (bits) {
    putchar(base16((tmp >> 4) & 15));
    putchar(base16(tmp & 15));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     11ec <main+0xac>
mov    -0x10(%rbp),%edi
call   1060 <ascii2gsm@plt>
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jl     11d8 <main+0x98>
mov    -0x8(%rbp),%edi
sar    $0x4,%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    11dd <main+0x9d>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
jmp    1167 <main+0x27>
cmpl   $0x1,-0xc(%rbp)
jne    11ff <main+0xbf>
mov    -0x8(%rbp),%eax
or     $0x1a,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1230 <main+0xf0>
mov    -0x8(%rbp),%edi
sar    $0x4,%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e93(%rip),%r14
cmp    (%r14),%eax
je     11fa <main+0xba>
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    11a8 <main+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
sar    $0x8,%ebx
add    $0xffffffff,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     11c7 <main+0x87>
mov    %ebx,%ebp
mov    %eax,%edi
call   1060 <ascii2gsm@plt>
mov    %eax,%ebx
mov    %r15d,%ecx
shl    %cl,%ebx
or     %ebp,%ebx
test   %r15d,%r15d
jg     1170 <main+0x30>
mov    $0x7,%r15d
jmp    119c <main+0x5c>
test   %r15d,%r15d
je     11fa <main+0xba>
cmp    $0x1,%r15d
jne    11d5 <main+0x95>
or     $0x1a,%ebx
mov    %ebx,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
and    $0xf,%ebx
mov    %ebx,%edi
call   1050 <base16@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 (...) @getchar()
store i32 %5, i32* %4
br label %6
6: ; preds = %36, %0
%7 = load i32, i32* %4
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %38
10: ; preds = %6
%11 = load i32, i32* %4
%12 = call i32 @ascii2gsm(i32 %11)
%13 = load i32, i32* %3
%14 = shl i32 %12, %13
%15 = load i32, i32* %2
%16 = or i32 %15, %14
store i32 %16, i32* %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 7
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp sge i32 %19, 8
br i1 %20, label %21, label %35
21: ; preds = %10
%22 = load i32, i32* %2
%23 = ashr i32 %22, 4
%24 = and i32 %23, 15
%25 = call i32 @base16(i32 %24)
%26 = call i32 @putchar(i32 %25)
%27 = load i32, i32* %2
%28 = and i32 %27, 15
%29 = call i32 @base16(i32 %28)
%30 = call i32 @putchar(i32 %29)
%31 = load i32, i32* %2
%32 = ashr i32 %31, 8
store i32 %32, i32* %2
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 8
store i32 %34, i32* %3
br label %35
35: ; preds = %21, %10
br label %36
36: ; preds = %35
%37 = call i32 (...) @getchar()
store i32 %37, i32* %4
br label %6
38: ; preds = %6
%39 = load i32, i32* %3
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %2
%43 = or i32 %42, 26
store i32 %43, i32* %2
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %3
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %44
%48 = load i32, i32* %2
%49 = ashr i32 %48, 4
%50 = and i32 %49, 15
%51 = call i32 @base16(i32 %50)
%52 = call i32 @putchar(i32 %51)
%53 = load i32, i32* %2
%54 = and i32 %53, 15
%55 = call i32 @base16(i32 %54)
%56 = call i32 @putchar(i32 %55)
br label %57
57: ; preds = %47, %44
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %40, label %6
4: ; preds = %24
%5 = or i32 %25, 26
switch i32 %26, label %30 [
i32 1, label %31
i32 0, label %40
]
6: ; preds = %0, %24
%7 = phi i32 [ %27, %24 ], [ %1, %0 ]
%8 = phi i32 [ %26, %24 ], [ 0, %0 ]
%9 = phi i32 [ %25, %24 ], [ 0, %0 ]
%10 = tail call i32 @ascii2gsm(i32 %7)
%11 = shl i32 %10, %8
%12 = or i32 %11, %9
%13 = icmp sgt i32 %8, 0
br i1 %13, label %14, label %24
14: ; preds = %6
%15 = lshr i32 %12, 4
%16 = and i32 %15, 15
%17 = tail call i32 @base16(i32 %16)
%18 = tail call i32 @putchar(i32 %17)
%19 = and i32 %12, 15
%20 = tail call i32 @base16(i32 %19)
%21 = tail call i32 @putchar(i32 %20)
%22 = ashr i32 %12, 8
%23 = add nsw i32 %8, -1
br label %24
24: ; preds = %6, %14
%25 = phi i32 [ %22, %14 ], [ %12, %6 ]
%26 = phi i32 [ %23, %14 ], [ 7, %6 ]
%27 = tail call i32 (...) @getchar()
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %4, label %6
30: ; preds = %4
br label %31
31: ; preds = %4, %30
%32 = phi i32 [ %5, %4 ], [ %25, %30 ]
%33 = lshr i32 %32, 4
%34 = and i32 %33, 15
%35 = tail call i32 @base16(i32 %34)
%36 = tail call i32 @putchar(i32 %35)
%37 = and i32 %32, 15
%38 = tail call i32 @base16(i32 %37)
%39 = tail call i32 @putchar(i32 %38)
br label %40
40: ; preds = %4, %0, %31
ret i32 0
}