#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 */

/* Variables and functions */
int copy_to_file_from_fd(int /*<<< orphan*/, char *);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ trio_fprintf(int /*<<< orphan*/, char *);
int save_settings_to_fs() {
  if (mkdir("/settings", 0777) != 0) {
    trio_fprintf(stderr, "Indexer settings not loaded\n");
    return -1;
  }
  int conf = copy_to_file_from_fd(0, "/settings/sphinx.conf");
  if (conf <= 0) {
    trio_fprintf(stderr, "Indexer settings not loaded\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<save_settings_to_fs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     1174 <save_settings_to_fs+0x44>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
call   1040 <trio_fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <save_settings_to_fs+0x87>
xor    %edi,%edi
lea    0xeaa(%rip),%rsi
call   1050 <copy_to_file_from_fd@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     11b0 <save_settings_to_fs+0x80>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1040 <trio_fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <save_settings_to_fs+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_settings_to_fs>:
push   %rbx
lea    0xec8(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
jne    115b <save_settings_to_fs+0x2b>
lea    0xed9(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <copy_to_file_from_fd@plt>
test   %eax,%eax
jg     1175 <save_settings_to_fs+0x45>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
call   1040 <trio_fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/settings\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"Indexer settings not loaded\0A\00"
@.str.2 = [22 x i8] c"/settings/sphinx.conf\00"
define i32 @save_settings_to_fs() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 511)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @trio_fprintf(i32 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %16
8: ; preds = %0
%9 = call i32 @copy_to_file_from_fd(i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = call i32 @trio_fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %16
15: ; preds = %8
store i32 0, i32* %1
br label %16
16: ; preds = %15, %12, %5
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [10 x i8] c"/settings\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"Indexer settings not loaded\0A\00"
@.str.2 = [22 x i8] c"/settings/sphinx.conf\00"
define i32 @save_settings_to_fs() {
%1 = tail call i64 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 511)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @copy_to_file_from_fd(i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp slt i32 %4, 1
br i1 %5, label %6, label %9
6: ; preds = %3, %0
%7 = load i32, i32* @stderr
%8 = tail call i32 @trio_fprintf(i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ 0, %3 ], [ -1, %6 ]
ret i32 %10
}