#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 */
scalar_t__ deleteMov();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ insertIndirectJump();
scalar_t__ insertJump();
scalar_t__ modifyAddressing(int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int failed = 0;
  if (deleteMov() != 0) {
    fprintf(stderr, "Mov instruction was not deleted\n");
    failed++;
  }
  if (insertJump() != 0) {
    fprintf(stderr, "Mov instruction was not branched over\n");
    failed++;
  }
  if (insertIndirectJump() != 0) {
    fprintf(stderr, "Mov instruction was not indirectly branched over\n");
    failed++;
  }
  if (modifyAddressing(1) != 0) {
    fprintf(stderr, "Addressing was not modified\n");
    failed++;
  }
  return failed;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <deleteMov@plt>
cmp    $0x0,%rax
je     119c <main+0x4c>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <insertJump@plt>
cmp    $0x0,%rax
je     11cb <main+0x7b>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <insertIndirectJump@plt>
cmp    $0x0,%rax
je     11fa <main+0xaa>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x1,%edi
call   1050 <modifyAddressing@plt>
cmp    $0x0,%rax
je     122c <main+0xdc>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <deleteMov@plt>
test   %rax,%rax
je     1179 <main+0x29>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%ebx
xor    %eax,%eax
call   1040 <insertJump@plt>
test   %rax,%rax
je     119d <main+0x4d>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1070 <fprintf@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1060 <insertIndirectJump@plt>
test   %rax,%rax
je     11c1 <main+0x71>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1070 <fprintf@plt>
add    $0x1,%ebx
mov    $0x1,%edi
call   1050 <modifyAddressing@plt>
test   %rax,%rax
je     11e8 <main+0x98>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
call   1070 <fprintf@plt>
add    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Mov instruction was not deleted\0A\00"
@.str.1 = [39 x i8] c"Mov instruction was not branched over\0A\00"
@.str.2 = [50 x i8] c"Mov instruction was not indirectly branched over\0A\00"
@.str.3 = [29 x i8] c"Addressing was not modified\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = call i64 (...) @deleteMov()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
br label %14
14: ; preds = %9, %2
%15 = call i64 (...) @insertJump()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %22
22: ; preds = %17, %14
%23 = call i64 (...) @insertIndirectJump()
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %30
30: ; preds = %25, %22
%31 = call i64 @modifyAddressing(i32 1)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %38
38: ; preds = %33, %30
%39 = load i32, i32* %6
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Mov instruction was not deleted\0A\00"
@.str.1 = [39 x i8] c"Mov instruction was not branched over\0A\00"
@.str.2 = [50 x i8] c"Mov instruction was not indirectly branched over\0A\00"
@.str.3 = [29 x i8] c"Addressing was not modified\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @deleteMov()
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = phi i32 [ 1, %5 ], [ 0, %2 ]
%10 = tail call i64 (...) @insertJump()
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%15 = add nuw nsw i32 %9, 1
br label %16
16: ; preds = %12, %8
%17 = phi i32 [ %15, %12 ], [ %9, %8 ]
%18 = tail call i64 (...) @insertIndirectJump()
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%23 = add nuw nsw i32 %17, 1
br label %24
24: ; preds = %20, %16
%25 = phi i32 [ %23, %20 ], [ %17, %16 ]
%26 = tail call i64 @modifyAddressing(i32 1)
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%31 = add nuw nsw i32 %25, 1
br label %32
32: ; preds = %28, %24
%33 = phi i32 [ %31, %28 ], [ %25, %24 ]
ret i32 %33
}