#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 */
struct passwd {
  int /*<<< orphan*/ pw_dir;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
char *malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
char *load_input() {
  struct passwd *pw = getpwuid(getuid());
  char *u_file = malloc(400);
  strcpy(u_file, pw->pw_dir);
  strcat(u_file, "/.rxc/udata");
  int fd = open(u_file, O_RDONLY);
  char *input = malloc(400);
  read(fd, input, 400);
  close(fd);
  return input;
}


x86 assembly (clang, -O0):
<load_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x8(%rbp)
mov    $0x190,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
mov    $0x190,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x190,%edx
call   1070 <read@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_input>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,%r14
mov    $0x190,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    (%r14),%esi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xe4c(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <open@plt>
mov    %eax,%ebp
mov    $0x190,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0x190,%edx
call   1070 <read@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [12 x i8] c"/.rxc/udata\00"
@O_RDONLY = global i32 0
define i8* @load_input() {
%1 = alloca %struct.passwd*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = call i32 (...) @getuid()
%6 = call %struct.passwd* @getpwuid(i32 %5)
store %struct.passwd* %6, %struct.passwd** %1
%7 = call i8* @malloc(i32 400)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = load %struct.passwd*, %struct.passwd** %1
%10 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @strcpy(i8* %8, i32 %11)
%13 = load i8*, i8** %2
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* %15, i32 %16)
store i32 %17, i32* %3
%18 = call i8* @malloc(i32 400)
store i8* %18, i8** %4
%19 = load i32, i32* %3
%20 = load i8*, i8** %4
%21 = call i32 @read(i32 %19, i8* %20, i32 400)
%22 = load i32, i32* %3
%23 = call i32 @close(i32 %22)
%24 = load i8*, i8** %4
ret i8* %24
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@.str = [12 x i8] c"/.rxc/udata\00"
@O_RDONLY = global i32 0
define noalias i8* @load_input() {
%1 = tail call i32 (...) @getuid()
%2 = tail call %struct.passwd* @getpwuid(i32 %1)
%3 = tail call dereferenceable_or_null(400) i8* @malloc(i32 400)
%4 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i32 @strcpy(i8* %3, i32 %5)
%7 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @O_RDONLY
%9 = tail call i32 @open(i8* %3, i32 %8)
%10 = tail call dereferenceable_or_null(400) i8* @malloc(i32 400)
%11 = tail call i32 @read(i32 %9, i8* %10, i32 400)
%12 = tail call i32 @close(i32 %9)
ret i8* %10
}