#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__ copyAndTest(int *, int *, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int testMovsd() {
  enum { length = 121 };
  int *s1 = (int *)malloc(length * sizeof(int));
  int *d1 = (int *)malloc((length + 2) * sizeof(int));
  int df;
  int failures = 0;
  for (df = 0; df < 2; df++) {
    failures += copyAndTest(d1, s1, length, df);
  }
  printf("%d failures in testMovsd\n", failures);
  return failures;
}


x86 assembly (clang, -O0):
<testMovsd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1e4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x1ec,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    119c <testMovsd+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0x79,%edx
call   1040 <copyAndTest@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <testMovsd+0x32>
mov    -0x18(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testMovsd>:
push   %r15
push   %r14
push   %rbx
mov    $0x1e4,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x1ec,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x79,%edx
xor    %ecx,%ecx
call   1040 <copyAndTest@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x79,%edx
mov    $0x1,%ecx
call   1040 <copyAndTest@plt>
mov    %rax,%rbx
add    %r15d,%ebx
lea    0xe7a(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"%d failures in testMovsd\0A\00"
define i32 @testMovsd() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = call i64 @malloc(i32 484)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %1
%7 = call i64 @malloc(i32 492)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32*, i32** %2
%14 = load i32*, i32** %1
%15 = load i32, i32* %3
%16 = call i64 @copyAndTest(i32* %13, i32* %14, i32 121, i32 %15)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %4
br label %21
21: ; preds = %12
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %9
24: ; preds = %9
%25 = load i32, i32* %4
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [26 x i8] c"%d failures in testMovsd\0A\00"
define i32 @testMovsd() {
%1 = tail call i64 @malloc(i32 484)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i64 @malloc(i32 492)
%4 = inttoptr i64 %3 to i32*
%5 = tail call i64 @copyAndTest(i32* %4, i32* %2, i32 121, i32 0)
%6 = trunc i64 %5 to i32
%7 = tail call i64 @copyAndTest(i32* %4, i32* %2, i32 121, i32 1)
%8 = trunc i64 %7 to i32
%9 = add i32 %6, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 %9
}