#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__ calloc(int, int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int main() {
  int *pm;
  pm = (int *)malloc(5 * 8);
  int *pc;
  pc = (int *)calloc(5, 8);
  int i;
  for (i = 0; i < 5; i++) {
    *(pm + i) = i;
    *(pc + i) = i;
  }
  for (i = 0; i < 5; i++) {
    if (*(pm + i) != *(pc + i)) {
      return -1;
    }
  }
  free(pc);
  free(pm);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x5,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    119b <main+0x6b>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <main+0x37>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    11e7 <main+0xb7>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
je     11d4 <main+0xa4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <main+0xd0>
jmp    11d9 <main+0xa9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <main+0x72>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x5,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rdi
movl   $0x0,(%rbx)
movl   $0x0,(%rax)
movl   $0x1,0x4(%rbx)
movl   $0x1,0x4(%rax)
movl   $0x2,0x8(%rbx)
movl   $0x2,0x8(%rax)
movl   $0x3,0xc(%rbx)
movl   $0x3,0xc(%rax)
movl   $0x4,0x10(%rbx)
movl   $0x4,0x10(%rax)
mov    (%rbx),%ecx
mov    $0xffffffff,%eax
cmp    (%rdi),%ecx
jne    11cc <main+0x9c>
mov    0x4(%rbx),%ecx
cmp    0x4(%rdi),%ecx
jne    11cc <main+0x9c>
mov    0x8(%rbx),%ecx
cmp    0x8(%rdi),%ecx
jne    11cc <main+0x9c>
mov    0xc(%rbx),%ecx
cmp    0xc(%rdi),%ecx
jne    11cc <main+0x9c>
cmpl   $0x4,0x10(%rbx)
jne    11cc <main+0x9c>
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %2
%7 = call i64 @calloc(i32 5, i32 8)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %3
store i32 0, i32* %4
br label %9
9: ; preds = %23, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32*, i32** %2
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 %13, i32* %17
%18 = load i32, i32* %4
%19 = load i32*, i32** %3
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %9
26: ; preds = %9
store i32 0, i32* %4
br label %27
27: ; preds = %44, %26
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 5
br i1 %29, label %30, label %47
30: ; preds = %27
%31 = load i32*, i32** %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %3
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = icmp ne i32 %35, %40
br i1 %41, label %42, label %43
42: ; preds = %30
store i32 -1, i32* %1
br label %52
43: ; preds = %30
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %27
47: ; preds = %27
%48 = load i32*, i32** %3
%49 = call i32 @free(i32* %48)
%50 = load i32*, i32** %2
%51 = call i32 @free(i32* %50)
store i32 0, i32* %1
br label %52
52: ; preds = %47, %42
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 40)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i64 @calloc(i32 5, i32 8)
%4 = inttoptr i64 %3 to i32*
store i32 0, i32* %2
store i32 0, i32* %4
%5 = getelementptr inbounds i32, i32* %2, i64 1
store i32 1, i32* %5
%6 = getelementptr inbounds i32, i32* %4, i64 1
store i32 1, i32* %6
%7 = getelementptr inbounds i32, i32* %2, i64 2
store i32 2, i32* %7
%8 = getelementptr inbounds i32, i32* %4, i64 2
store i32 2, i32* %8
%9 = getelementptr inbounds i32, i32* %2, i64 3
store i32 3, i32* %9
%10 = getelementptr inbounds i32, i32* %4, i64 3
store i32 3, i32* %10
%11 = getelementptr inbounds i32, i32* %2, i64 4
store i32 4, i32* %11
%12 = getelementptr inbounds i32, i32* %4, i64 4
store i32 4, i32* %12
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %0
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i32, i32* %11
%30 = icmp eq i32 %29, 4
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = tail call i32 @free(i32* %4)
%33 = tail call i32 @free(i32* %2)
br label %34
34: ; preds = %0, %16, %20, %24, %28, %31
%35 = phi i32 [ 0, %31 ], [ -1, %28 ], [ -1, %24 ], [ -1, %20 ], [ -1, %16 ], [ -1, %0 ]
ret i32 %35
}