#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
int strlen(char *);
int do_test(const char *description, int value, int expected, int negate,
            int fatal) {
  int num_chars;
  num_chars = printf("%s", description);
  for (; num_chars < 60 - strlen("passed"); num_chars++)
    putchar('.');
  fflush(stdout);
  if (!negate) {
    if (value == expected) {
      printf("passed\n");
      return 0;
    } else {
      printf("failed\n");
      if (fatal)
        exit(EXIT_FAILURE);
    }
  } else {
    if (value != expected) {
      printf("passed\n");
      return 0;
    } else {
      printf("failed\n");
      if (fatal)
        exit(EXIT_FAILURE);
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    0xe78(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%eax
mov    $0x3c,%ecx
sub    %edx,%ecx
cmp    %ecx,%eax
jge    11bc <do_test+0x6c>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117e <do_test+0x2e>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    122a <do_test+0xda>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11fa <do_test+0xaa>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1287 <do_test+0x137>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
je     1220 <do_test+0xd0>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1225 <do_test+0xd5>
jmp    1280 <do_test+0x130>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1250 <do_test+0x100>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1287 <do_test+0x137>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
je     1276 <do_test+0x126>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    127b <do_test+0x12b>
jmp    1280 <do_test+0x130>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rsi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %eax,%ebx
lea    0xe79(%rip),%rdi
call   1050 <strlen@plt>
mov    $0x3c,%ecx
sub    %eax,%ecx
cmp    %ecx,%ebx
jge    11d0 <do_test+0x70>
lea    0xe62(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    $0x3c,%ecx
sub    %eax,%ecx
cmp    %ecx,%ebx
jl     11b0 <do_test+0x50>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
test   %r13d,%r13d
je     120c <do_test+0xac>
cmp    %r15d,%r12d
jne    1211 <do_test+0xb1>
lea    0xe14(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
test   %r14d,%r14d
je     121f <do_test+0xbf>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmp    %r15d,%r12d
jne    11e8 <do_test+0x88>
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"passed\00"
@stdout = global i32 0
@.str.2 = [8 x i8] c"passed\0A\00"
@.str.3 = [8 x i8] c"failed\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @do_test(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%13 = load i8*, i8** %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 %14, i32* %12
br label %15
15: ; preds = %22, %5
%16 = load i32, i32* %12
%17 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = sub nsw i32 60, %17
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = call i32 @putchar(i8 signext 46)
br label %22
22: ; preds = %20
%23 = load i32, i32* %12
%24 = add nsw i32 %23, 1
store i32 %24, i32* %12
br label %15
25: ; preds = %15
%26 = load i32, i32* @stdout
%27 = call i32 @fflush(i32 %26)
%28 = load i32, i32* %10
%29 = icmp ne i32 %28, 0
br i1 %29, label %45, label %30
30: ; preds = %25
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %61
36: ; preds = %30
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%38 = load i32, i32* %11
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %36
br label %44
44: ; preds = %43
br label %60
45: ; preds = %25
%46 = load i32, i32* %8
%47 = load i32, i32* %9
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %61
51: ; preds = %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32, i32* %11
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %51
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59, %44
store i32 1, i32* %6
br label %61
61: ; preds = %60, %49, %34
%62 = load i32, i32* %6
ret i32 %62
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdout = global i32 0
@EXIT_FAILURE = global i32 0
@str.5 = [7 x i8] c"failed\00"
@str.6 = [7 x i8] c"passed\00"
define i32 @do_test(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.6, i64 0, i64 0))
%8 = sub nsw i32 60, %7
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %17
10: ; preds = %5, %10
%11 = phi i32 [ %13, %10 ], [ %6, %5 ]
%12 = tail call i32 @putchar(i8 signext 46)
%13 = add nsw i32 %11, 1
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.6, i64 0, i64 0))
%15 = sub nsw i32 60, %14
%16 = icmp slt i32 %13, %15
br i1 %16, label %10, label %17
17: ; preds = %10, %5
%18 = load i32, i32* @stdout
%19 = tail call i32 @fflush(i32 %18)
%20 = icmp eq i32 %3, 0
%21 = icmp eq i32 %1, %2
br i1 %20, label %22, label %29
22: ; preds = %17
br i1 %21, label %36, label %23
23: ; preds = %22
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
%25 = icmp eq i32 %4, 0
br i1 %25, label %39, label %26
26: ; preds = %23
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %17
br i1 %21, label %30, label %36
30: ; preds = %29
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
%32 = icmp eq i32 %4, 0
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %29, %22
%37 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.6, i64 0, i64 0), %22 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.6, i64 0, i64 0), %29 ]
%38 = tail call i32 @puts(i8* dereferenceable(1) %37)
br label %39
39: ; preds = %36, %23, %30
%40 = phi i32 [ 1, %30 ], [ 1, %23 ], [ 0, %36 ]
ret i32 %40
}