#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 count_tests();
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ test(int);
int test_all() {
  int i = 0;
  int n = count_tests();
  int count = 0;
  printf("1..%d\n", n);
  while (i++ < n) {
    count += test(i);
  }
  if (count != 0) {
    printf("  %d of %d tests unsuccessful\n", count, n);
  } else {
    printf("  all %d tests successful\n", n);
  }
  return count;
}


x86 assembly (clang, -O0):
<test_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <count_tests@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x4(%rbp)
cmp    -0x8(%rbp),%eax
jge    118f <test_all+0x5f>
mov    -0x4(%rbp),%edi
call   1050 <test@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1161 <test_all+0x31>
cmpl   $0x0,-0xc(%rbp)
je     11b2 <test_all+0x82>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <test_all+0x93>
mov    -0x8(%rbp),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_all>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <count_tests@plt>
mov    %eax,%r15d
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15d,%r15d
jle    11a8 <test_all+0x78>
mov    %r15d,%r12d
neg    %r12d
xor    %ebx,%ebx
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <test@plt>
add    %eax,%ebx
lea    (%r12,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1170 <test_all+0x40>
test   %ebx,%ebx
je     11a8 <test_all+0x78>
lea    0xe70(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%r14d
jmp    11b9 <test_all+0x89>
lea    0xe77(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"1..%d\0A\00"
@.str.1 = [31 x i8] c" %d of %d tests unsuccessful\0A\00"
@.str.2 = [27 x i8] c" all %d tests successful\0A\00"
define i32 @test_all() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @count_tests()
store i32 %4, i32* %2
store i32 0, i32* %3
%5 = load i32, i32* %2
%6 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %12, %0
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i32, i32* %1
%14 = call i64 @test(i32 %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, %14
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
br label %7
19: ; preds = %7
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24)
br label %29
26: ; preds = %19
%27 = load i32, i32* %2
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %22
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [7 x i8] c"1..%d\0A\00"
@.str.1 = [31 x i8] c" %d of %d tests unsuccessful\0A\00"
@.str.2 = [27 x i8] c" all %d tests successful\0A\00"
define i32 @test_all() {
%1 = tail call i32 (...) @count_tests()
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %16
4: ; preds = %0, %4
%5 = phi i32 [ %10, %4 ], [ 1, %0 ]
%6 = phi i32 [ %9, %4 ], [ 0, %0 ]
%7 = tail call i64 @test(i32 %5)
%8 = trunc i64 %7 to i32
%9 = add i32 %6, %8
%10 = add nuw i32 %5, 1
%11 = icmp eq i32 %5, %1
br i1 %11, label %12, label %4
12: ; preds = %4
%13 = icmp eq i32 %9, 0
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %1)
br label %18
16: ; preds = %0, %12
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ 0, %16 ], [ %9, %14 ]
ret i32 %19
}