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

/* Variables and functions */
int __save_options(char *);
char *getenv(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int save_options(void) {
  char fn[256];
  if (getenv("HOME")) {
    snprintf(fn, sizeof(fn), "%s/.miniphone-conf", getenv("HOME"));
    return __save_options(fn);
  } else
    return __save_options("/etc/miniphone.conf");
}


x86 assembly (clang, -O0):
<save_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    0xebe(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     119a <save_options+0x6a>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x118(%rbp),%rdi
mov    %rax,%rcx
mov    $0x100,%esi
lea    0xe84(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <__save_options@plt>
mov    %eax,-0x4(%rbp)
jmp    11a9 <save_options+0x79>
lea    0xe77(%rip),%rdi
call   1040 <__save_options@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_options>:
push   %rbx
sub    $0x100,%rsp
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1174 <save_options+0x44>
lea    0xeb5(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <__save_options@plt>
add    $0x100,%rsp
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
add    $0x100,%rsp
pop    %rbx
jmp    1040 <__save_options@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [19 x i8] c"%s/.miniphone-conf\00"
@.str.2 = [20 x i8] c"/etc/miniphone.conf\00"
define i32 @save_options() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %11
5: ; preds = %0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%10 = call i32 @__save_options(i8* %9)
store i32 %10, i32* %1
br label %13
11: ; preds = %0
%12 = call i32 @__save_options(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 %12, i32* %1
br label %13
13: ; preds = %11, %5
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [19 x i8] c"%s/.miniphone-conf\00"
@.str.2 = [20 x i8] c"/etc/miniphone.conf\00"
define i32 @save_options() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @snprintf(i8* %2, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @__save_options(i8* %2)
br label %10
8: ; preds = %0
%9 = tail call i32 @__save_options(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ %7, %5 ], [ %9, %8 ]
ret i32 %11
}