#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;
typedef scalar_t__ gid_t;
typedef int /*<<< orphan*/ buf3;
typedef int /*<<< orphan*/ buf2;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int ENAMETOOLONG;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_current_username(char *, int);
int get_group_id(char *, scalar_t__ *);
int get_group_name(scalar_t__, char *, int);
int get_user_id(char *, int /*<<< orphan*/ *);
int get_user_name(int /*<<< orphan*/, char *, int);
scalar_t__ getgid();
char *index(char *, char);
int run_cmd_get_output(char *, int, char const **);
int /*<<< orphan*/ stderr;
int strcmp(char *, char *);
int main(void) {
  char buf[512], buf2[512], buf3[512], *newline;
  uid_t uid;
  gid_t gid, gid2;
  const char *cvec[] = {"whoami", NULL};
  do {
    if ((get_current_username(buf, 0)) != (-ENAMETOOLONG)) {
      fprintf(stderr, "failed on line %d: %s\n", 34,
              "get_current_username(buf, 0)");
      return 1;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = get_current_username(buf, sizeof(buf));
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 35,
              "get_current_username(buf, sizeof(buf))");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = run_cmd_get_output(buf2, sizeof(buf2), cvec);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 36,
              "run_cmd_get_output(buf2, sizeof(buf2), cvec)");
      return __my_ret__;
    }
  } while (0);
  ;
  newline = index(buf2, '\n');
  if (newline)
    *newline = '\0';
  if (strcmp(buf, buf2)) {
    fprintf(stderr,
            "get_current_username returned '%s', but "
            "whoami returned '%s'\n",
            buf, buf2);
    return EXIT_FAILURE;
  }
  do {
    int __my_ret__ = get_user_id(buf, &uid);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 45, "get_user_id(buf, &uid)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = get_user_name(uid, buf3, sizeof(buf3));
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 46,
              "get_user_name(uid, buf3, sizeof(buf3))");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = strcmp(buf, buf3);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 47, "strcmp(buf, buf3)");
      return __my_ret__;
    }
  } while (0);
  ;
  gid = getgid();
  do {
    int __my_ret__ = get_group_name(gid, buf3, sizeof(buf3));
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 49,
              "get_group_name(gid, buf3, sizeof(buf3))");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = get_group_id(buf3, &gid2);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 50,
              "get_group_id(buf3, &gid2)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    if ((gid) != (gid2)) {
      fprintf(stderr, "failed on line %d: %s\n", 51, "gid");
      return 1;
    }
  } while (0);
  ;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2c37(%rip),%rax
