#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");
    unsetenv("ZDTM_PIDFILE");
    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/fbocharov/criu/refs/heads/master/test/"
             "zdtm/lib/groups.c",
             43, 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     1259 <main+0xc9>
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>
lea    0xe1f(%rip),%rdi
call   1090 <unsetenv@plt>
mov    -0x20(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe0f(%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     129d <main+0x10d>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xddb(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    12ba <main+0x12a>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
jmp    12fa <main+0x16a>
mov    0x2d1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x424(%rbp)
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x424(%rbp),%ecx
mov    %eax,%r8d
lea    0xd8f(%rip),%rdi
lea    0xdb9(%rip),%rsi
mov    $0x2b,%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     1229 <main+0x99>
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
call   1090 <unsetenv@plt>
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <test_msg@plt>
lea    0xe44(%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     128e <main+0xfe>
lea    0xe21(%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     128e <main+0xfe>
mov    0x2d7c(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10b0 <strerror@plt>
lea    0xe02(%rip),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x2b,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <test_msg@plt>
jmp    129c <main+0x10c>
lea    0xddb(%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 = [13 x i8] c"ZDTM_PIDFILE\00"
@.str.7 = [12 x i8] c"List: [%s]\0A\00"
@.str.8 = [13 x i8] c"sh /%s.start\00"
@.str.9 = [12 x i8] c"sh /%s.stop\00"
@.str.10 = [6 x i8] c"PASS\0A\00"
@.str.11 = [49 x i8] c"FAIL: %s:%d: Some subs failed (errno = %d (%s))\0A\00"
@.str.12 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fbocharov/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 %32
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 = call i32 @unsetenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%25 = load i8*, i8** %7
%26 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%28 = load i8*, i8** %7
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%31 = call i32 @system(i8* %30)
br label %32
32: ; preds = %18, %2
%33 = call i32 (...) @test_daemon()
%34 = call i32 (...) @test_waitsig()
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %32
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = load i8*, i8** %7
%43 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%45 = call i32 @system(i8* %44)
store i32 %45, i32* %6
br label %46
46: ; preds = %40, %32
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %56
51: ; preds = %46
%52 = load i32, i32* @errno
%53 = load i32, i32* @errno
%54 = call i32 @strerror(i32 %53)
%55 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.12, i64 0, i64 0), i32 43, i32 %52, i32 %54)
br label %56
56: ; preds = %51, %49
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 = [13 x i8] c"ZDTM_PIDFILE\00"
@.str.7 = [12 x i8] c"List: [%s]\0A\00"
@.str.8 = [13 x i8] c"sh /%s.start\00"
@.str.9 = [12 x i8] c"sh /%s.stop\00"
@.str.10 = [6 x i8] c"PASS\0A\00"
@.str.11 = [49 x i8] c"FAIL: %s:%d: Some subs failed (errno = %d (%s))\0A\00"
@.str.12 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fbocharov/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 %19, 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 @unsetenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%17 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%18 = call i32 @system(i8* %4)
br label %19
19: ; preds = %9, %2
%20 = tail call i32 (...) @test_daemon()
%21 = tail call i32 (...) @test_waitsig()
%22 = load i8, i8* %6
%23 = icmp eq i8 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%26 = call i32 @system(i8* %4)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %19, %24
%29 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %34
30: ; preds = %24
%31 = load i32, i32* @errno
%32 = tail call i32 @strerror(i32 %31)
%33 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.12, i64 0, i64 0), i32 43, i32 %31, i32 %32)
br label %34
34: ; preds = %30, %28
ret i32 0
}