#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 */
char EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void print_instructions(FILE *input) {
  char c;
  long pos = ftell(input);
  fseek(input, 0, SEEK_SET);
  printf("\033[1m"
         "Instructions:"
         "\033[0m"
         "\n");
  while ((c = getc(input)) != EOF) {
    if (ftell(input) == pos + 1) {
      printf("\033[1m"
             "\x1B[31m"
             "%c"
             "\033[0m",
             c);
    } else {
      printf("%c", c);
    }
  }
  fseek(input, pos, SEEK_SET);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_instructions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <fseek@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2e55(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e6 <print_instructions+0xa6>
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11cf <print_instructions+0x8f>
movsbl -0x9(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e1 <print_instructions+0xa1>
movsbl -0x9(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117d <print_instructions+0x3d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_instructions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <ftell@plt>
mov    %rax,%r12
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1080 <getc@plt>
mov    0x2e44(%rip),%r13
cmp    0x0(%r13),%al
jne    11d6 <print_instructions+0x76>
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <fseek@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %r12,%r14
add    $0x1,%r14
lea    0xe1c(%rip),%r15
jmp    1205 <print_instructions+0xa5>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1080 <getc@plt>
cmp    0x0(%r13),%al
je     11aa <print_instructions+0x4a>
movsbl %al,%ebp
mov    %rbx,%rdi
call   1060 <ftell@plt>
cmp    %r14,%rax
jne    11f0 <print_instructions+0x90>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f7 <print_instructions+0x97>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [23 x i8] c"\1B[1mInstructions:\1B[0m\0A\00"
@EOF = global i8 0
@.str.1 = [16 x i8] c"\1B[1m\1B[31m%c\1B[0m\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_instructions(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i64
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i64 @ftell(i32* %5)
store i64 %6, i64* %4
%7 = load i32*, i32** %2
%8 = load i32, i32* @SEEK_SET
%9 = call i32 @fseek(i32* %7, i64 0, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %32, %1
%12 = load i32*, i32** %2
%13 = call signext i8 @getc(i32* %12)
store i8 %13, i8* %3
%14 = sext i8 %13 to i32
%15 = load i8, i8* @EOF
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %14, %16
br i1 %17, label %18, label %33
18: ; preds = %11
%19 = load i32*, i32** %2
%20 = call i64 @ftell(i32* %19)
%21 = load i64, i64* %4
%22 = add nsw i64 %21, 1
%23 = icmp eq i64 %20, %22
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %32
28: ; preds = %18
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %24
br label %11
33: ; preds = %11
%34 = load i32*, i32** %2
%35 = load i64, i64* %4
%36 = load i32, i32* @SEEK_SET
%37 = call i32 @fseek(i32* %34, i64 %35, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@EOF = global i8 0
@.str.1 = [16 x i8] c"\1B[1m\1B[31m%c\1B[0m\00"
@str = [22 x i8] c"\1B[1mInstructions:\1B[0m\00"
define void @print_instructions(i32* nocapture %0) {
%2 = tail call i64 @ftell(i32* %0)
%3 = load i32, i32* @SEEK_SET
%4 = tail call i32 @fseek(i32* %0, i64 0, i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = tail call signext i8 @getc(i32* %0)
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %24, label %9
9: ; preds = %1
%10 = add nsw i64 %2, 1
br label %11
11: ; preds = %9, %20
%12 = phi i8 [ %6, %9 ], [ %21, %20 ]
%13 = sext i8 %12 to i32
%14 = tail call i64 @ftell(i32* %0)
%15 = icmp eq i64 %14, %10
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %20
18: ; preds = %11
%19 = tail call i32 @putchar(i32 %13)
br label %20
20: ; preds = %18, %16
%21 = tail call signext i8 @getc(i32* %0)
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %24, label %11
24: ; preds = %20, %1
%25 = load i32, i32* @SEEK_SET
%26 = tail call i32 @fseek(i32* %0, i64 %2, i32 %25)
%27 = tail call i32 @putchar(i32 10)
ret void
}