#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 */
size_t fread(char **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *raw_encoding_extract(char *, size_t);
int /*<<< orphan*/ stdin;
char *strtoupper(char *);
int main(void) {
  char buffer[4096];
  size_t len = fread(&buffer, sizeof(char), 4096, stdin);
  char *enc = raw_encoding_extract(buffer, len);
  if (enc != NULL) {
    printf("%s\n", strtoupper(enc));
    free(enc);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1010(%rbp),%rdi
mov    0x2e78(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %rax,-0x1018(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x1018(%rbp),%rsi
call   1070 <raw_encoding_extract@plt>
mov    %rax,-0x1020(%rbp)
cmpq   $0x0,-0x1020(%rbp)
je     11d7 <main+0x87>
mov    -0x1020(%rbp),%rdi
call   1050 <strtoupper@plt>
mov    %rax,%rsi
lea    0xe3a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x1020(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1000,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <raw_encoding_extract@plt>
test   %rax,%rax
je     11a8 <main+0x58>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strtoupper@plt>
lea    0xe68(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i64
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [4096 x i8]* %2 to i8**
%6 = load i32, i32* @stdin
%7 = call i64 @fread(i8** %5, i32 1, i32 4096, i32 %6)
store i64 %7, i64* %3
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%9 = load i64, i64* %3
%10 = call i8* @raw_encoding_extract(i8* %8, i64 %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i8*, i8** %4
%15 = call i8* @strtoupper(i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @free(i8* %17)
br label %19
19: ; preds = %13, %0
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%3 = bitcast [4096 x i8]* %1 to i8**
%4 = load i32, i32* @stdin
%5 = call i64 @fread(i8** %3, i32 1, i32 4096, i32 %4)
%6 = call i8* @raw_encoding_extract(i8* %2, i64 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = call i8* @strtoupper(i8* %6)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @free(i8* %6)
br label %12
12: ; preds = %8, %0
ret i32 0
}