#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int finished(const char *cmd, int status) {
  if (!strcmp(cmd, "not"))
    return !status;
  if (!strcmp(cmd, "should")) {
    if (status)
      fprintf(stderr, "TEST WARNING: Ignoring command failure.\n");
    return 0;
  } else if (!strcmp(cmd, "invalid")) {
    if (status == 3)
      return 0;
    fprintf(stderr, "Test expected exit code 3 (invalid), but got %d.\n",
            status);
  } else if (!strcmp(cmd, "fail")) {
    if (status == 5)
      return 0;
    fprintf(stderr, "Test expected exit code 5 (fail), but got %d.\n", status);
  }
  return 6;
}


x86 assembly (clang, -O0):
<finished>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    115e <finished+0x3e>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    124c <finished+0x12c>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11a4 <finished+0x84>
cmpl   $0x0,-0x14(%rbp)
je     1198 <finished+0x78>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124c <finished+0x12c>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f2 <finished+0xd2>
cmpl   $0x3,-0x14(%rbp)
jne    11d3 <finished+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    124c <finished+0x12c>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1240 <finished+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    123b <finished+0x11b>
cmpl   $0x5,-0x14(%rbp)
jne    1221 <finished+0x101>
movl   $0x0,-0x4(%rbp)
jmp    124c <finished+0x12c>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1240 <finished+0x120>
jmp    1245 <finished+0x125>
movl   $0x6,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finished>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0xed1(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     118f <finished+0x6f>
lea    0xec5(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1199 <finished+0x79>
lea    0xee2(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b8 <finished+0x98>
lea    0xf09(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
mov    $0x6,%ebp
test   %eax,%eax
jne    11e1 <finished+0xc1>
xor    %ebp,%ebp
cmp    $0x5,%ebx
je     11e1 <finished+0xc1>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xee6(%rip),%rsi
jmp    11cf <finished+0xaf>
xor    %ebp,%ebp
test   %ebx,%ebx
sete   %bpl
jmp    11e1 <finished+0xc1>
test   %ebx,%ebx
je     11df <finished+0xbf>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11e1 <finished+0xc1>
xor    %ebp,%ebp
cmp    $0x3,%ebx
je     11e1 <finished+0xc1>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x6,%ebp
jmp    11e1 <finished+0xc1>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"not\00"
@.str.1 = [7 x i8] c"should\00"
@stderr = global i32 0
@.str.2 = [41 x i8] c"TEST WARNING: Ignoring command failure.\0A\00"
@.str.3 = [8 x i8] c"invalid\00"
@.str.4 = [50 x i8] c"Test expected exit code 3 (invalid), but got %d.\0A\00"
@.str.5 = [5 x i8] c"fail\00"
@.str.6 = [47 x i8] c"Test expected exit code 5 (fail), but got %d.\0A\00"
define i32 @finished(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
store i32 %13, i32* %3
br label %52
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %14
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
store i32 0, i32* %3
br label %52
25: ; preds = %14
%26 = load i8*, i8** %4
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %25
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 0, i32* %3
br label %52
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i32, i32* %5
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %35)
br label %50
37: ; preds = %25
%38 = load i8*, i8** %4
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %49, label %41
41: ; preds = %37
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 5
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 0, i32* %3
br label %52
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = load i32, i32* %5
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %45, %37
br label %50
50: ; preds = %49, %33
br label %51
51: ; preds = %50
store i32 6, i32* %3
br label %52
52: ; preds = %51, %44, %32, %24, %9
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [4 x i8] c"not\00"
@.str.1 = [7 x i8] c"should\00"
@stderr = global i32 0
@.str.2 = [41 x i8] c"TEST WARNING: Ignoring command failure.\0A\00"
@.str.3 = [8 x i8] c"invalid\00"
@.str.4 = [50 x i8] c"Test expected exit code 3 (invalid), but got %d.\0A\00"
@.str.5 = [5 x i8] c"fail\00"
@.str.6 = [47 x i8] c"Test expected exit code 5 (fail), but got %d.\0A\00"
define i32 @finished(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = icmp eq i32 %1, 0
%7 = zext i1 %6 to i32
br label %32
8: ; preds = %2
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = icmp eq i32 %1, 0
br i1 %12, label %32, label %13
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
br label %32
16: ; preds = %8
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = icmp eq i32 %1, 3
br i1 %20, label %32, label %21
21: ; preds = %19
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %32
24: ; preds = %16
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = icmp eq i32 %1, 5
br i1 %28, label %32, label %29
29: ; preds = %27
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %1)
br label %32
32: ; preds = %24, %29, %21, %27, %19, %11, %13, %5
%33 = phi i32 [ %7, %5 ], [ 0, %13 ], [ 0, %11 ], [ 0, %19 ], [ 0, %27 ], [ 6, %21 ], [ 6, %29 ], [ 6, %24 ]
ret i32 %33
}