#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int _fileno;
};
typedef TYPE_1__ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(TYPE_1__ *);
TYPE_1__ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  FILE *fp;
  fp = fopen("test.txt", "r");
  if (fp != NULL) {
    printf("fp->_fileno = %d\n", fp->_fileno);
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <main+0x4c>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1162 <main+0x32>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"fp->_fileno = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.TYPE_4__*
store i32 0, i32* %1
%3 = call %struct.TYPE_4__* @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 %struct.TYPE_4__* %3, %struct.TYPE_4__** %2
%4 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%5 = icmp ne %struct.TYPE_4__* %4, null
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%12 = call i32 @fclose(%struct.TYPE_4__* %11)
br label %13
13: ; preds = %6, %0
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"fp->_fileno = %d\0A\00"
define i32 @main() {
%1 = tail call %struct.TYPE_4__* @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))
%2 = icmp eq %struct.TYPE_4__* %1, null
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @fclose(%struct.TYPE_4__* %1)
br label %8
8: ; preds = %3, %0
ret i32 0
}