#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__ doCmpsTests(int /*<<< orphan*/);
scalar_t__ doTest();
int /*<<< orphan*/ printf(char *);
scalar_t__ testMovsd();
int main(int argc, char **argv) {
  int failures = 0;
  printf("Simple tests\n");
  failures += doTest();
  printf("movsd tests\n");
  failures += testMovsd();
  printf("\n\ncmps tests\n");
  failures += doCmpsTests(0);
  return failures;
}


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)
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <doTest@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <testMovsd@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
lea    0xe77(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1040 <doCmpsTests@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <doTest@plt>
mov    %rax,%r14
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <testMovsd@plt>
mov    %rax,%rbx
add    %r14d,%ebx
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <doCmpsTests@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Simple tests\0A\00"
@.str.1 = [13 x i8] c"movsd tests\0A\00"
@.str.2 = [14 x i8] c"\0A\0Acmps tests\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 i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i64 (...) @doTest()
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %8
%12 = trunc i64 %11 to i32
store i32 %12, i32* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%14 = call i64 (...) @testMovsd()
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, %14
%18 = trunc i64 %17 to i32
store i32 %18, i32* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%20 = call i64 @doCmpsTests(i32 0)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = add nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %6
%25 = load i32, i32* %6
ret i32 %25
}

LLVM IR (-O2):
@str = [13 x i8] c"Simple tests\00"
@str.3 = [12 x i8] c"movsd tests\00"
@str.4 = [13 x i8] c"\0A\0Acmps tests\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = tail call i64 (...) @doTest()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i64 (...) @testMovsd()
%7 = add i64 %6, %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%9 = tail call i64 @doCmpsTests(i32 0)
%10 = add i64 %7, %9
%11 = trunc i64 %10 to i32
ret i32 %11
}