#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 /*<<< orphan*/ free(char *);
char *getenv(char *);
int /*<<< orphan*/ read_config(char *, void (*)(char const *, char const *));
char *string_join(char const *, char *);
void dvswitch_read_config(void (*item_handler)(const char *, const char *)) {
  read_config("/etc/dvswitchrc", item_handler);
  const char *home = getenv("HOME");
  if (home) {
    char *home_dvswitchrc = string_join(home, "/.dvswitchrc");
    read_config(home_dvswitchrc, item_handler);
    free(home_dvswitchrc);
  }
}


x86 assembly (clang, -O0):
<dvswitch_read_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1050 <read_config@plt>
lea    0xead(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a1 <dvswitch_read_config+0x61>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1060 <string_join@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <read_config@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvswitch_read_config>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rdi
mov    %r14,%rsi
call   1050 <read_config@plt>
lea    0xeb3(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1193 <dvswitch_read_config+0x53>
lea    0xea7(%rip),%rsi
mov    %rax,%rdi
call   1060 <string_join@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <read_config@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"/etc/dvswitchrc\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [13 x i8] c"/.dvswitchrc\00"
define void @dvswitch_read_config(void (i8*, i8*)* %0) {
%2 = alloca void (i8*, i8*)*
%3 = alloca i8*
%4 = alloca i8*
store void (i8*, i8*)* %0, void (i8*, i8*)** %2
%5 = load void (i8*, i8*)*, void (i8*, i8*)** %2
%6 = call i32 @read_config(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), void (i8*, i8*)* %5)
%7 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @string_join(i8* %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = load void (i8*, i8*)*, void (i8*, i8*)** %2
%15 = call i32 @read_config(i8* %13, void (i8*, i8*)* %14)
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
br label %18
18: ; preds = %10, %1
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"/etc/dvswitchrc\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [13 x i8] c"/.dvswitchrc\00"
define void @dvswitch_read_config(void (i8*, i8*)* %0) {
%2 = tail call i32 @read_config(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), void (i8*, i8*)* %0)
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = tail call i8* @string_join(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @read_config(i8* %6, void (i8*, i8*)* %0)
%8 = tail call i32 @free(i8* %6)
br label %9
9: ; preds = %5, %1
ret void
}