#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*/ printf(char *, ...);
scalar_t__ strcmp(char const *, char *);
scalar_t__ test_heap();
scalar_t__ test_string();
int main(int argc, char **argv) {
  const char *testsuite;
  printf("Testing basic environment:\n");
  printf("\tstrcmp");
  {
    if (strcmp("", "") != 0) {
      printf("\nstrcmp(\"\", \"\") failed.\n");
      return 1;
    } else {
      printf(".");
    }
    if (strcmp("12345", "12345") != 0) {
      printf("\nstrcmp(\"12345\", \"12345\") failed.\n");
      return 1;
    } else {
      printf(".");
    }
    if (strcmp("12345", "123456") == 0) {
      printf("\nstrcmp(\"12345\", \"123456\") failed.\n");
      return 1;
    } else {
      printf(".");
    }
    if (strcmp("123456", "12345") == 0) {
      printf("\nstrcmp(\"123456\", \"12345\") failed.\n");
      return 1;
    } else {
      printf(".");
    }
    printf(" passed.\n");
  }
  printf("All tests passed.\n\n");
  if (argc == 1) {
    testsuite = "all";
  } else {
    testsuite = argv[1];
  }
  printf("Testsuite \"%s\" selected:\n", testsuite);
  if (!strcmp(testsuite, "string") || !strcmp(testsuite, "all")) {
    if (test_string()) {
      printf("string tests failed.\n");
      return 1;
    }
  }
  if (!strcmp(testsuite, "heap") || !strcmp(testsuite, "all")) {
    if (test_heap()) {
      printf("heap tests failed.\n");
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf5b(%rip),%rsi
mov    %rsi,%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11a5 <main+0x65>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe85(%rip),%rsi
mov    %rsi,%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11e6 <main+0xa6>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122b <main+0xeb>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe28(%rip),%rdi
lea    0xdf8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1270 <main+0x130>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    12b4 <main+0x174>
lea    0xe2a(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12c0 <main+0x180>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1306 <main+0x1c6>
mov    -0x18(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1336 <main+0x1f6>
mov    $0x0,%al
call   1050 <test_string@plt>
cmp    $0x0,%rax
je     1331 <main+0x1f1>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
jmp    1336 <main+0x1f6>
mov    -0x18(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     136a <main+0x22a>
mov    -0x18(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    139a <main+0x25a>
mov    $0x0,%al
call   1060 <test_heap@plt>
cmp    $0x0,%rax
je     1395 <main+0x255>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
jmp    139a <main+0x25a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeec(%rip),%rdi
mov    %rdi,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     119f <main+0x3f>
lea    0xf69(%rip),%rdi
jmp    11c4 <main+0x64>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe58(%rip),%rdi
mov    %rdi,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d7 <main+0x77>
lea    0xf20(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe20(%rip),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     124b <main+0xeb>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe04(%rip),%rdi
lea    0xdf7(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1257 <main+0xf7>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe2e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x1,%ebp
jne    1263 <main+0x103>
lea    0xdcc(%rip),%rbx
jmp    1267 <main+0x107>
lea    0xe6f(%rip),%rdi
jmp    11c4 <main+0x64>
lea    0xe40(%rip),%rdi
jmp    11c4 <main+0x64>
mov    0x8(%rbx),%rbx
lea    0xdab(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdb4(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12a0 <main+0x140>
lea    0xd82(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12b8 <main+0x158>
xor    %eax,%eax
call   1070 <test_string@plt>
test   %rax,%rax
je     12b8 <main+0x158>
lea    0xdd6(%rip),%rdi
jmp    11c4 <main+0x64>
lea    0xd7b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12e6 <main+0x186>
lea    0xd42(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    11ce <main+0x6e>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <test_heap@plt>
test   %rax,%rax
je     11ce <main+0x6e>
lea    0xd77(%rip),%rdi
jmp    11c4 <main+0x64>

LLVM IR (-O0):
@.str = [28 x i8] c"Testing basic environment:\0A\00"
@.str.1 = [8 x i8] c"\09strcmp\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [25 x i8] c"\0Astrcmp(\22\22, \22\22) failed.\0A\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [6 x i8] c"12345\00"
@.str.6 = [35 x i8] c"\0Astrcmp(\2212345\22, \2212345\22) failed.\0A\00"
@.str.7 = [7 x i8] c"123456\00"
@.str.8 = [36 x i8] c"\0Astrcmp(\2212345\22, \22123456\22) failed.\0A\00"
@.str.9 = [36 x i8] c"\0Astrcmp(\22123456\22, \2212345\22) failed.\0A\00"
@.str.10 = [10 x i8] c" passed.\0A\00"
@.str.11 = [20 x i8] c"All tests passed.\0A\0A\00"
@.str.12 = [4 x i8] c"all\00"
@.str.13 = [26 x i8] c"Testsuite \22%s\22 selected:\0A\00"
@.str.14 = [7 x i8] c"string\00"
@.str.15 = [22 x i8] c"string tests failed.\0A\00"
@.str.16 = [5 x i8] c"heap\00"
@.str.17 = [20 x i8] c"heap tests failed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %77
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %13
%16 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %77
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20
%23 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %77
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %77
34: ; preds = %29
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %42
41: ; preds = %36
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8** %6
br label %46
42: ; preds = %36
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
store i8* %45, i8** %6
br label %46
46: ; preds = %42, %41
%47 = load i8*, i8** %6
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8* %47)
%49 = load i8*, i8** %6
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = load i8*, i8** %6
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%55 = icmp ne i64 %54, 0
br i1 %55, label %62, label %56
56: ; preds = %52, %46
%57 = call i64 (...) @test_string()
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %3
br label %77
61: ; preds = %56
br label %62
62: ; preds = %61, %52
%63 = load i8*, i8** %6
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i8*, i8** %6
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%69 = icmp ne i64 %68, 0
br i1 %69, label %76, label %70
70: ; preds = %66, %62
%71 = call i64 (...) @test_heap()
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.17, i64 0, i64 0))
store i32 1, i32* %3
br label %77
75: ; preds = %70
br label %76
76: ; preds = %75, %66
store i32 0, i32* %3
br label %77
77: ; preds = %76, %73, %59, %32, %25, %18, %11
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"\09strcmp\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.5 = [6 x i8] c"12345\00"
@.str.7 = [7 x i8] c"123456\00"
@.str.12 = [4 x i8] c"all\00"
@.str.13 = [26 x i8] c"Testsuite \22%s\22 selected:\0A\00"
@.str.14 = [7 x i8] c"string\00"
@.str.16 = [5 x i8] c"heap\00"
@str = [27 x i8] c"Testing basic environment:\00"
@str.18 = [9 x i8] c" passed.\00"
@str.19 = [19 x i8] c"All tests passed.\0A\00"
@str.20 = [19 x i8] c"heap tests failed.\00"
@str.21 = [21 x i8] c"string tests failed.\00"
@str.22 = [35 x i8] c"\0Astrcmp(\22123456\22, \2212345\22) failed.\00"
@str.23 = [35 x i8] c"\0Astrcmp(\2212345\22, \22123456\22) failed.\00"
@str.24 = [34 x i8] c"\0Astrcmp(\2212345\22, \2212345\22) failed.\00"
@str.25 = [24 x i8] c"\0Astrcmp(\22\22, \22\22) failed.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %47
7: ; preds = %2
%8 = tail call i32 @putchar(i32 46)
%9 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %7
%12 = tail call i32 @putchar(i32 46)
%13 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %47, label %15
15: ; preds = %11
%16 = tail call i32 @putchar(i32 46)
%17 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %47, label %19
19: ; preds = %15
%20 = tail call i32 @putchar(i32 46)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.18, i64 0, i64 0))
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.19, i64 0, i64 0))
%23 = icmp eq i32 %0, 1
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
br label %27
27: ; preds = %19, %24
%28 = phi i8* [ %26, %24 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), %19 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8* %28)
%30 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %27
%33 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32, %27
%36 = tail call i64 (...) @test_string()
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %35, %32
%39 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41, %38
%45 = tail call i64 (...) @test_heap()
%46 = icmp eq i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44, %35, %15, %11, %7, %2
%48 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.25, i64 0, i64 0), %2 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.24, i64 0, i64 0), %7 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.23, i64 0, i64 0), %11 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.22, i64 0, i64 0), %15 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.21, i64 0, i64 0), %35 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.20, i64 0, i64 0), %44 ]
%49 = tail call i32 @puts(i8* dereferenceable(1) %48)
br label %50
50: ; preds = %47, %41, %44
%51 = phi i32 [ 0, %44 ], [ 0, %41 ], [ 1, %47 ]
ret i32 %51
}