#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 */
unsigned char ecc_calc(int);
int /*<<< orphan*/ err_msg(char *);
int ecc_calc_self_test(void) {
  int ret = 0;
  unsigned char ecc;
  ecc = ecc_calc(0x40096000);
  if (ecc != 0x77) {
    err_msg("self_test failed");
    ret++;
  }
  ecc = ecc_calc(0x3c080008);
  if (ecc != 0x49) {
    err_msg("self_test failed");
    ret++;
  }
  ecc = ecc_calc(0x01094024);
  if (ecc != 0x43) {
    err_msg("self_test failed");
    ret++;
  }
  ecc = ecc_calc(0x11000004);
  if (ecc != 0x5a) {
    err_msg("self_test failed");
    ret++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<ecc_calc_self_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x40096000,%edi
call   1030 <ecc_calc@plt>
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x77,%eax
je     115e <ecc_calc_self_test+0x3e>
lea    0xeb0(%rip),%rdi
call   1040 <err_msg@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x3c080008,%edi
call   1030 <ecc_calc@plt>
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x49,%eax
je     118d <ecc_calc_self_test+0x6d>
lea    0xe81(%rip),%rdi
call   1040 <err_msg@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x1094024,%edi
call   1030 <ecc_calc@plt>
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x43,%eax
je     11bc <ecc_calc_self_test+0x9c>
lea    0xe52(%rip),%rdi
call   1040 <err_msg@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x11000004,%edi
call   1030 <ecc_calc@plt>
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
je     11eb <ecc_calc_self_test+0xcb>
lea    0xe23(%rip),%rdi
call   1040 <err_msg@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecc_calc_self_test>:
push   %rbx
mov    $0x40096000,%edi
call   1030 <ecc_calc@plt>
xor    %ebx,%ebx
cmp    $0x77,%al
je     1142 <ecc_calc_self_test+0x22>
lea    0xec8(%rip),%rdi
call   1040 <err_msg@plt>
mov    $0x1,%ebx
mov    $0x3c080008,%edi
call   1030 <ecc_calc@plt>
cmp    $0x49,%al
je     115f <ecc_calc_self_test+0x3f>
lea    0xea9(%rip),%rdi
call   1040 <err_msg@plt>
add    $0x1,%ebx
mov    $0x1094024,%edi
call   1030 <ecc_calc@plt>
cmp    $0x43,%al
je     117c <ecc_calc_self_test+0x5c>
lea    0xe8c(%rip),%rdi
call   1040 <err_msg@plt>
add    $0x1,%ebx
mov    $0x11000004,%edi
call   1030 <ecc_calc@plt>
cmp    $0x5a,%al
je     1199 <ecc_calc_self_test+0x79>
lea    0xe6f(%rip),%rdi
call   1040 <err_msg@plt>
add    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"self_test failed\00"
define i32 @ecc_calc_self_test() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call zeroext i8 @ecc_calc(i32 1074356224)
store i8 %3, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
%6 = icmp ne i32 %5, 119
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 1
store i32 %10, i32* %1
br label %11
11: ; preds = %7, %0
%12 = call zeroext i8 @ecc_calc(i32 1007157256)
store i8 %12, i8* %2
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = icmp ne i32 %14, 73
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
store i32 %19, i32* %1
br label %20
20: ; preds = %16, %11
%21 = call zeroext i8 @ecc_calc(i32 17383460)
store i8 %21, i8* %2
%22 = load i8, i8* %2
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 67
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %1
br label %29
29: ; preds = %25, %20
%30 = call zeroext i8 @ecc_calc(i32 285212676)
store i8 %30, i8* %2
%31 = load i8, i8* %2
%32 = zext i8 %31 to i32
%33 = icmp ne i32 %32, 90
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %38
38: ; preds = %34, %29
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"self_test failed\00"
define i32 @ecc_calc_self_test() {
%1 = tail call zeroext i8 @ecc_calc(i32 1074356224)
%2 = icmp eq i8 %1, 119
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = phi i32 [ 1, %3 ], [ 0, %0 ]
%7 = tail call zeroext i8 @ecc_calc(i32 1007157256)
%8 = icmp eq i8 %7, 73
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = add nuw nsw i32 %6, 1
br label %12
12: ; preds = %9, %5
%13 = phi i32 [ %11, %9 ], [ %6, %5 ]
%14 = tail call zeroext i8 @ecc_calc(i32 17383460)
%15 = icmp eq i8 %14, 67
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%18 = add nuw nsw i32 %13, 1
br label %19
19: ; preds = %16, %12
%20 = phi i32 [ %18, %16 ], [ %13, %12 ]
%21 = tail call zeroext i8 @ecc_calc(i32 285212676)
%22 = icmp eq i8 %21, 90
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = tail call i32 @err_msg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%25 = add nuw nsw i32 %20, 1
br label %26
26: ; preds = %23, %19
%27 = phi i32 [ %25, %23 ], [ %20, %19 ]
ret i32 %27
}