#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 */
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test_convergence_1d(int *, int, int);
int /*<<< orphan*/ test_convergence_2d(int *, int *, int *, int, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("%s ORDER_1D\n", argv[0]);
    return 1;
  }
  int order_1d = atoi(argv[1]);
  printf("Beginning convergence test\n");
  printf("Interpolating:\n\tsin(kx*x)*cos(ky*y)\non domain:\n\t[-pi, pi]^2\n");
  int nx[4] = {11, 21, 41, 81};
  int ny[4] = {9, 17, 33, 81};
  int order[3] = {2, 4, 6};
  int kx = 5;
  int ky = 3;
  test_convergence_1d(nx, kx, order_1d);
  test_convergence_2d(nx, ny, order, kx, ky);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1181 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1229 <main+0xe9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xebc(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x4c(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x44(%rbp)
movl   $0x5,-0x50(%rbp)
movl   $0x3,-0x54(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <test_convergence_1d@plt>
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
call   1060 <test_convergence_2d@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jg     1176 <main+0x26>
mov    (%rsi),%rsi
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    11f7 <main+0xa7>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0xee1(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xece(%rip),%rax
mov    %rax,(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %ebp,%edx
call   1040 <test_convergence_1d@plt>
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    $0x5,%ecx
mov    $0x3,%r8d
call   1070 <test_convergence_2d@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s ORDER_1D\0A\00"
@.str.1 = [28 x i8] c"Beginning convergence test\0A\00"
@.str.2 = [61 x i8] c"Interpolating:\0A\09sin(kx*x)*cos(ky*y)\0Aon domain:\0A\09[-pi, pi]^2\0A\00"
@__const.main.nx = [4 x i32] [i32 11, i32 21, i32 41, i32 81]
@__const.main.ny = [4 x i32] [i32 9, i32 17, i32 33, i32 81]
@__const.main.order = [3 x i32] [i32 2, i32 4, i32 6]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i32]
%8 = alloca [4 x i32]
%9 = alloca [3 x i32]
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %39
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%26 = bitcast [4 x i32]* %7 to i8*
%27 = bitcast [4 x i32]* %8 to i8*
%28 = bitcast [3 x i32]* %9 to i8*
store i32 5, i32* %10
store i32 3, i32* %11
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%30 = load i32, i32* %10
%31 = load i32, i32* %6
%32 = call i32 @test_convergence_1d(i32* %29, i32 %30, i32 %31)
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 0
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = call i32 @test_convergence_2d(i32* %33, i32* %34, i32* %35, i32 %36, i32 %37)
store i32 0, i32* %3
br label %39
39: ; preds = %19, %14
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s ORDER_1D\0A\00"
@__const.main.nx = [4 x i32] [i32 11, i32 21, i32 41, i32 81]
@__const.main.ny = [4 x i32] [i32 9, i32 17, i32 33, i32 81]
@__const.main.order = [3 x i32] [i32 2, i32 4, i32 6]
@str = [27 x i8] c"Beginning convergence test\00"
@str.3 = [60 x i8] c"Interpolating:\0A\09sin(kx*x)*cos(ky*y)\0Aon domain:\0A\09[-pi, pi]^2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = alloca [4 x i32]
%5 = alloca [3 x i32]
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %24
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.3, i64 0, i64 0))
%16 = bitcast [4 x i32]* %3 to i8*
%17 = bitcast [4 x i32]* %4 to i8*
%18 = bitcast [3 x i32]* %5 to i8*
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%20 = call i32 @test_convergence_1d(i32* %19, i32 5, i32 %13)
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%23 = call i32 @test_convergence_2d(i32* %19, i32* %21, i32* %22, i32 5, i32 3)
br label %24
24: ; preds = %10, %7
%25 = phi i32 [ 1, %7 ], [ 0, %10 ]
ret i32 %25
}