#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char const *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char const *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ sync();
void omb_utils_save(const char *key, const char *value) {
  char tmp[255];
  sprintf(tmp, "%s/%s/.%s", "/omb", "open-multiboot", key);
  FILE *fd = fopen(tmp, "w");
  if (fd) {
    fwrite(value, 1, strlen(value), fd);
    fclose(fd);
    sync();
  }
}


x86 assembly (clang, -O0):
<omb_utils_save>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%r8
lea    0xe7b(%rip),%rsi
lea    0xe7e(%rip),%rdx
lea    0xe7c(%rip),%rcx
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
je     1201 <omb_utils_save+0xa1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x120(%rbp),%rdi
mov    %eax,%edx
mov    -0x118(%rbp),%rcx
mov    $0x1,%esi
call   1080 <fwrite@plt>
mov    -0x118(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x0,%al
call   1050 <sync@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<omb_utils_save>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %rdi,%r8
lea    0xe89(%rip),%rsi
lea    0xe8c(%rip),%rdx
lea    0xe8a(%rip),%rcx
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11da <omb_utils_save+0x7a>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
jmp    1050 <sync@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s/%s/.%s\00"
@.str.1 = [5 x i8] c"/omb\00"
@.str.2 = [15 x i8] c"open-multiboot\00"
@.str.3 = [2 x i8] c"w\00"
define void @omb_utils_save(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [255 x i8]
%6 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = load i32*, i32** %6
%19 = call i32 @fwrite(i8* %15, i32 1, i32 %17, i32* %18)
%20 = load i32*, i32** %6
%21 = call i32 @fclose(i32* %20)
%22 = call i32 (...) @sync()
br label %23
23: ; preds = %14, %2
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s/%s/.%s\00"
@.str.1 = [5 x i8] c"/omb\00"
@.str.2 = [15 x i8] c"open-multiboot\00"
@.str.3 = [2 x i8] c"w\00"
define void @omb_utils_save(i8* %0, i8* %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %1)
%10 = tail call i32 @fwrite(i8* %1, i32 1, i32 %9, i32* %6)
%11 = tail call i32 @fclose(i32* %6)
%12 = tail call i32 (...) @sync()
br label %13
13: ; preds = %8, %2
ret void
}