#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*/ uid_t;
struct stat {
  int /*<<< orphan*/ st_uid;
};
struct passwd {
  char *pw_name;
};

/* Variables and functions */
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ stat(char *, struct stat *);
char *GetOwner(char *queueDir, int thisJobID) {
  struct stat statBuff;
  struct passwd *pwdBuff;
  char jobFile[240];
  uid_t uid;
  sprintf(jobFile, "%s/%d", queueDir, thisJobID);
  stat(jobFile, &statBuff);
  uid = statBuff.st_uid;
  pwdBuff = getpwuid(uid);
  return (pwdBuff->pw_name);
}


x86 assembly (clang, -O0):
<GetOwner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xea9(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetOwner>:
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ecx
mov    %rdi,%rdx
lea    0xebc(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
mov    0x8(%rsp),%edi
call   1030 <getpwuid@plt>
mov    (%rax),%rax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.passwd = type { i8* }
@.str = [6 x i8] c"%s/%d\00"
define i8* @GetOwner(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.stat
%6 = alloca %struct.passwd*
%7 = alloca [240 x i8]
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = getelementptr inbounds [240 x i8], [240 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = getelementptr inbounds [240 x i8], [240 x i8]* %7, i64 0, i64 0
%14 = call i32 @stat(i8* %13, %struct.stat* %5)
%15 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%16 = load i32, i32* %15
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = call %struct.passwd* @getpwuid(i32 %17)
store %struct.passwd* %18, %struct.passwd** %6
%19 = load %struct.passwd*, %struct.passwd** %6
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %19, i32 0, i32 0
%21 = load i8*, i8** %20
ret i8* %21
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.passwd = type { i8* }
@.str = [6 x i8] c"%s/%d\00"
define i8* @GetOwner(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = alloca [240 x i8]
%5 = bitcast %struct.stat* %3 to i8*
%6 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%8 = call i32 @stat(i8* %6, %struct.stat* %3)
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call %struct.passwd* @getpwuid(i32 %10)
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%13 = load i8*, i8** %12
ret i8* %13
}