#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int hexFromFile(char const *);
int intFromFile(char const *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ unlink(char const *);
int testfilehelper() {
  const char *testfile = "tmp_tst.tmp";
  unlink(testfile);
  if (hexFromFile(testfile) != -1) {
    printf("Fail:"
           "hexFromFile(testfile)"
           " != "
           "-1"
           ".\n");
    return 1;
  };
  if (intFromFile(testfile) != -1) {
    printf("Fail:"
           "intFromFile(testfile)"
           " != "
           "-1"
           ".\n");
    return 1;
  };
  FILE *f = fopen(testfile, "w");
  fprintf(f, "42\n");
  fclose(f);
  if (hexFromFile(testfile) != 0x42) {
    printf("Fail:"
           "hexFromFile(testfile)"
           " != "
           "0x42"
           ".\n");
    return 1;
  };
  if (intFromFile(testfile) != 42) {
    printf("Fail:"
           "intFromFile(testfile)"
           " != "
           "42"
           ".\n");
    return 1;
  };
  unlink(testfile);
  return 0;
}


x86 assembly (clang, -O0):
<testfilehelper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x10(%rbp),%rdi
call   1030 <hexFromFile@plt>
cmp    $0xffffffff,%eax
je     11b6 <testfilehelper+0x46>
lea    0xe67(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1271 <testfilehelper+0x101>
mov    -0x10(%rbp),%rdi
call   1080 <intFromFile@plt>
cmp    $0xffffffff,%eax
je     11e0 <testfilehelper+0x70>
lea    0xe60(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1271 <testfilehelper+0x101>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <hexFromFile@plt>
cmp    $0x42,%eax
je     1237 <testfilehelper+0xc7>
lea    0xe32(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1271 <testfilehelper+0x101>
mov    -0x10(%rbp),%rdi
call   1080 <intFromFile@plt>
cmp    $0x2a,%eax
je     1261 <testfilehelper+0xf1>
lea    0xe2d(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1271 <testfilehelper+0x101>
mov    -0x10(%rbp),%rdi
call   1040 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testfilehelper>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rbx
mov    %rbx,%rdi
call   1040 <unlink@plt>
mov    %rbx,%rdi
call   1030 <hexFromFile@plt>
cmp    $0xffffffff,%eax
je     119c <testfilehelper+0x2c>
lea    0xee3(%rip),%rdi
jmp    122e <testfilehelper+0xbe>
lea    0xe5d(%rip),%rdi
call   1070 <intFromFile@plt>
cmp    $0xffffffff,%eax
je     11b6 <testfilehelper+0x46>
lea    0xea4(%rip),%rdi
jmp    122e <testfilehelper+0xbe>
lea    0xe43(%rip),%r14
lea    0xe48(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe38(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1090 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1030 <hexFromFile@plt>
cmp    $0x42,%eax
jne    121e <testfilehelper+0xae>
lea    0xdfc(%rip),%rdi
call   1070 <intFromFile@plt>
cmp    $0x2a,%eax
jne    1227 <testfilehelper+0xb7>
lea    0xdeb(%rip),%rdi
call   1040 <unlink@plt>
xor    %eax,%eax
jmp    1238 <testfilehelper+0xc8>
lea    0xe0f(%rip),%rdi
jmp    122e <testfilehelper+0xbe>
lea    0xde4(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"tmp_tst.tmp\00"
@.str.1 = [35 x i8] c"Fail:hexFromFile(testfile) != -1.\0A\00"
@.str.2 = [35 x i8] c"Fail:intFromFile(testfile) != -1.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"42\0A\00"
@.str.5 = [37 x i8] c"Fail:hexFromFile(testfile) != 0x42.\0A\00"
@.str.6 = [35 x i8] c"Fail:intFromFile(testfile) != 42.\0A\00"
define i32 @testfilehelper() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @unlink(i8* %4)
%6 = load i8*, i8** %2
%7 = call i32 @hexFromFile(i8* %6)
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %38
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i32 @intFromFile(i8* %12)
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %38
17: ; preds = %11
%18 = load i8*, i8** %2
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %3
%20 = load i32*, i32** %3
%21 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
%24 = load i8*, i8** %2
%25 = call i32 @hexFromFile(i8* %24)
%26 = icmp ne i32 %25, 66
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %38
29: ; preds = %17
%30 = load i8*, i8** %2
%31 = call i32 @intFromFile(i8* %30)
%32 = icmp ne i32 %31, 42
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %1
br label %38
35: ; preds = %29
%36 = load i8*, i8** %2
%37 = call i32 @unlink(i8* %36)
store i32 0, i32* %1
br label %38
38: ; preds = %35, %33, %27, %15, %9
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [12 x i8] c"tmp_tst.tmp\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"42\0A\00"
@str = [34 x i8] c"Fail:intFromFile(testfile) != 42.\00"
@str.7 = [36 x i8] c"Fail:hexFromFile(testfile) != 0x42.\00"
@str.8 = [34 x i8] c"Fail:intFromFile(testfile) != -1.\00"
@str.9 = [34 x i8] c"Fail:hexFromFile(testfile) != -1.\00"
define i32 @testfilehelper() {
%1 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @hexFromFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, -1
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
br label %26
6: ; preds = %0
%7 = tail call i32 @intFromFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.8, i64 0, i64 0))
br label %26
11: ; preds = %6
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 3, i64 1, i32* %12)
%14 = tail call i32 @fclose(i32* %12)
%15 = tail call i32 @hexFromFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 66
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.7, i64 0, i64 0))
br label %26
19: ; preds = %11
%20 = tail call i32 @intFromFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i32 %20, 42
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %17, %22, %24, %9, %4
%27 = phi i32 [ 1, %4 ], [ 1, %9 ], [ 1, %17 ], [ 1, %22 ], [ 0, %24 ]
ret i32 %27
}