#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 */
char getchar();
int /*<<< orphan*/ printf(char *, char, char);
int /*<<< orphan*/ putchar(char);
int main(void) {
  char ch;
  int i = 0;
  while ((ch = getchar()) != '#') {
    printf("%c %3d\t", ch, ch);
    if (i++ % 8 == 7)
      putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     119d <main+0x6d>
mov    -0x5(%rbp),%al
lea    0xe9a(%rip),%rdi
movsbl %al,%esi
movsbl -0x5(%rbp),%edx
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    1198 <main+0x68>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x23,%al
jne    1147 <main+0x17>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xeb2(%rip),%rbx
xor    %ebp,%ebp
jmp    116e <main+0x3e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebp
cmp    $0x23,%al
je     113e <main+0xe>
movsbl %al,%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
jne    1160 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1160 <main+0x30>

LLVM IR (-O0):
@.str = [8 x i8] c"%c %3d\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %18, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 35
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = load i8, i8* %2
%10 = load i8, i8* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %9, i8 signext %10)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = srem i32 %12, 8
%15 = icmp eq i32 %14, 7
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 @putchar(i8 signext 10)
br label %18
18: ; preds = %16, %8
br label %4
19: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%c %3d\09\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = icmp eq i8 %1, 35
br i1 %2, label %15, label %3
3: ; preds = %0, %12
%4 = phi i8 [ %13, %12 ], [ %1, %0 ]
%5 = phi i32 [ %7, %12 ], [ 0, %0 ]
%6 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %4, i8 signext %4)
%7 = add nuw nsw i32 %5, 1
%8 = and i32 %5, 7
%9 = icmp eq i32 %8, 7
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @putchar(i8 signext 10)
br label %12
12: ; preds = %10, %3
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 35
br i1 %14, label %15, label %3
15: ; preds = %12, %0
ret i32 0
}