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

/* Variables and functions */
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
char *getenv(char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(void) {
  Display *disp;
  char buf[4096];
  sprintf(buf, "XCOMPOSEFILE=%s/.XCompose", getenv("HOME"));
  putenv(buf);
  sprintf(buf, "XCOMPOSECACHE=%s/.XCompose.cache", getenv("HOME"));
  putenv(buf);
  disp = XOpenDisplay(NULL);
  if (disp)
    XCloseDisplay(disp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1020(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x1020(%rbp),%rdi
mov    %rax,%rdx
lea    0xe73(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1040 <putenv@plt>
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1018(%rbp)
lea    0xe67(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x1018(%rbp),%rdi
mov    %rax,%rdx
lea    0xe56(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1040 <putenv@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11fb <main+0xab>
mov    -0x10(%rbp),%rdi
call   1070 <XCloseDisplay@plt>
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
lea    0xeb9(%rip),%r14
mov    %r14,%rdi
call   1030 <getenv@plt>
lea    0xe90(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <putenv@plt>
mov    %r14,%rdi
call   1030 <getenv@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <putenv@plt>
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     11bc <main+0x6c>
mov    %rax,%rdi
call   1070 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"XCOMPOSEFILE=%s/.XCompose\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [33 x i8] c"XCOMPOSECACHE=%s/.XCompose.cache\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [4096 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%8 = call i32 @putenv(i8* %7)
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%10 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%13 = call i32 @putenv(i8* %12)
%14 = call i32* @XOpenDisplay(i32* null)
store i32* %14, i32** %2
%15 = load i32*, i32** %2
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = load i32*, i32** %2
%19 = call i32 @XCloseDisplay(i32* %18)
br label %20
20: ; preds = %17, %0
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [26 x i8] c"XCOMPOSEFILE=%s/.XCompose\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [33 x i8] c"XCOMPOSECACHE=%s/.XCompose.cache\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @putenv(i8* %2)
%6 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = call i32 @putenv(i8* %2)
%9 = call i32* @XOpenDisplay(i32* null)
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 @XCloseDisplay(i32* %9)
br label %13
13: ; preds = %11, %0
ret i32 0
}