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

/* Variables and functions */
int /*<<< orphan*/ errno;
char *getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int system(char *);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int /*<<< orphan*/ unsetenv(char *);
int main(int argc, char **argv) {
  int sret = 0;
  char *env;
  char sh[1024];
  test_init(argc, argv);
  env = getenv("ZDTM_TESTS");
  if (env[0] != '\0') {
    unsetenv("ZDTM_NEWNS");
    unsetenv("ZDTM_GROUPS");
    unsetenv("ZDTM_UID");
    unsetenv("ZDTM_GID");
    unsetenv("ZDTM_ROOT");
    test_msg("List: [%s]\n", env);
    sprintf(sh, "sh /%s.start", env);
    system(sh);
  }
  test_daemon();
  test_waitsig();
  if (env[0] != '\0') {
    sprintf(sh, "sh /%s.stop", env);
    sret = system(sh);
  }
  if (sret == 0)
    test_msg("PASS\n");
  else
    test_msg("FAIL: %s:%d: "
             "Some subs failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/lib/groups.c",
             42, errno, strerror(errno));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <test_init@plt>
lea    0xe3d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124d <main+0xbd>
lea    0xe28(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe27(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe27(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe24(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe21(%rip),%rdi
call   1090 <unsetenv@plt>
mov    -0x20(%rbp),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe0e(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1050 <system@plt>
mov    $0x0,%al
call   1060 <test_daemon@plt>
mov    $0x0,%al
call   1080 <test_waitsig@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1291 <main+0x101>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdda(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    12ae <main+0x11e>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
jmp    12ee <main+0x15e>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x424(%rbp)
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x424(%rbp),%ecx
mov    %eax,%r8d
lea    0xd8e(%rip),%rdi
lea    0xdb8(%rip),%rsi
mov    $0x2a,%edx
mov    $0x0,%al
call   1070 <test_msg@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
call   1040 <test_init@plt>
lea    0xe5a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     121d <main+0x8d>
lea    0xe51(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe50(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe50(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe4d(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe4a(%rip),%rdi
call   1090 <unsetenv@plt>
lea    0xe48(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <test_msg@plt>
lea    0xe43(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   10a0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1060 <test_daemon@plt>
xor    %eax,%eax
call   1080 <test_waitsig@plt>
cmpb   $0x0,(%rbx)
je     1282 <main+0xf2>
lea    0xe20(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   10a0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
test   %eax,%eax
je     1282 <main+0xf2>
mov    0x2d88(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10b0 <strerror@plt>
lea    0xe01(%rip),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x2a,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <test_msg@plt>
jmp    1290 <main+0x100>
lea    0xdda(%rip),%rdi
xor    %eax,%eax
call   1070 <test_msg@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ZDTM_TESTS\00"
@.str.1 = [11 x i8] c"ZDTM_NEWNS\00"
@.str.2 = [12 x i8] c"ZDTM_GROUPS\00"
@.str.3 = [9 x i8] c"ZDTM_UID\00"
@.str.4 = [9 x i8] c"ZDTM_GID\00"
@.str.5 = [10 x i8] c"ZDTM_ROOT\00"
@.str.6 = [12 x i8] c"List: [%s]\0A\00"
@.str.7 = [13 x i8] c"sh /%s.start\00"
@.str.8 = [12 x i8] c"sh /%s.stop\00"
@.str.9 = [6 x i8] c"PASS\0A\00"
@.str.10 = [49 x i8] c"FAIL: %s:%d: Some subs failed (errno = %d (%s))\0A\00"
@.str.11 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/lib/groups.c\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @test_init(i32 %9, i8** %10)
%12 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %2
%19 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @unsetenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @unsetenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @unsetenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @unsetenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%24 = load i8*, i8** %7
%25 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%27 = load i8*, i8** %7
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%30 = call i32 @system(i8* %29)
br label %31
31: ; preds = %18, %2
%32 = call i32 (...) @test_daemon()
%33 = call i32 (...) @test_waitsig()
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %31
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%41 = load i8*, i8** %7
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%44 = call i32 @system(i8* %43)
store i32 %44, i32* %6
br label %45
45: ; preds = %39, %31
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %55
50: ; preds = %45
%51 = load i32, i32* @errno
%52 = load i32, i32* @errno
%53 = call i32 @strerror(i32 %52)
%54 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.11, i64 0, i64 0), i32 42, i32 %51, i32 %53)
br label %55
55: ; preds = %50, %48
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"ZDTM_TESTS\00"
@.str.1 = [11 x i8] c"ZDTM_NEWNS\00"
@.str.2 = [12 x i8] c"ZDTM_GROUPS\00"
@.str.3 = [9 x i8] c"ZDTM_UID\00"
@.str.4 = [9 x i8] c"ZDTM_GID\00"
@.str.5 = [10 x i8] c"ZDTM_ROOT\00"
@.str.6 = [12 x i8] c"List: [%s]\0A\00"
@.str.7 = [13 x i8] c"sh /%s.start\00"
@.str.8 = [12 x i8] c"sh /%s.stop\00"
@.str.9 = [6 x i8] c"PASS\0A\00"
@.str.10 = [49 x i8] c"FAIL: %s:%d: Some subs failed (errno = %d (%s))\0A\00"
@.str.11 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/lib/groups.c\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @test_init(i32 %0, i8** %1)
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = tail call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @unsetenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @unsetenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @unsetenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @unsetenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%16 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%17 = call i32 @system(i8* %4)
br label %18
18: ; preds = %9, %2
%19 = tail call i32 (...) @test_daemon()
%20 = tail call i32 (...) @test_waitsig()
%21 = load i8, i8* %6
%22 = icmp eq i8 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%25 = call i32 @system(i8* %4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %18, %23
%28 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %33
29: ; preds = %23
%30 = load i32, i32* @errno
%31 = tail call i32 @strerror(i32 %30)
%32 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.11, i64 0, i64 0), i32 42, i32 %30, i32 %31)
br label %33
33: ; preds = %29, %27
ret i32 0
}