#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*/ cdecler(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *tmpfile();
void test_file(char *filename, char *cdecl_str) {
  freopen(filename, "r", stdin);
  FILE *pFile;
  pFile = tmpfile();
  cdecler(stdin, pFile);
  rewind(pFile);
  fgets(cdecl_str, 256, pFile);
  fclose(pFile);
  return;
}


x86 assembly (clang, -O0):
<test_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
lea    0xe7c(%rip),%rsi
call   1060 <freopen@plt>
mov    $0x0,%al
call   1080 <tmpfile@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <cdecler@plt>
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_file>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    0x2e79(%rip),%r15
mov    (%r15),%edx
lea    0xe87(%rip),%rsi
call   1060 <freopen@plt>
xor    %eax,%eax
call   1080 <tmpfile@plt>
mov    %rax,%rbx
mov    (%r15),%edi
mov    %rax,%rsi
call   1030 <cdecler@plt>
mov    %rbx,%rdi
call   1050 <rewind@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdin = global i32 0
define void @test_file(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i32, i32* @stdin
%8 = call i32 @freopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32* (...) @tmpfile()
store i32* %9, i32** %5
%10 = load i32, i32* @stdin
%11 = load i32*, i32** %5
%12 = call i32 @cdecler(i32 %10, i32* %11)
%13 = load i32*, i32** %5
%14 = call i32 @rewind(i32* %13)
%15 = load i8*, i8** %4
%16 = load i32*, i32** %5
%17 = call i32 @fgets(i8* %15, i32 256, i32* %16)
%18 = load i32*, i32** %5
%19 = call i32 @fclose(i32* %18)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdin = global i32 0
define void @test_file(i8* %0, i8* %1) {
%3 = load i32, i32* @stdin
%4 = tail call i32 @freopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32* (...) @tmpfile()
%6 = load i32, i32* @stdin
%7 = tail call i32 @cdecler(i32 %6, i32* %5)
%8 = tail call i32 @rewind(i32* %5)
%9 = tail call i32 @fgets(i8* %1, i32 256, i32* %5)
%10 = tail call i32 @fclose(i32* %5)
ret void
}