#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*/ pre_buffer;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ assert(int);
int getchar();
char *scan_keys(void) {
  static char pre_buffer[256];
  register size_t i;
  int character;
  for (i = 0; i < sizeof(pre_buffer); i++) {
    character = getchar();
    if (character == '\n')
      break;
    assert(character != EOF);
    pre_buffer[i] = (char)character;
  }
  assert(i < sizeof(pre_buffer));
  pre_buffer[i] = '\0';
  return &(pre_buffer[0]);
}


x86 assembly (clang, -O0):
<scan_keys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
cmpq   $0x100,-0x8(%rbp)
jae    1194 <scan_keys+0x74>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    1157 <scan_keys+0x37>
jmp    1194 <scan_keys+0x74>
mov    -0xc(%rbp),%eax
mov    0x2e87(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rcx
lea    0x2ec0(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1130 <scan_keys+0x10>
cmpq   $0x100,-0x8(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rcx
lea    0x2e8c(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e81(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_keys>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%eax
jne    113f <scan_keys+0x1f>
mov    $0x1,%edi
jmp    11a6 <scan_keys+0x86>
mov    %eax,%ebx
mov    0x2ea0(%rip),%r12
lea    0x2ef1(%rip),%r13
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%r15
xor    %edi,%edi
cmp    (%r12),%ebx
setne  %dil
call   1040 <assert@plt>
mov    %bl,(%r14,%r13,1)
cmp    $0xff,%r14
je     1193 <scan_keys+0x73>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ebx
lea    0x1(%r15),%r14
cmp    $0xa,%eax
jne    1160 <scan_keys+0x40>
jmp    1199 <scan_keys+0x79>
mov    $0x100,%r14d
xor    %edi,%edi
cmp    $0xff,%r15
setb   %dil
call   1040 <assert@plt>
lea    0x2e8e(%rip),%rax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@scan_keys.pre_buffer = internal global [256 x i8] zeroinitializer
@EOF = global i32 0
define i8* @scan_keys() {
%1 = alloca i64
%2 = alloca i32
store i64 0, i64* %1
br label %3
3: ; preds = %21, %0
%4 = load i64, i64* %1
%5 = icmp ult i64 %4, 256
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = call i32 (...) @getchar()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %6
br label %24
11: ; preds = %6
%12 = load i32, i32* %2
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %2
%18 = trunc i32 %17 to i8
%19 = load i64, i64* %1
%20 = getelementptr inbounds [256 x i8], [256 x i8]* @scan_keys.pre_buffer, i64 0, i64 %19
store i8 %18, i8* %20
br label %21
21: ; preds = %11
%22 = load i64, i64* %1
%23 = add i64 %22, 1
store i64 %23, i64* %1
br label %3
24: ; preds = %10, %3
%25 = load i64, i64* %1
%26 = icmp ult i64 %25, 256
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i64, i64* %1
%30 = getelementptr inbounds [256 x i8], [256 x i8]* @scan_keys.pre_buffer, i64 0, i64 %29
store i8 0, i8* %30
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @scan_keys.pre_buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@scan_keys.pre_buffer = internal global [256 x i8] zeroinitializer
@EOF = global i32 0
define i8* @scan_keys() {
%1 = tail call i32 (...) @getchar()
%2 = icmp eq i32 %1, 10
br i1 %2, label %21, label %6
3: ; preds = %6
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, 10
br i1 %5, label %17, label %6
6: ; preds = %0, %3
%7 = phi i32 [ %4, %3 ], [ %1, %0 ]
%8 = phi i64 [ %15, %3 ], [ 0, %0 ]
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %7, %9
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = trunc i32 %7 to i8
%14 = getelementptr inbounds [256 x i8], [256 x i8]* @scan_keys.pre_buffer, i64 0, i64 %8
store i8 %13, i8* %14
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, 256
br i1 %16, label %17, label %3
17: ; preds = %3, %6
%18 = phi i64 [ 256, %6 ], [ %15, %3 ]
%19 = icmp ult i64 %8, 255
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %17, %0
%22 = phi i64 [ 0, %0 ], [ %18, %17 ]
%23 = phi i32 [ 1, %0 ], [ %20, %17 ]
%24 = tail call i32 @assert(i32 %23)
%25 = getelementptr inbounds [256 x i8], [256 x i8]* @scan_keys.pre_buffer, i64 0, i64 %22
store i8 0, i8* %25
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @scan_keys.pre_buffer, i64 0, i64 0)
}