#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 */
char *getenv(char *);
char *malloc(size_t);
int snprintf(char *, size_t, char *, char *);
char *getFileLocation(int temp) {
  if (temp == 1) {
    size_t bufferSize =
        snprintf(NULL, 0, "%s/.profanity.tmp", getenv("HOME")) + 1;
    char *buffer = malloc(bufferSize);
    snprintf(buffer, bufferSize, "%s/.profanity.tmp", getenv("HOME"));
    return buffer;
  }
  size_t bufferSize = snprintf(NULL, 0, "%s/.profanity", getenv("HOME")) + 1;
  char *buffer = malloc(bufferSize);
  snprintf(buffer, bufferSize, "%s/.profanity", getenv("HOME"));
  return buffer;
}


x86 assembly (clang, -O0):
<getFileLocation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11bd <getFileLocation+0x8d>
lea    0xec6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    %eax,%esi
lea    0xea1(%rip),%rdx
mov    %rsi,%rdi
call   1040 <snprintf@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe7e(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %rax,%rcx
lea    0xe55(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1230 <getFileLocation+0x100>
lea    0xe4e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    %eax,%esi
lea    0xe40(%rip),%rdx
mov    %rsi,%rdi
call   1040 <snprintf@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xe06(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %rax,%rcx
lea    0xdf4(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileLocation>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xed4(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x1,%ebx
jne    1151 <getFileLocation+0x21>
lea    0xeb1(%rip),%r14
jmp    1158 <getFileLocation+0x28>
lea    0xebf(%rip),%r14
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <snprintf@plt>
add    $0x1,%eax
movslq %eax,%r15
mov    %r15,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe93(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%s/.profanity.tmp\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [14 x i8] c"%s/.profanity\00"
define i8* @getFileLocation(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = add nsw i32 %12, 1
%14 = sext i32 %13 to i64
store i64 %14, i64* %4
%15 = load i64, i64* %4
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = load i64, i64* %4
%19 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @snprintf(i8* %17, i64 %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %5
store i8* %21, i8** %2
br label %34
22: ; preds = %1
%23 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = call i8* @malloc(i64 %27)
store i8* %28, i8** %7
%29 = load i8*, i8** %7
%30 = load i64, i64* %6
%31 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @snprintf(i8* %29, i64 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %7
store i8* %33, i8** %2
br label %34
34: ; preds = %22, %10
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s/.profanity.tmp\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [14 x i8] c"%s/.profanity\00"
define i8* @getFileLocation(i32 %0) {
%2 = icmp eq i32 %0, 1
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br i1 %2, label %4, label %11
4: ; preds = %1
%5 = tail call i32 @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = tail call i8* @malloc(i64 %7)
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @snprintf(i8* %8, i64 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %18
11: ; preds = %1
%12 = tail call i32 @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%13 = add nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = tail call i8* @malloc(i64 %14)
%16 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @snprintf(i8* %15, i64 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %11, %4
%19 = phi i8* [ %8, %4 ], [ %15, %11 ]
ret i8* %19
}