#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*/ LC_ALL;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
void maketempfile(FILE *f, char **hash) {
  setlocale(LC_ALL, "");
  unsigned char x;
  int i;
  FILE *temp;
  temp = fopen("temp.txt", "w");
  rewind(f);
  for (i = 0; i < 16; i++) {
    fputc('0', temp);
  }
  while (1) {
    x = fgetc(f);
    if (feof(f)) {
      break;
    }
    fputs(hash[x], temp);
  }
  fclose(temp);
}


x86 assembly (clang, -O0):
<maketempfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1090 <setlocale@plt>
lea    0xe54(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    11f2 <maketempfile+0x72>
mov    -0x20(%rbp),%rsi
mov    $0x30,%edi
call   1070 <fputc@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11cc <maketempfile+0x4c>
jmp    11f7 <maketempfile+0x77>
mov    -0x8(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     121b <maketempfile+0x9b>
jmp    1235 <maketempfile+0xb5>
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <fputs@plt>
jmp    11f7 <maketempfile+0x77>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maketempfile>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1090 <setlocale@plt>
lea    0xe56(%rip),%rdi
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1040 <rewind@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    $0x30,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    12c8 <maketempfile+0x148>
movzbl %bl,%eax
mov    (%r14,%rax,8),%rdi
mov    %r12,%rsi
call   1050 <fputs@plt>
jmp    12a0 <maketempfile+0x120>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"temp.txt\00"
@.str.2 = [2 x i8] c"w\00"
define void @maketempfile(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32*
store i32* %0, i32** %3
store i8** %1, i8*** %4
%8 = load i32, i32* @LC_ALL
%9 = call i32 @setlocale(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %3
%12 = call i32 @rewind(i32* %11)
store i32 0, i32* %6
br label %13
13: ; preds = %19, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 16
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32*, i32** %7
%18 = call i32 @fputc(i32 48, i32* %17)
br label %19
19: ; preds = %16
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %13
22: ; preds = %13
br label %23
23: ; preds = %22, %30
%24 = load i32*, i32** %3
%25 = call zeroext i8 @fgetc(i32* %24)
store i8 %25, i8* %5
%26 = load i32*, i32** %3
%27 = call i64 @feof(i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23
br label %38
30: ; preds = %23
%31 = load i8**, i8*** %4
%32 = load i8, i8* %5
%33 = zext i8 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = load i32*, i32** %7
%37 = call i32 @fputs(i8* %35, i32* %36)
br label %23
38: ; preds = %29
%39 = load i32*, i32** %7
%40 = call i32 @fclose(i32* %39)
ret void
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"temp.txt\00"
@.str.2 = [2 x i8] c"w\00"
define void @maketempfile(i32* nocapture %0, i8** nocapture %1) {
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @rewind(i32* %0)
%7 = tail call i32 @fputc(i32 48, i32* %5)
%8 = tail call i32 @fputc(i32 48, i32* %5)
%9 = tail call i32 @fputc(i32 48, i32* %5)
%10 = tail call i32 @fputc(i32 48, i32* %5)
%11 = tail call i32 @fputc(i32 48, i32* %5)
%12 = tail call i32 @fputc(i32 48, i32* %5)
%13 = tail call i32 @fputc(i32 48, i32* %5)
%14 = tail call i32 @fputc(i32 48, i32* %5)
%15 = tail call i32 @fputc(i32 48, i32* %5)
%16 = tail call i32 @fputc(i32 48, i32* %5)
%17 = tail call i32 @fputc(i32 48, i32* %5)
%18 = tail call i32 @fputc(i32 48, i32* %5)
%19 = tail call i32 @fputc(i32 48, i32* %5)
%20 = tail call i32 @fputc(i32 48, i32* %5)
%21 = tail call i32 @fputc(i32 48, i32* %5)
%22 = tail call i32 @fputc(i32 48, i32* %5)
%23 = tail call zeroext i8 @fgetc(i32* %0)
%24 = tail call i64 @feof(i32* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %2, %26
%27 = phi i8 [ %32, %26 ], [ %23, %2 ]
%28 = zext i8 %27 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32 @fputs(i8* %30, i32* %5)
%32 = tail call zeroext i8 @fgetc(i32* %0)
%33 = tail call i64 @feof(i32* %0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %26, label %35
35: ; preds = %26, %2
%36 = tail call i32 @fclose(i32* %5)
ret void
}