#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*/ getchar();
scalar_t__ printf(char *);
int replaced_byte(int, int, int);
int main(void) {
  int assert_result;
  assert_result = 0x12AB5678;
  !(assert_result ^ replaced_byte(0x12345678, 0xAB, 2)) &&
      (printf("First example test successful!\n"));
  assert_result = 0x123456AB;
  !(assert_result ^ replaced_byte(0x12345678, 0xAB, 0)) &&
      (printf("Second example test successful!\n"));
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x12ab5678,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x12345678,%edi
mov    $0xab,%esi
mov    $0x2,%edx
call   1050 <replaced_byte@plt>
mov    -0x10(%rbp),%ecx
xor    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
jne    1189 <main+0x59>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
movl   $0x123456ab,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x12345678,%edi
mov    $0xab,%esi
xor    %edx,%edx
call   1050 <replaced_byte@plt>
mov    -0x18(%rbp),%ecx
xor    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    11d3 <main+0xa3>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x12345678,%edi
mov    $0xab,%esi
mov    $0x2,%edx
call   1050 <replaced_byte@plt>
cmp    $0x12ab5678,%eax
jne    1158 <main+0x28>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    $0x12345678,%edi
mov    $0xab,%esi
xor    %edx,%edx
call   1050 <replaced_byte@plt>
cmp    $0x123456ab,%eax
jne    117c <main+0x4c>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"First example test successful!\0A\00"
@.str.1 = [33 x i8] c"Second example test successful!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 313218680, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @replaced_byte(i32 305419896, i32 171, i32 2)
%5 = xor i32 %3, %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i64 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br label %10
10: ; preds = %7, %0
%11 = phi i1 [ false, %0 ], [ %9, %7 ]
%12 = zext i1 %11 to i32
store i32 305419947, i32* %2
%13 = load i32, i32* %2
%14 = call i32 @replaced_byte(i32 305419896, i32 171, i32 0)
%15 = xor i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %10
%18 = call i64 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br label %20
20: ; preds = %17, %10
%21 = phi i1 [ false, %10 ], [ %19, %17 ]
%22 = zext i1 %21 to i32
%23 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@str = [31 x i8] c"First example test successful!\00"
@str.2 = [32 x i8] c"Second example test successful!\00"
define i32 @main() {
%1 = tail call i32 @replaced_byte(i32 305419896, i32 171, i32 2)
%2 = icmp eq i32 %1, 313218680
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @replaced_byte(i32 305419896, i32 171, i32 0)
%7 = icmp eq i32 %6, 305419947
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = tail call i32 (...) @getchar()
ret i32 0
}