#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 uid_t;
struct tm {
  int dummy;
};
struct passwd {
  char *pw_name;
};
struct group {
  char *gr_name;
};
typedef int gid_t;

/* Variables and functions */
int getegid();
int geteuid();
int getgid();
struct group *getgrgid(int);
struct passwd *getpwuid(int);
int getuid();
int /*<<< orphan*/ printf(char *, ...);
int id(char **command, struct tm start) {
  struct passwd *pwd = NULL;
  struct group *gr = NULL;
  uid_t uid = getuid();
  printf("uid:%i", uid);
  pwd = getpwuid(uid);
  if (pwd)
    printf("(%s)", pwd->pw_name);
  printf(" ");
  uid_t euid = geteuid();
  printf("euid:%i", euid);
  pwd = getpwuid(euid);
  if (pwd)
    printf("(%s)", pwd->pw_name);
  printf(" ");
  gid_t gid = getgid();
  printf("gid:%i", gid);
  gr = getgrgid(gid);
  if (gr)
    printf("(%s)", gr->gr_name);
  gid_t egid = getegid();
  printf("egid:%i", egid);
  gr = getgrgid(egid);
  if (gr)
    printf("(%s)", gr->gr_name);
  printf("\n");
  return 1;
}


x86 assembly (clang, -O0):
<id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %esi,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d6 <id+0x66>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <geteuid@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     122b <id+0xbb>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getgid@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1060 <getgrgid@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1280 <id+0x110>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1090 <getegid@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
call   1060 <getgrgid@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12c7 <id+0x157>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<id>:
push   %rbx
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %eax,%ebx
lea    0xe75(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     11b7 <id+0x37>
mov    (%rax),%rsi
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1080 <geteuid@plt>
mov    %eax,%ebx
lea    0xe34(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     11f7 <id+0x77>
mov    (%rax),%rsi
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1090 <getgid@plt>
mov    %eax,%ebx
lea    0xdfd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1070 <getgrgid@plt>
test   %rax,%rax
je     1237 <id+0xb7>
mov    (%rax),%rsi
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <getegid@plt>
mov    %eax,%ebx
lea    0xdc6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1070 <getgrgid@plt>
test   %rax,%rax
je     126d <id+0xed>
mov    (%rax),%rsi
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [7 x i8] c"uid:%i\00"
@.str.1 = [5 x i8] c"(%s)\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [8 x i8] c"euid:%i\00"
@.str.4 = [7 x i8] c"gid:%i\00"
@.str.5 = [8 x i8] c"egid:%i\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @id(i8** %0, i32 %1) {
%3 = alloca %struct.tm
%4 = alloca i8**
%5 = alloca %struct.passwd*
%6 = alloca %struct.group*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
store i32 %1, i32* %11
store i8** %0, i8*** %4
store %struct.passwd* null, %struct.passwd** %5
store %struct.group* null, %struct.group** %6
%12 = call i32 (...) @getuid()
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %7
%16 = call %struct.passwd* @getpwuid(i32 %15)
store %struct.passwd* %16, %struct.passwd** %5
%17 = load %struct.passwd*, %struct.passwd** %5
%18 = icmp ne %struct.passwd* %17, null
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load %struct.passwd*, %struct.passwd** %5
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (...) @geteuid()
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %8
%30 = call %struct.passwd* @getpwuid(i32 %29)
store %struct.passwd* %30, %struct.passwd** %5
%31 = load %struct.passwd*, %struct.passwd** %5
%32 = icmp ne %struct.passwd* %31, null
br i1 %32, label %33, label %38
33: ; preds = %24
%34 = load %struct.passwd*, %struct.passwd** %5
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %33, %24
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (...) @getgid()
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %9
%44 = call %struct.group* @getgrgid(i32 %43)
store %struct.group* %44, %struct.group** %6
%45 = load %struct.group*, %struct.group** %6
%46 = icmp ne %struct.group* %45, null
br i1 %46, label %47, label %52
47: ; preds = %38
%48 = load %struct.group*, %struct.group** %6
%49 = getelementptr inbounds %struct.group, %struct.group* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %47, %38
%53 = call i32 (...) @getegid()
store i32 %53, i32* %10
%54 = load i32, i32* %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %10
%57 = call %struct.group* @getgrgid(i32 %56)
store %struct.group* %57, %struct.group** %6
%58 = load %struct.group*, %struct.group** %6
%59 = icmp ne %struct.group* %58, null
br i1 %59, label %60, label %65
60: ; preds = %52
%61 = load %struct.group*, %struct.group** %6
%62 = getelementptr inbounds %struct.group, %struct.group* %61, i32 0, i32 0
%63 = load i8*, i8** %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %60, %52
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [7 x i8] c"uid:%i\00"
@.str.1 = [5 x i8] c"(%s)\00"
@.str.3 = [8 x i8] c"euid:%i\00"
@.str.4 = [7 x i8] c"gid:%i\00"
@.str.5 = [8 x i8] c"egid:%i\00"
define i32 @id(i8** nocapture readnone %0, i32 %1) {
%3 = tail call i32 (...) @getuid()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call %struct.passwd* @getpwuid(i32 %3)
%6 = icmp eq %struct.passwd* %5, null
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %5, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %7, %2
%12 = tail call i32 @putchar(i32 32)
%13 = tail call i32 (...) @geteuid()
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = tail call %struct.passwd* @getpwuid(i32 %13)
%16 = icmp eq %struct.passwd* %15, null
br i1 %16, label %21, label %17
17: ; preds = %11
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 0
%19 = load i8*, i8** %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %11
%22 = tail call i32 @putchar(i32 32)
%23 = tail call i32 (...) @getgid()
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = tail call %struct.group* @getgrgid(i32 %23)
%26 = icmp eq %struct.group* %25, null
br i1 %26, label %31, label %27
27: ; preds = %21
%28 = getelementptr inbounds %struct.group, %struct.group* %25, i64 0, i32 0
%29 = load i8*, i8** %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %27, %21
%32 = tail call i32 (...) @getegid()
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = tail call %struct.group* @getgrgid(i32 %32)
%35 = icmp eq %struct.group* %34, null
br i1 %35, label %40, label %36
36: ; preds = %31
%37 = getelementptr inbounds %struct.group, %struct.group* %34, i64 0, i32 0
%38 = load i8*, i8** %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %36, %31
%41 = tail call i32 @putchar(i32 10)
ret i32 1
}