mov    %rax,-0x640(%rbp)
mov    0x2c31(%rip),%rax
mov    %rax,-0x638(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
call   1060 <get_current_username@plt>
xor    %ecx,%ecx
mov    0x2deb(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
je     121e <main+0x7e>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
mov    $0x22,%edx
lea    0xe13(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    1223 <main+0x83>
jmp    1228 <main+0x88>
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
call   1060 <get_current_username@plt>
mov    %eax,-0x644(%rbp)
cmpl   $0x0,-0x644(%rbp)
je     127d <main+0xdd>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
mov    $0x23,%edx
lea    0xdd3(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x644(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    1282 <main+0xe2>
jmp    1287 <main+0xe7>
lea    -0x410(%rbp),%rdi
lea    -0x640(%rbp),%rdx
mov    $0x200,%esi
call   1040 <run_cmd_get_output@plt>
mov    %eax,-0x648(%rbp)
cmpl   $0x0,-0x648(%rbp)
je     12e3 <main+0x143>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
lea    0xd45(%rip),%rsi
mov    $0x24,%edx
lea    0xd94(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x648(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    12e8 <main+0x148>
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1050 <index@plt>
mov    %rax,-0x618(%rbp)
cmpq   $0x0,-0x618(%rbp)
je     1318 <main+0x178>
mov    -0x618(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x210(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     136a <main+0x1ca>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
lea    -0x210(%rbp),%rdx
lea    -0x410(%rbp),%rcx
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    136f <main+0x1cf>
lea    -0x210(%rbp),%rdi
lea    -0x61c(%rbp),%rsi
call   1030 <get_user_id@plt>
mov    %eax,-0x64c(%rbp)
cmpl   $0x0,-0x64c(%rbp)
je     13c6 <main+0x226>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
lea    0xc62(%rip),%rsi
mov    $0x2d,%edx
lea    0xd1c(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x64c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    13cb <main+0x22b>
jmp    13d0 <main+0x230>
mov    -0x61c(%rbp),%edi
lea    -0x610(%rbp),%rsi
mov    $0x200,%edx
call   10c0 <get_user_name@plt>
mov    %eax,-0x650(%rbp)
cmpl   $0x0,-0x650(%rbp)
je     142b <main+0x28b>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
lea    0xbfd(%rip),%rsi
mov    $0x2e,%edx
lea    0xcce(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x650(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    1430 <main+0x290>
jmp    1435 <main+0x295>
lea    -0x210(%rbp),%rdi
lea    -0x610(%rbp),%rsi
call   1070 <strcmp@plt>
mov    %eax,-0x654(%rbp)
cmpl   $0x0,-0x654(%rbp)
je     148c <main+0x2ec>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
lea    0xb9c(%rip),%rsi
mov    $0x2f,%edx
lea    0xc94(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x654(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    1491 <main+0x2f1>
mov    $0x0,%al
call   1090 <getgid@plt>
mov    %rax,-0x628(%rbp)
mov    -0x628(%rbp),%rdi
lea    -0x610(%rbp),%rsi
mov    $0x200,%edx
call   10b0 <get_group_name@plt>
mov    %eax,-0x658(%rbp)
cmpl   $0x0,-0x658(%rbp)
je     14fb <main+0x35b>
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
lea    0xb2d(%rip),%rsi
mov    $0x31,%edx
lea    0xc37(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x658(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    1500 <main+0x360>
jmp    1505 <main+0x365>
lea    -0x610(%rbp),%rdi
lea    -0x630(%rbp),%rsi
call   10a0 <get_group_id@plt>
mov    %eax,-0x65c(%rbp)
cmpl   $0x0,-0x65c(%rbp)
je     155c <main+0x3bc>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
lea    0xacc(%rip),%rsi
mov    $0x32,%edx
lea    0xbfe(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x65c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    1561 <main+0x3c1>
jmp    1566 <main+0x3c6>
mov    -0x628(%rbp),%rax
cmp    -0x630(%rbp),%rax
je     15a9 <main+0x409>
mov    0x2a5f(%rip),%rax
mov    (%rax),%edi
lea    0xa7d(%rip),%rsi
mov    $0x33,%edx
lea    0xbc9(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ba <main+0x41a>
jmp    15ae <main+0x40e>
mov    0x2a13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x628,%rsp
movaps 0x2c3f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1060 <get_current_username@plt>
mov    0x2e07(%rip),%rcx
add    (%rcx),%eax
jne    1200 <main+0x60>
lea    0x20(%rsp),%rdi
mov    $0x200,%esi
call   1060 <get_current_username@plt>
test   %eax,%eax
je     122a <main+0x8a>
mov    %eax,%ebx
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
lea    0xe42(%rip),%rcx
mov    $0x23,%edx
jmp    1263 <main+0xc3>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
lea    0xe07(%rip),%rcx
mov    $0x22,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebx
jmp    126a <main+0xca>
lea    0x420(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    $0x200,%esi
call   1040 <run_cmd_get_output@plt>
test   %eax,%eax
je     1277 <main+0xd7>
mov    %eax,%ebx
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
lea    0xe04(%rip),%rcx
mov    $0x24,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %ebx,%eax
add    $0x628,%rsp
pop    %rbx
pop    %r14
ret
lea    0x420(%rsp),%rdi
mov    $0xa,%esi
call   1050 <index@plt>
test   %rax,%rax
je     1291 <main+0xf1>
movb   $0x0,(%rax)
lea    0x20(%rsp),%rdi
lea    0x420(%rsp),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     12d6 <main+0x136>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x420(%rsp),%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%ebx
jmp    126a <main+0xca>
lea    0x20(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1030 <get_user_id@plt>
test   %eax,%eax
je     130c <main+0x16c>
mov    %eax,%ebx
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
lea    0xd0c(%rip),%rsi
lea    0xdcb(%rip),%rcx
mov    $0x2d,%edx
jmp    1263 <main+0xc3>
mov    0x4(%rsp),%edi
lea    0x220(%rsp),%rsi
mov    $0x200,%edx
call   10c0 <get_user_name@plt>
test   %eax,%eax
je     1349 <main+0x1a9>
mov    %eax,%ebx
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
lea    0xccf(%rip),%rsi
lea    0xda5(%rip),%rcx
mov    $0x2e,%edx
jmp    1263 <main+0xc3>
lea    0x20(%rsp),%rdi
lea    0x220(%rsp),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1382 <main+0x1e2>
mov    %eax,%ebx
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
lea    0xc96(%rip),%rsi
lea    0xd93(%rip),%rcx
mov    $0x2f,%edx
jmp    1263 <main+0xc3>
xor    %eax,%eax
call   1090 <getgid@plt>
mov    %rax,%r14
lea    0x220(%rsp),%rsi
mov    %rax,%rdi
mov    $0x200,%edx
call   10b0 <get_group_name@plt>
test   %eax,%eax
je     13c8 <main+0x228>
mov    %eax,%ebx
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
lea    0xc50(%rip),%rsi
lea    0xd5f(%rip),%rcx
mov    $0x31,%edx
jmp    1263 <main+0xc3>
lea    0x220(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <get_group_id@plt>
test   %eax,%eax
je     1401 <main+0x261>
mov    %eax,%ebx
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
lea    0xc17(%rip),%rsi
lea    0xd4e(%rip),%rcx
mov    $0x32,%edx
jmp    1263 <main+0xc3>
cmp    0x8(%rsp),%r14
jne    1414 <main+0x274>
mov    0x2bb9(%rip),%rax
jmp    12d2 <main+0x132>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
lea    0xbe3(%rip),%rsi
lea    0xd34(%rip),%rcx
mov    $0x33,%edx
jmp    121c <main+0x7c>

LLVM IR (-O0):
@.str = [7 x i8] c"whoami\00"
@__const.main.cvec = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* null]
@ENAMETOOLONG = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.2 = [29 x i8] c"get_current_username(buf, 0)\00"
@.str.3 = [39 x i8] c"get_current_username(buf, sizeof(buf))\00"
@.str.4 = [45 x i8] c"run_cmd_get_output(buf2, sizeof(buf2), cvec)\00"
@.str.5 = [62 x i8] c"get_current_username returned '%s', but whoami returned '%s'\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [23 x i8] c"get_user_id(buf, &uid)\00"
@.str.7 = [39 x i8] c"get_user_name(uid, buf3, sizeof(buf3))\00"
@.str.8 = [18 x i8] c"strcmp(buf, buf3)\00"
@.str.9 = [40 x i8] c"get_group_name(gid, buf3, sizeof(buf3))\00"
@.str.10 = [26 x i8] c"get_group_id(buf3, &gid2)\00"
@.str.11 = [4 x i8] c"gid\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca [2 x i8*]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %1
%17 = bitcast [2 x i8*]* %9 to i8*
br label %18
18: ; preds = %0
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%20 = call i32 @get_current_username(i8* %19, i32 0)
%21 = load i32, i32* @ENAMETOOLONG
%22 = sub nsw i32 0, %21
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %139
27: ; preds = %18
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%31 = call i32 @get_current_username(i8* %30, i32 512)
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* %10
store i32 %37, i32* %1
br label %139
38: ; preds = %29
br label %39
39: ; preds = %38
br label %40
40: ; preds = %39
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%42 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 0
%43 = call i32 @run_cmd_get_output(i8* %41, i32 512, i8** %42)
store i32 %43, i32* %11
%44 = load i32, i32* %11
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 36, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* %11
store i32 %49, i32* %1
br label %139
50: ; preds = %40
br label %51
51: ; preds = %50
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%53 = call i8* @index(i8* %52, i8 signext 10)
store i8* %53, i8** %5
%54 = load i8*, i8** %5
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = load i8*, i8** %5
store i8 0, i8* %57
br label %58
58: ; preds = %56, %51
%59 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%61 = call i32 @strcmp(i8* %59, i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %58
%64 = load i32, i32* @stderr
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i8* %65, i8* %66)
%68 = load i32, i32* @EXIT_FAILURE
store i32 %68, i32* %1
br label %139
69: ; preds = %58
br label %70
70: ; preds = %69
%71 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%72 = call i32 @get_user_id(i8* %71, i32* %6)
store i32 %72, i32* %12
%73 = load i32, i32* %12
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %70
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* %12
store i32 %78, i32* %1
br label %139
79: ; preds = %70
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
%82 = load i32, i32* %6
%83 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%84 = call i32 @get_user_name(i32 %82, i8* %83, i32 512)
store i32 %84, i32* %13
%85 = load i32, i32* %13
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %81
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%90 = load i32, i32* %13
store i32 %90, i32* %1
br label %139
91: ; preds = %81
br label %92
92: ; preds = %91
br label %93
93: ; preds = %92
%94 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%96 = call i32 @strcmp(i8* %94, i8* %95)
store i32 %96, i32* %14
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %93
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%102 = load i32, i32* %14
store i32 %102, i32* %1
br label %139
103: ; preds = %93
br label %104
104: ; preds = %103
%105 = call i64 (...) @getgid()
store i64 %105, i64* %7
br label %106
106: ; preds = %104
%107 = load i64, i64* %7
%108 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%109 = call i32 @get_group_name(i64 %107, i8* %108, i32 512)
store i32 %109, i32* %15
%110 = load i32, i32* %15
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %106
%113 = load i32, i32* @stderr
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 49, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
%115 = load i32, i32* %15
store i32 %115, i32* %1
br label %139
116: ; preds = %106
br label %117
117: ; preds = %116
br label %118
118: ; preds = %117
%119 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%120 = call i32 @get_group_id(i8* %119, i64* %8)
store i32 %120, i32* %16
%121 = load i32, i32* %16
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %127
123: ; preds = %118
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%126 = load i32, i32* %16
store i32 %126, i32* %1
br label %139
127: ; preds = %118
br label %128
128: ; preds = %127
br label %129
129: ; preds = %128
%130 = load i64, i64* %7
%131 = load i64, i64* %8
%132 = icmp ne i64 %130, %131
br i1 %132, label %133, label %136
133: ; preds = %129
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %1
br label %139
136: ; preds = %129
br label %137
137: ; preds = %136
%138 = load i32, i32* @EXIT_SUCCESS
store i32 %138, i32* %1
br label %139
139: ; preds = %137, %133, %123, %112, %99, %87, %75, %63, %46, %34, %24
%140 = load i32, i32* %1
ret i32 %140
}

LLVM IR (-O2):
@.str = [7 x i8] c"whoami\00"
@__const.main.cvec = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* null]
@ENAMETOOLONG = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.2 = [29 x i8] c"get_current_username(buf, 0)\00"
@.str.3 = [39 x i8] c"get_current_username(buf, sizeof(buf))\00"
@.str.4 = [45 x i8] c"run_cmd_get_output(buf2, sizeof(buf2), cvec)\00"
@.str.5 = [62 x i8] c"get_current_username returned '%s', but whoami returned '%s'\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [23 x i8] c"get_user_id(buf, &uid)\00"
@.str.7 = [39 x i8] c"get_user_name(uid, buf3, sizeof(buf3))\00"
@.str.8 = [18 x i8] c"strcmp(buf, buf3)\00"
@.str.9 = [40 x i8] c"get_group_name(gid, buf3, sizeof(buf3))\00"
@.str.10 = [26 x i8] c"get_group_id(buf3, &gid2)\00"
@.str.11 = [4 x i8] c"gid\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca i64
%6 = alloca [2 x i8*]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = bitcast i32* %4 to i8*
%11 = bitcast i64* %5 to i8*
%12 = bitcast [2 x i8*]* %6 to i8*
%13 = call i32 @get_current_username(i8* %7, i32 0)
%14 = load i32, i32* @ENAMETOOLONG
%15 = sub nsw i32 0, %14
%16 = icmp eq i32 %13, %15
br i1 %16, label %20, label %17
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %84
20: ; preds = %0
%21 = call i32 @get_current_username(i8* %7, i32 512)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %84
26: ; preds = %20
%27 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%28 = call i32 @run_cmd_get_output(i8* %8, i32 512, i8** %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 36, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %84
33: ; preds = %26
%34 = call i8* @index(i8* %8, i8 signext 10)
%35 = icmp eq i8* %34, null
br i1 %35, label %37, label %36
36: ; preds = %33
store i8 0, i8* %34
br label %37
37: ; preds = %36, %33
%38 = call i32 @strcmp(i8* %7, i8* %8)
%39 = icmp eq i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i8* %7, i8* %8)
%43 = load i32, i32* @EXIT_FAILURE
br label %84
44: ; preds = %37
%45 = call i32 @get_user_id(i8* %7, i32* %4)
%46 = icmp eq i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %84
50: ; preds = %44
%51 = load i32, i32* %4
%52 = call i32 @get_user_name(i32 %51, i8* %9, i32 512)
%53 = icmp eq i32 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %84
57: ; preds = %50
%58 = call i32 @strcmp(i8* %7, i8* %9)
%59 = icmp eq i32 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %84
63: ; preds = %57
%64 = call i64 (...) @getgid()
%65 = call i32 @get_group_name(i64 %64, i8* %9, i32 512)
%66 = icmp eq i32 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %63
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 49, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
br label %84
70: ; preds = %63
%71 = call i32 @get_group_id(i8* %9, i64* %5)
%72 = icmp eq i32 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %84
76: ; preds = %70
%77 = load i64, i64* %5
%78 = icmp eq i64 %64, %77
br i1 %78, label %82, label %79
79: ; preds = %76
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
br label %84
82: ; preds = %76
%83 = load i32, i32* @EXIT_SUCCESS
br label %84
84: ; preds = %73, %67, %60, %54, %47, %30, %23, %82, %79, %40, %17
%85 = phi i32 [ 1, %17 ], [ %43, %40 ], [ 1, %79 ], [ %83, %82 ], [ %71, %73 ], [ %65, %67 ], [ %58, %60 ], [ %52, %54 ], [ %45, %47 ], [ %28, %30 ], [ %21, %23 ]
ret i32 %85
}