#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*/ ex1(double *, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printarray(double *, int);
int main(int argc, char *argv[]) {
  int n = atoi(argv[1]);
  double *A = (double *)malloc(2 * n * sizeof(double));
  for (int i = 0; i < 2 * n; i++) {
    A[i] = 0.0;
  }
  ex1(A, n);
  printarray(A, n);
  free(A);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11c3 <main+0x73>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <main+0x44>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <ex1@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <printarray@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
shl    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    119d <main+0x3d>
mov    %ebx,%eax
add    %ebx,%eax
cmp    $0x2,%eax
mov    $0x1,%edx
cmovge %eax,%edx
shl    $0x3,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <ex1@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <printarray@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = mul nsw i32 2, %13
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %7
store i32 0, i32* %8
br label %20
20: ; preds = %30, %2
%21 = load i32, i32* %8
%22 = load i32, i32* %6
%23 = mul nsw i32 2, %22
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load double*, double** %7
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
store double 0.000000e+00, double* %29
br label %30
30: ; preds = %25
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %20
33: ; preds = %20
%34 = load double*, double** %7
%35 = load i32, i32* %6
%36 = call i32 @ex1(double* %34, i32 %35)
%37 = load double*, double** %7
%38 = load i32, i32* %6
%39 = call i32 @printarray(double* %37, i32 %38)
%40 = load double*, double** %7
%41 = call i32 @free(double* %40)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = shl i32 %5, 4
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to double*
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = inttoptr i64 %7 to i8*
%12 = shl nuw i32 %5, 1
%13 = call i32 @llvm.smax.i32(i32 %12, i32 1)
%14 = zext i32 %13 to i64
%15 = shl nuw nsw i64 %14, 3
br label %16
16: ; preds = %10, %2
%17 = tail call i32 @ex1(double* %8, i32 %5)
%18 = tail call i32 @printarray(double* %8, i32 %5)
%19 = tail call i32 @free(double* %8)
ret i32 0
}