#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 O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
char *get_output(char *, char *);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
char *malloc(int);
int open(char *, int, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int write(int, char *, int);
void login_user(char *name, char *password) {
  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_RDWR | O_CREAT | O_TRUNC, 0666);
  char *output = get_output(name, password);
  int s = write(fd, output, 101);
  close(fd);
}


x86 assembly (clang, -O0):
<login_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    %eax,%edi
call   1050 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
mov    $0x190,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
mov    0x2e05(%rip),%rax
or     (%rax),%esi
mov    0x2df4(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <get_output@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0x65,%edx
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<login_user>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1060 <getuid@plt>
mov    %eax,%edi
call   1050 <getpwuid@plt>
mov    %rax,%r12
mov    $0x190,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    (%r12),%esi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    0x2dfa(%rip),%rax
mov    0x2e13(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e00(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
mov    $0x1b6,%edx
call   10a0 <open@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <get_output@plt>
mov    %ebx,%edi
mov    %rax,%rsi
mov    $0x65,%edx
call   1040 <write@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <close@plt>

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [12 x i8] c"/.rxc/udata\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
define void @login_user(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.passwd*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = call i32 (...) @getuid()
%11 = call %struct.passwd* @getpwuid(i32 %10)
store %struct.passwd* %11, %struct.passwd** %5
%12 = call i8* @malloc(i32 400)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = load %struct.passwd*, %struct.passwd** %5
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @strcpy(i8* %13, i32 %16)
%18 = load i8*, i8** %6
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %6
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_CREAT
%23 = or i32 %21, %22
%24 = load i32, i32* @O_TRUNC
%25 = or i32 %23, %24
%26 = call i32 @open(i8* %20, i32 %25, i32 438)
store i32 %26, i32* %7
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i8* @get_output(i8* %27, i8* %28)
store i8* %29, i8** %8
%30 = load i32, i32* %7
%31 = load i8*, i8** %8
%32 = call i32 @write(i32 %30, i8* %31, i32 101)
store i32 %32, i32* %9
%33 = load i32, i32* %7
%34 = call i32 @close(i32 %33)
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@.str = [12 x i8] c"/.rxc/udata\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
define void @login_user(i8* %0, i8* %1) {
%3 = tail call i32 (...) @getuid()
%4 = tail call %struct.passwd* @getpwuid(i32 %3)
%5 = tail call dereferenceable_or_null(400) i8* @malloc(i32 400)
%6 = getelementptr inbounds %struct.passwd, %struct.passwd* %4, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @strcpy(i8* %5, i32 %7)
%9 = tail call i32 @strcat(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @O_RDWR
%11 = load i32, i32* @O_CREAT
%12 = or i32 %11, %10
%13 = load i32, i32* @O_TRUNC
%14 = or i32 %12, %13
%15 = tail call i32 @open(i8* %5, i32 %14, i32 438)
%16 = tail call i8* @get_output(i8* %0, i8* %1)
%17 = tail call i32 @write(i32 %15, i8* %16, i32 101)
%18 = tail call i32 @close(i32 %15)
ret void
}