#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 */
struct _file_stream {
  int dummy;
};
struct _directory {
  int dummy;
};

/* Variables and functions */
struct _directory *directory_initial(char *, char *, int /*<<< orphan*/);
struct _file_stream *directory_open_file(struct _directory *, char *, char *,
                                         char *);
char *fs_read_string(struct _file_stream *);
int /*<<< orphan*/ printf(char *, char *);
void bit_test_main3() {
  struct _directory *dir = directory_initial("/root/sdoc", "/root/index", 0);
  struct _file_stream *in = directory_open_file(dir, "segments", ".x", "r");
  char *name = fs_read_string(in);
  printf("name: %s\n", name);
}


x86 assembly (clang, -O0):
<bit_test_main3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb5(%rip),%rsi
xor    %edx,%edx
call   1040 <directory_initial@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
lea    0xead(%rip),%rdx
lea    0xea9(%rip),%rcx
call   1060 <directory_open_file@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fs_read_string@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_test_main3>:
push   %rax
lea    0xeb8(%rip),%rdi
lea    0xebc(%rip),%rsi
xor    %edx,%edx
call   1040 <directory_initial@plt>
lea    0xeba(%rip),%rsi
lea    0xebc(%rip),%rdx
lea    0xeb8(%rip),%rcx
mov    %rax,%rdi
call   1060 <directory_open_file@plt>
mov    %rax,%rdi
call   1050 <fs_read_string@plt>
lea    0xea3(%rip),%rdi
mov    %rax,%rsi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct._directory = type { i32 }
%struct._file_stream = type { i32 }
@.str = [11 x i8] c"/root/sdoc\00"
@.str.1 = [12 x i8] c"/root/index\00"
@.str.2 = [9 x i8] c"segments\00"
@.str.3 = [3 x i8] c".x\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [10 x i8] c"name: %s\0A\00"
define void @bit_test_main3() {
%1 = alloca %struct._directory*
%2 = alloca %struct._file_stream*
%3 = alloca i8*
%4 = call %struct._directory* @directory_initial(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0)
store %struct._directory* %4, %struct._directory** %1
%5 = load %struct._directory*, %struct._directory** %1
%6 = call %struct._file_stream* @directory_open_file(%struct._directory* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store %struct._file_stream* %6, %struct._file_stream** %2
%7 = load %struct._file_stream*, %struct._file_stream** %2
%8 = call i8* @fs_read_string(%struct._file_stream* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %9)
ret void
}

LLVM IR (-O2):
%struct._directory = type { i32 }
%struct._file_stream = type { i32 }
@.str = [11 x i8] c"/root/sdoc\00"
@.str.1 = [12 x i8] c"/root/index\00"
@.str.2 = [9 x i8] c"segments\00"
@.str.3 = [3 x i8] c".x\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [10 x i8] c"name: %s\0A\00"
define void @bit_test_main3() {
%1 = tail call %struct._directory* @directory_initial(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0)
%2 = tail call %struct._file_stream* @directory_open_file(%struct._directory* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%3 = tail call i8* @fs_read_string(%struct._file_stream* %2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %3)
ret void
}