#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 /*<<< orphan*/ printf(char *, ...);
void *readbyte();
int readfiledescription() {
  int i = 0;
  char letter = 0;
  int fnl = readbyte();
  printf("File description: ");
  do {
    letter = readbyte();
    printf("%c", letter);
    i++;
  } while (i != fnl);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<readfiledescription>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
mov    $0x0,%al
call   1040 <readbyte@plt>
mov    %eax,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <readbyte@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    114b <readfiledescription+0x2b>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readfiledescription>:
push   %rbx
xor    %eax,%eax
call   1050 <readbyte@plt>
mov    %rax,%rbx
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <readbyte@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1150 <readfiledescription+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"File description: \00"
define i32 @readfiledescription() {
%1 = tail call i8* (...) @readbyte()
%2 = ptrtoint i8* %1 to i64
%3 = trunc i64 %2 to i32
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ 0, %0 ], [ %13, %5 ]
%7 = tail call i8* (...) @readbyte()
%8 = ptrtoint i8* %7 to i64
%9 = trunc i64 %8 to i32
%10 = shl i32 %9, 24
%11 = ashr exact i32 %10, 24
%12 = tail call i32 @putchar(i32 %11)
%13 = add nuw nsw i32 %6, 1
%14 = icmp eq i32 %13, %3
br i1 %14, label %15, label %5
15: ; preds = %5
%16 = tail call i32 @putchar(i32 10)
ret i32 0
}