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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, ...);
unsigned long read32(int /*<<< orphan*/ *);
int symbolhunk(FILE *fp) {
  unsigned long strsz;
  while ((strsz = read32(fp)) != 0) {
    strsz = strsz + 1;
    int i;
    for (i = 0; i < strsz; i++) {
      int ch0 = fgetc(fp);
      int ch1 = fgetc(fp);
      int ch2 = fgetc(fp);
      int ch3 = fgetc(fp);
      if (ch0 == EOF || ch1 == EOF || ch2 == EOF || ch3 == EOF) {
        printf("SymbolHunk reached end of file unexpectedly\n");
        fclose(fp);
        exit(2);
      }
      if (isprint(ch0))
        printf("%c", ch0);
      else
        printf(" ");
      if (isprint(ch1))
        printf("%c", ch1);
      else
        printf(" ");
      if (isprint(ch2))
        printf("%c", ch2);
      else
        printf(" ");
      if (isprint(ch3))
        printf("%c", ch3);
      else
        printf(" ");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<symbolhunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <read32@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     133b <symbolhunk+0x1db>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1328 <symbolhunk+0x1c8>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e0a(%rip),%rcx
cmp    (%rcx),%eax
je     121c <symbolhunk+0xbc>
mov    -0x1c(%rbp),%eax
mov    0x2df8(%rip),%rcx
cmp    (%rcx),%eax
je     121c <symbolhunk+0xbc>
mov    -0x20(%rbp),%eax
mov    0x2de6(%rip),%rcx
cmp    (%rcx),%eax
je     121c <symbolhunk+0xbc>
mov    -0x24(%rbp),%eax
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%eax
jne    123d <symbolhunk+0xdd>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     1265 <symbolhunk+0x105>
mov    -0x18(%rbp),%esi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1273 <symbolhunk+0x113>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     129b <symbolhunk+0x13b>
mov    -0x1c(%rbp),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a9 <symbolhunk+0x149>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     12d1 <symbolhunk+0x171>
mov    -0x20(%rbp),%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12df <symbolhunk+0x17f>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     1307 <symbolhunk+0x1a7>
mov    -0x24(%rbp),%esi
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1315 <symbolhunk+0x1b5>
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    131a <symbolhunk+0x1ba>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <symbolhunk+0x36>
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    116c <symbolhunk+0xc>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symbolhunk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
call   1080 <read32@plt>
test   %rax,%rax
je     1294 <symbolhunk+0x124>
mov    %rax,%r15
jmp    11bf <symbolhunk+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%rdi
call   1080 <read32@plt>
mov    %rax,%r15
test   %rax,%rax
je     1294 <symbolhunk+0x124>
cmp    $0xffffffffffffffff,%r15
je     11a0 <symbolhunk+0x30>
add    $0x1,%r15
nopl   0x0(%rax)
mov    (%rsp),%rbp
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r12d
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%r12d
je     12a5 <symbolhunk+0x135>
cmp    %eax,%r13d
je     12a5 <symbolhunk+0x135>
cmp    %eax,%ebx
je     12a5 <symbolhunk+0x135>
cmp    %eax,%r14d
je     12a5 <symbolhunk+0x135>
mov    %ebx,%edi
call   1070 <isprint@plt>
test   %rax,%rax
mov    $0x20,%ebp
cmove  %ebp,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    %r14d,%edi
call   1070 <isprint@plt>
test   %rax,%rax
cmove  %ebp,%r14d
mov    %r14d,%edi
call   1030 <putchar@plt>
mov    %r13d,%edi
call   1070 <isprint@plt>
test   %rax,%rax
cmove  %ebp,%r13d
mov    %r13d,%edi
call   1030 <putchar@plt>
mov    %r12d,%edi
call   1070 <isprint@plt>
test   %rax,%rax
cmove  %ebp,%r12d
mov    %r12d,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%r15
jne    11d0 <symbolhunk+0x60>
jmp    11a0 <symbolhunk+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd54(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rdi
call   1050 <fclose@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [45 x i8] c"SymbolHunk reached end of file unexpectedly\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @symbolhunk(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %2
br label %9
9: ; preds = %90, %1
%10 = load i32*, i32** %2
%11 = call i64 @read32(i32* %10)
store i64 %11, i64* %3
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %92
13: ; preds = %9
%14 = load i64, i64* %3
%15 = add i64 %14, 1
store i64 %15, i64* %3
store i32 0, i32* %4
br label %16
16: ; preds = %87, %13
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = load i64, i64* %3
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %90
21: ; preds = %16
%22 = load i32*, i32** %2
%23 = call i32 @fgetc(i32* %22)
store i32 %23, i32* %5
%24 = load i32*, i32** %2
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %6
%26 = load i32*, i32** %2
%27 = call i32 @fgetc(i32* %26)
store i32 %27, i32* %7
%28 = load i32*, i32** %2
%29 = call i32 @fgetc(i32* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %5
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %45, label %33
33: ; preds = %21
%34 = load i32, i32* %6
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %45, label %37
37: ; preds = %33
%38 = load i32, i32* %7
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = load i32, i32* %8
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %50
45: ; preds = %41, %37, %33, %21
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%47 = load i32*, i32** %2
%48 = call i32 @fclose(i32* %47)
%49 = call i32 @exit(i32 2)
unreachable
50: ; preds = %41
%51 = load i32, i32* %5
%52 = call i64 @isprint(i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i32, i32* %5
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %55)
br label %59
57: ; preds = %50
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %57, %54
%60 = load i32, i32* %6
%61 = call i64 @isprint(i32 %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i32, i32* %6
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %64)
br label %68
66: ; preds = %59
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = load i32, i32* %7
%70 = call i64 @isprint(i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = load i32, i32* %7
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %73)
br label %77
75: ; preds = %68
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %77
77: ; preds = %75, %72
%78 = load i32, i32* %8
%79 = call i64 @isprint(i32 %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = load i32, i32* %8
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %82)
br label %86
84: ; preds = %77
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %86
86: ; preds = %84, %81
br label %87
87: ; preds = %86
%88 = load i32, i32* %4
%89 = add nsw i32 %88, 1
store i32 %89, i32* %4
br label %16
90: ; preds = %16
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %9
92: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [44 x i8] c"SymbolHunk reached end of file unexpectedly\00"
define i32 @symbolhunk(i32* %0) {
%2 = tail call i64 @read32(i32* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %48, label %4
4: ; preds = %1, %44
%5 = phi i64 [ %46, %44 ], [ %2, %1 ]
%6 = icmp eq i64 %5, -1
br i1 %6, label %44, label %7
7: ; preds = %4, %25
%8 = phi i64 [ %42, %25 ], [ 0, %4 ]
%9 = tail call i32 @fgetc(i32* %0)
%10 = tail call i32 @fgetc(i32* %0)
%11 = tail call i32 @fgetc(i32* %0)
%12 = tail call i32 @fgetc(i32* %0)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %9, %13
%15 = icmp eq i32 %10, %13
%16 = or i1 %14, %15
%17 = icmp eq i32 %11, %13
%18 = or i1 %17, %16
%19 = icmp eq i32 %12, %13
%20 = or i1 %19, %18
br i1 %20, label %21, label %25
21: ; preds = %7
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @fclose(i32* %0)
%24 = tail call i32 @exit(i32 2)
unreachable
25: ; preds = %7
%26 = tail call i64 @isprint(i32 %9)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i32 32, i32 %9
%29 = tail call i32 @putchar(i32 %28)
%30 = tail call i64 @isprint(i32 %10)
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i32 32, i32 %10
%33 = tail call i32 @putchar(i32 %32)
%34 = tail call i64 @isprint(i32 %11)
%35 = icmp eq i64 %34, 0
%36 = select i1 %35, i32 32, i32 %11
%37 = tail call i32 @putchar(i32 %36)
%38 = tail call i64 @isprint(i32 %12)
%39 = icmp eq i64 %38, 0
%40 = select i1 %39, i32 32, i32 %12
%41 = tail call i32 @putchar(i32 %40)
%42 = add nuw i64 %8, 1
%43 = icmp eq i64 %8, %5
br i1 %43, label %44, label %7
44: ; preds = %25, %4
%45 = tail call i32 @putchar(i32 10)
%46 = tail call i64 @read32(i32* %0)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %4
48: ; preds = %44, %1
ret i32 0
}