#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 *);
int /*<<< orphan*/ fs_write_string(struct _file_stream *, char *);
void bit_test_main4() {
  struct _directory *dir = directory_initial("/root/sdoc", "/root/index", 0);
  struct _file_stream *in = directory_open_file(dir, "segments", ".x", "w");
  char *n = "hello";
  fs_write_string(in, n);
}


x86 assembly (clang, -O0):
<bit_test_main4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
lea    0xec5(%rip),%rsi
xor    %edx,%edx
call   1030 <directory_initial@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebb(%rip),%rsi
lea    0xebd(%rip),%rdx
lea    0xeb9(%rip),%rcx
call   1050 <directory_open_file@plt>
mov    %rax,-0x10(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fs_write_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_test_main4>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0xecc(%rip),%rsi
xor    %edx,%edx
call   1030 <directory_initial@plt>
lea    0xeca(%rip),%rsi
lea    0xecc(%rip),%rdx
lea    0xec8(%rip),%rcx
mov    %rax,%rdi
call   1050 <directory_open_file@plt>
lea    0xebb(%rip),%rsi
mov    %rax,%rdi
pop    %rax
jmp    1040 <fs_write_string@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"w\00"
@.str.5 = [6 x i8] c"hello\00"
define void @bit_test_main4() {
%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
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %3
%7 = load %struct._file_stream*, %struct._file_stream** %2
%8 = load i8*, i8** %3
%9 = call i32 @fs_write_string(%struct._file_stream* %7, i8* %8)
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"w\00"
@.str.5 = [6 x i8] c"hello\00"
define void @bit_test_main4() {
%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 i32 @fs_write_string(%struct._file_stream* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret void
}