#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*/ EX_OSERR;
int asprintf(char **, char *, char *, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
char *realpath(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *gnupghome_dir(void) {
  char *cwd;
  int ret;
  char *str;
  cwd = realpath(".", NULL);
  if (!cwd) {
    fprintf(stderr, "%s: %s: %s\n", "prettykey", "realpath", strerror(errno));
    exit(EX_OSERR);
  }
  ret = asprintf(&str, "%s/%s", cwd, "GnuPG");
  if (ret == -1 || !str) {
    fprintf(stderr, "%s: %s: %s\n", "prettykey", "asprintf", strerror(errno));
    exit(EX_OSERR);
  }
  return str;
}


x86 assembly (clang, -O0):
<gnupghome_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <realpath@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11bf <gnupghome_dir+0x6f>
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%r8
lea    0xe64(%rip),%rsi
lea    0xe69(%rip),%rdx
lea    0xe6c(%rip),%rcx
call   1030 <fprintf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    0xe53(%rip),%rsi
lea    0xe52(%rip),%rcx
call   1050 <asprintf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     11f2 <gnupghome_dir+0xa2>
cmpq   $0x0,-0x18(%rbp)
jne    123a <gnupghome_dir+0xea>
mov    0x2de7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%r8
lea    0xde9(%rip),%rsi
lea    0xdee(%rip),%rdx
lea    0xe06(%rip),%rcx
call   1030 <fprintf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnupghome_dir>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
xor    %esi,%esi
call   1040 <realpath@plt>
test   %rax,%rax
je     1198 <gnupghome_dir+0x48>
lea    0xeb2(%rip),%rsi
lea    0xeb1(%rip),%rcx
lea    0x8(%rsp),%rdi
mov    %rax,%rdx
call   1050 <asprintf@plt>
cmp    $0xffffffff,%eax
je     11c6 <gnupghome_dir+0x76>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11c6 <gnupghome_dir+0x76>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e41(%rip),%rax
mov    (%rax),%ebx
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe4c(%rip),%rsi
lea    0xe51(%rip),%rdx
lea    0xe54(%rip),%rcx
jmp    11f2 <gnupghome_dir+0xa2>
mov    0x2e13(%rip),%rax
mov    (%rax),%ebx
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe1e(%rip),%rsi
lea    0xe23(%rip),%rdx
lea    0xe3b(%rip),%rcx
mov    %ebx,%edi
mov    %rax,%r8
call   1030 <fprintf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"%s: %s: %s\0A\00"
@.str.2 = [10 x i8] c"prettykey\00"
@.str.3 = [9 x i8] c"realpath\00"
@errno = global i32 0
@EX_OSERR = global i32 0
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [6 x i8] c"GnuPG\00"
@.str.6 = [9 x i8] c"asprintf\00"
define i8* @gnupghome_dir() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = call i8* @realpath(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* null)
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EX_OSERR
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load i8*, i8** %1
%16 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, -1
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = icmp ne i8* %20, null
br i1 %21, label %29, label %22
22: ; preds = %19, %14
%23 = load i32, i32* @stderr
%24 = load i32, i32* @errno
%25 = call i8* @strerror(i32 %24)
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EX_OSERR
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"%s: %s: %s\0A\00"
@.str.2 = [10 x i8] c"prettykey\00"
@.str.3 = [9 x i8] c"realpath\00"
@errno = global i32 0
@EX_OSERR = global i32 0
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [6 x i8] c"GnuPG\00"
@.str.6 = [9 x i8] c"asprintf\00"
define i8* @gnupghome_dir() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i8* @realpath(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* null)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EX_OSERR
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = call i32 @asprintf(i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%14 = icmp ne i32 %13, -1
%15 = load i8*, i8** %1
%16 = icmp ne i8* %15, null
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %25, label %18
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EX_OSERR
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %12
ret i8* %15
}