#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*/ gid_t;

/* Variables and functions */
int /*<<< orphan*/ getgid();
int getgroups(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ print_gid(int /*<<< orphan*/);
int /*<<< orphan*/ print_uid(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int id_main(int argc, char **argv) {
  gid_t list[64];
  int n, max;
  max = getgroups(64, list);
  if (max < 0)
    max = 0;
  printf("uid=");
  print_uid(getuid());
  printf(" gid=");
  print_gid(getgid());
  if (max) {
    printf(" groups=");
    print_gid(list[0]);
    for (n = 1; n < max; n++) {
      printf(",");
      print_gid(list[n]);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<id_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rsi
mov    $0x40,%edi
call   1080 <getgroups@plt>
mov    %eax,-0x118(%rbp)
cmpl   $0x0,-0x118(%rbp)
jge    11a0 <id_main+0x40>
movl   $0x0,-0x118(%rbp)
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,%edi
call   1060 <print_uid@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getgid@plt>
mov    %eax,%edi
call   1050 <print_gid@plt>
cmpl   $0x0,-0x118(%rbp)
je     124c <id_main+0xec>
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
mov    -0x110(%rbp),%edi
call   1050 <print_gid@plt>
movl   $0x1,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x118(%rbp),%eax
jge    1247 <id_main+0xe7>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
movslq -0x114(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%edi
call   1050 <print_gid@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1202 <id_main+0xa2>
jmp    124c <id_main+0xec>
lea    0xdc3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<id_main>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %rsp,%rsi
mov    $0x40,%edi
call   1090 <getgroups@plt>
mov    %eax,%ebx
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%edi
call   1070 <print_uid@plt>
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getgid@plt>
mov    %eax,%edi
call   1060 <print_gid@plt>
test   %ebx,%ebx
cmovns %ebx,%ebp
jle    120b <id_main+0x9b>
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
mov    (%rsp),%edi
call   1060 <print_gid@plt>
cmp    $0x2,%ebp
jb     120b <id_main+0x9b>
mov    %ebp,%ebx
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    (%rsp,%rbp,4),%edi
call   1060 <print_gid@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11f0 <id_main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"uid=\00"
@.str.1 = [6 x i8] c" gid=\00"
@.str.2 = [9 x i8] c" groups=\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @id_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [64 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%9 = call i32 @getgroups(i32 64, i32* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %7
br label %13
13: ; preds = %12, %2
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @getuid()
%16 = call i32 @print_uid(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (...) @getgid()
%19 = call i32 @print_gid(i32 %18)
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %42
22: ; preds = %13
%23 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%24 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%25 = load i32, i32* %24
%26 = call i32 @print_gid(i32 %25)
store i32 1, i32* %6
br label %27
27: ; preds = %38, %22
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 @print_gid(i32 %36)
br label %38
38: ; preds = %31
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %27
41: ; preds = %27
br label %42
42: ; preds = %41, %13
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"uid=\00"
@.str.1 = [6 x i8] c" gid=\00"
@.str.2 = [9 x i8] c" groups=\00"
define i32 @id_main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i32]
%4 = bitcast [64 x i32]* %3 to i8*
%5 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 0
%6 = call i32 @getgroups(i32 64, i32* %5)
%7 = icmp sgt i32 %6, 0
%8 = select i1 %7, i32 %6, i32 0
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @getuid()
%11 = call i32 @print_uid(i32 %10)
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (...) @getgid()
%14 = call i32 @print_gid(i32 %13)
br i1 %7, label %15, label %30
15: ; preds = %2
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* %5
%18 = call i32 @print_gid(i32 %17)
%19 = icmp ugt i32 %8, 1
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = zext i32 %8 to i64
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ 1, %20 ], [ %28, %22 ]
%24 = call i32 @putchar(i32 44)
%25 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 %23
%26 = load i32, i32* %25
%27 = call i32 @print_gid(i32 %26)
%28 = add nuw nsw i64 %23, 1
%29 = icmp eq i64 %28, %21
br i1 %29, label %30, label %22
30: ; preds = %22, %15, %2
%31 = call i32 @putchar(i32 10)
ret i32 0
}