#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int setBit(int, int);
void putcodification(FILE *Writeoutput) {
  FILE *temp;
  temp = fopen("temp.txt", "r");
  long int size;
  int currentpos;
  currentpos = ftell(temp);
  fseek(temp, 0, SEEK_END);
  size = ftell(temp);
  fseek(temp, currentpos, SEEK_SET);
  fseek(temp, 16, SEEK_SET);
  while (1) {
    int i, ch = 0;
    for (i = 7; i >= 0; i--) {
      if (fgetc(temp) == '1') {
        ch = setBit(ch, i);
      }
    }
    fputc(ch, Writeoutput);
    if (ftell(temp) == size) {
      break;
    }
  }
  fclose(Writeoutput);
  fclose(temp);
}


x86 assembly (clang, -O0):
<putcodification>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe7d(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1070 <fseek@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x7,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     123a <putcodification+0xca>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
movsbl %al,%eax
cmp    $0x31,%eax
jne    1227 <putcodification+0xb7>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1090 <setBit@plt>
mov    %eax,-0x24(%rbp)
jmp    122c <putcodification+0xbc>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11fa <putcodification+0x8a>
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
cmp    -0x18(%rbp),%rax
jne    125e <putcodification+0xee>
jmp    1263 <putcodification+0xf3>
jmp    11ec <putcodification+0x7c>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putcodification>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    0xe7e(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <ftell@plt>
mov    %rax,%r12
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %rax,%r15
mov    0x2e17(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    %r12d,%esi
call   1070 <fseek@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <fseek@plt>
jmp    120b <putcodification+0x9b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
cmp    %r15,%rax
je     12e6 <putcodification+0x176>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    $0x0,%ebp
cmp    $0x31,%al
jne    122a <putcodification+0xba>
xor    %edi,%edi
mov    $0x7,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1244 <putcodification+0xd4>
mov    %ebp,%edi
mov    $0x6,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    125e <putcodification+0xee>
mov    %ebp,%edi
mov    $0x5,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1278 <putcodification+0x108>
mov    %ebp,%edi
mov    $0x4,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1292 <putcodification+0x122>
mov    %ebp,%edi
mov    $0x3,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    12ac <putcodification+0x13c>
mov    %ebp,%edi
mov    $0x2,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    12c6 <putcodification+0x156>
mov    %ebp,%edi
mov    $0x1,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11f0 <putcodification+0x80>
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <setBit@plt>
mov    %eax,%ebp
jmp    11f0 <putcodification+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"temp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define void @putcodification(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = call i64 @ftell(i32* %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %5
%12 = load i32*, i32** %3
%13 = load i32, i32* @SEEK_END
%14 = call i32 @fseek(i32* %12, i32 0, i32 %13)
%15 = load i32*, i32** %3
%16 = call i64 @ftell(i32* %15)
store i64 %16, i64* %4
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = load i32, i32* @SEEK_SET
%20 = call i32 @fseek(i32* %17, i32 %18, i32 %19)
%21 = load i32*, i32** %3
%22 = load i32, i32* @SEEK_SET
%23 = call i32 @fseek(i32* %21, i32 16, i32 %22)
br label %24
24: ; preds = %1, %50
store i32 0, i32* %7
store i32 7, i32* %6
br label %25
25: ; preds = %38, %24
%26 = load i32, i32* %6
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i32*, i32** %3
%30 = call signext i8 @fgetc(i32* %29)
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 49
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* %7
%35 = load i32, i32* %6
%36 = call i32 @setBit(i32 %34, i32 %35)
store i32 %36, i32* %7
br label %37
37: ; preds = %33, %28
br label %38
38: ; preds = %37
%39 = load i32, i32* %6
%40 = add nsw i32 %39, -1
store i32 %40, i32* %6
br label %25
41: ; preds = %25
%42 = load i32, i32* %7
%43 = load i32*, i32** %2
%44 = call i32 @fputc(i32 %42, i32* %43)
%45 = load i32*, i32** %3
%46 = call i64 @ftell(i32* %45)
%47 = load i64, i64* %4
%48 = icmp eq i64 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %41
br label %51
50: ; preds = %41
br label %24
51: ; preds = %49
%52 = load i32*, i32** %2
%53 = call i32 @fclose(i32* %52)
%54 = load i32*, i32** %3
%55 = call i32 @fclose(i32* %54)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"temp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define void @putcodification(i32* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i64 @ftell(i32* %2)
%4 = trunc i64 %3 to i32
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %2, i32 0, i32 %5)
%7 = tail call i64 @ftell(i32* %2)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %2, i32 %4, i32 %8)
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @fseek(i32* %2, i32 16, i32 %10)
br label %12
12: ; preds = %59, %1
%13 = tail call signext i8 @fgetc(i32* %2)
%14 = icmp eq i8 %13, 49
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @setBit(i32 0, i32 7)
br label %17
17: ; preds = %12, %15
%18 = phi i32 [ %16, %15 ], [ 0, %12 ]
%19 = tail call signext i8 @fgetc(i32* %2)
%20 = icmp eq i8 %19, 49
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i32 @setBit(i32 %18, i32 6)
br label %23
23: ; preds = %21, %17
%24 = phi i32 [ %22, %21 ], [ %18, %17 ]
%25 = tail call signext i8 @fgetc(i32* %2)
%26 = icmp eq i8 %25, 49
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = tail call i32 @setBit(i32 %24, i32 5)
br label %29
29: ; preds = %27, %23
%30 = phi i32 [ %28, %27 ], [ %24, %23 ]
%31 = tail call signext i8 @fgetc(i32* %2)
%32 = icmp eq i8 %31, 49
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = tail call i32 @setBit(i32 %30, i32 4)
br label %35
35: ; preds = %33, %29
%36 = phi i32 [ %34, %33 ], [ %30, %29 ]
%37 = tail call signext i8 @fgetc(i32* %2)
%38 = icmp eq i8 %37, 49
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 @setBit(i32 %36, i32 3)
br label %41
41: ; preds = %39, %35
%42 = phi i32 [ %40, %39 ], [ %36, %35 ]
%43 = tail call signext i8 @fgetc(i32* %2)
%44 = icmp eq i8 %43, 49
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = tail call i32 @setBit(i32 %42, i32 2)
br label %47
47: ; preds = %45, %41
%48 = phi i32 [ %46, %45 ], [ %42, %41 ]
%49 = tail call signext i8 @fgetc(i32* %2)
%50 = icmp eq i8 %49, 49
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = tail call i32 @setBit(i32 %48, i32 1)
br label %53
53: ; preds = %51, %47
%54 = phi i32 [ %52, %51 ], [ %48, %47 ]
%55 = tail call signext i8 @fgetc(i32* %2)
%56 = icmp eq i8 %55, 49
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = tail call i32 @setBit(i32 %54, i32 0)
br label %59
59: ; preds = %57, %53
%60 = phi i32 [ %58, %57 ], [ %54, %53 ]
%61 = tail call i32 @fputc(i32 %60, i32* %0)
%62 = tail call i64 @ftell(i32* %2)
%63 = icmp eq i64 %62, %7
br i1 %63, label %64, label %12
64: ; preds = %59
%65 = tail call i32 @fclose(i32* %0)
%66 = tail call i32 @fclose(i32* %2)
ret void
}