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

/* Variables and functions */
struct group *getgrgid(int /*<<< orphan*/);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char *argv[]) {
  struct stat props;
  struct passwd *o;
  struct group *g;
  if (argc <= 1) {
    printf("usage: %s file\n", argv[0]);
    return (1);
  }
  if (stat(argv[1], &props) != 0) {
    perror(argv[1]);
    return (1);
  }
  o = getpwuid(props.st_uid);
  g = getgrgid(props.st_gid);
  printf("%s.%s\n", o->pw_name, g->gr_name);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1191 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
je     11c5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <main+0xa9>
mov    -0x14(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <getgrgid@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1175 <main+0x25>
mov    (%rbx),%rsi
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    11b3 <main+0x63>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
jne    11bb <main+0x6b>
mov    0xc(%rsp),%edi
call   1030 <getpwuid@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%edi
call   1050 <getgrgid@plt>
mov    (%rbx),%rsi
mov    (%rax),%rdx
lea    0xe66(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rbx),%rdi
call   1070 <perror@plt>
mov    $0x1,%ebx
jmp    11b3 <main+0x63>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [16 x i8] c"usage: %s file\0A\00"
@.str.1 = [7 x i8] c"%s.%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca %struct.passwd*
%8 = alloca %struct.group*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %41
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @stat(i8* %19, %struct.stat* %6)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @perror(i8* %25)
store i32 1, i32* %3
br label %41
27: ; preds = %16
%28 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%29 = load i32, i32* %28
%30 = call %struct.passwd* @getpwuid(i32 %29)
store %struct.passwd* %30, %struct.passwd** %7
%31 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%32 = load i32, i32* %31
%33 = call %struct.group* @getgrgid(i32 %32)
store %struct.group* %33, %struct.group** %8
%34 = load %struct.passwd*, %struct.passwd** %7
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = load %struct.group*, %struct.group** %8
%38 = getelementptr inbounds %struct.group, %struct.group* %37, i32 0, i32 0
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %36, i8* %39)
br label %41
41: ; preds = %27, %22, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [16 x i8] c"usage: %s file\0A\00"
@.str.1 = [7 x i8] c"%s.%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %29
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @stat(i8* %11, %struct.stat* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = call i32 @perror(i8* %15)
br label %29
17: ; preds = %9
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%19 = load i32, i32* %18
%20 = call %struct.passwd* @getpwuid(i32 %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%22 = load i32, i32* %21
%23 = call %struct.group* @getgrgid(i32 %22)
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = getelementptr inbounds %struct.group, %struct.group* %23, i64 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %27)
br label %29
29: ; preds = %17, %14, %6
%30 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 0, %17 ]
ret i32 %30
}