#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
scalar_t__ gdev_test_matrixadd(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int ret;
  int n;
  uint32_t *a, *b, *c;
  if (argc != 2) {
    printf("Invalid arguments\n");
    return 0;
  }
  n = atoi(argv[1]);
  a = malloc(n * n * sizeof(uint32_t));
  b = malloc(n * n * sizeof(uint32_t));
  c = malloc(n * n * sizeof(uint32_t));
  if (gdev_test_matrixadd(a, b, c, n))
    printf("Test failed.\n");
  else
    printf("Test passed.\n");
end:
  free(a);
  free(b);
  free(c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1242 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1050 <gdev_test_matrixadd@plt>
cmp    $0x0,%rax
je     120f <main+0xbf>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
jmp    121b <main+0xcb>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
jmp    1220 <main+0xd0>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11d1 <main+0x81>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%ebp
imul   %eax,%ebp
shl    $0x2,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %ebx,%ecx
call   1050 <gdev_test_matrixadd@plt>
test   %rax,%rax
lea    0xe59(%rip),%rax
lea    0xe5f(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    11dd <main+0x8d>
lea    0xe42(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Invalid arguments\0A\00"
@.str.1 = [14 x i8] c"Test failed.\0A\00"
@.str.2 = [14 x i8] c"Test passed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %59
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32, i32* %7
%22 = mul nsw i32 %20, %21
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = trunc i64 %24 to i32
%26 = call i32* @malloc(i32 %25)
store i32* %26, i32** %8
%27 = load i32, i32* %7
%28 = load i32, i32* %7
%29 = mul nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 4
%32 = trunc i64 %31 to i32
%33 = call i32* @malloc(i32 %32)
store i32* %33, i32** %9
%34 = load i32, i32* %7
%35 = load i32, i32* %7
%36 = mul nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = trunc i64 %38 to i32
%40 = call i32* @malloc(i32 %39)
store i32* %40, i32** %10
%41 = load i32*, i32** %8
%42 = load i32*, i32** %9
%43 = load i32*, i32** %10
%44 = load i32, i32* %7
%45 = call i64 @gdev_test_matrixadd(i32* %41, i32* %42, i32* %43, i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %15
%48 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %51
49: ; preds = %15
%50 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
br label %52
52: ; preds = %51
%53 = load i32*, i32** %8
%54 = call i32 @free(i32* %53)
%55 = load i32*, i32** %9
%56 = call i32 @free(i32* %55)
%57 = load i32*, i32** %10
%58 = call i32 @free(i32* %57)
store i32 0, i32* %3
br label %59
59: ; preds = %52, %13
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@str = [13 x i8] c"Test passed.\00"
@str.3 = [13 x i8] c"Test failed.\00"
@str.4 = [18 x i8] c"Invalid arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %22
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = shl i32 %9, 2
%11 = mul i32 %10, %9
%12 = tail call i32* @malloc(i32 %11)
%13 = tail call i32* @malloc(i32 %11)
%14 = tail call i32* @malloc(i32 %11)
%15 = tail call i64 @gdev_test_matrixadd(i32* %12, i32* %13, i32* %14, i32 %9)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
%19 = tail call i32 @free(i32* %12)
%20 = tail call i32 @free(i32* %13)
%21 = tail call i32 @free(i32* %14)
br label %22
22: ; preds = %6, %4
ret i32 0
}