#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 getchar();
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ putchar(int);
void to7bit() {
  int ch;
  while ((ch = getchar()) != EOF) {
    ch &= 0xFF;
    if (ch >= 0200)
      (void)printf("\\%3.3o", (unsigned)ch);
    else
      (void)putchar(ch);
  }
}


x86 assembly (clang, -O0):
<to7bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e9f(%rip),%rcx
cmp    (%rcx),%eax
je     118a <to7bit+0x5a>
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jl     117d <to7bit+0x4d>
mov    -0x4(%rbp),%esi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
jmp    1185 <to7bit+0x55>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    1138 <to7bit+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to7bit>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea6(%rip),%rbx
cmp    (%rbx),%eax
jne    114e <to7bit+0x1e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeab(%rip),%r14
jmp    1172 <to7bit+0x42>
nopw   0x0(%rax,%rax,1)
mov    %esi,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%eax
je     1146 <to7bit+0x16>
movzbl %al,%esi
cmp    $0x80,%esi
jb     1160 <to7bit+0x30>
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    1167 <to7bit+0x37>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [7 x i8] c"\\%3.3o\00"
define void @to7bit() {
%1 = alloca i32
br label %2
2: ; preds = %17, %0
%3 = call i32 (...) @getchar()
store i32 %3, i32* %1
%4 = load i32, i32* @EOF
%5 = icmp ne i32 %3, %4
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = load i32, i32* %1
%8 = and i32 %7, 255
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = icmp sge i32 %9, 128
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %1
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %17
14: ; preds = %6
%15 = load i32, i32* %1
%16 = call i32 @putchar(i32 %15)
br label %17
17: ; preds = %14, %11
br label %2
18: ; preds = %2
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [7 x i8] c"\\%3.3o\00"
define void @to7bit() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %16, label %4
4: ; preds = %0, %12
%5 = phi i32 [ %13, %12 ], [ %1, %0 ]
%6 = and i32 %5, 255
%7 = icmp ugt i32 %6, 127
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %12
10: ; preds = %4
%11 = tail call i32 @putchar(i32 %6)
br label %12
12: ; preds = %10, %8
%13 = tail call i32 (...) @getchar()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %4
16: ; preds = %12, %0
ret void
}