#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(unsigned int *);
scalar_t__ malloc(unsigned int const);
int /*<<< orphan*/ muldwu1(unsigned int *, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write_data_as_json(int /*<<< orphan*/ *, unsigned int *,
                                      unsigned int *, unsigned int *,
                                      unsigned int const);
void generate(unsigned int *a, unsigned int *b, const unsigned int len,
              const char *name) {
  unsigned int i;
  unsigned int *y;
  FILE *f;
  y = (unsigned int *)malloc(len * sizeof(unsigned int) * 2);
  if (y == NULL) {
    printf("Error allocating memory.\n");
    exit(1);
  }
  for (i = 0; i < len; i++) {
    muldwu1(&y[i * 2], a[i], b[i]);
  }
  f = fopen(name, "w");
  if (f == NULL) {
    printf("Error opening file.\n");
    exit(1);
  }
  write_data_as_json(f, a, b, y, len);
  fclose(f);
  free(y);
}


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ce <generate+0x4e>
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    121b <generate+0x9b>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,%eax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
call   1090 <muldwu1@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d5 <generate+0x55>
mov    -0x20(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1250 <generate+0xd0>
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x14(%rbp),%r8d
call   1060 <write_data_as_json@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x0(,%r14,8),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     122a <generate+0xaa>
mov    %rax,%rbx
test   %r14d,%r14d
je     11e0 <generate+0x60>
mov    %r14d,%ebp
add    %rbp,%rbp
xor    %r13d,%r13d
nop
mov    %r13d,%eax
and    $0xfffffffe,%eax
lea    (%rbx,%rax,4),%rdi
mov    (%r12,%r13,2),%esi
mov    (%r15,%r13,2),%edx
call   1090 <muldwu1@plt>
add    $0x2,%r13
cmp    %r13,%rbp
jne    11c0 <generate+0x40>
lea    0xe19(%rip),%rsi
mov    (%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1233 <generate+0xb3>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1060 <write_data_as_json@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xde5(%rip),%rdi
jmp    123a <generate+0xba>
lea    0xdc8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Error allocating memory.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"Error opening file.\0A\00"
define void @generate(i32* %0, i32* %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = load i32, i32* %7
%13 = zext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = mul i64 %14, 2
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %10
%19 = load i32*, i32** %10
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %4
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %4
store i32 0, i32* %9
br label %25
25: ; preds = %46, %24
%26 = load i32, i32* %9
%27 = load i32, i32* %7
%28 = icmp ult i32 %26, %27
br i1 %28, label %29, label %49
29: ; preds = %25
%30 = load i32*, i32** %10
%31 = load i32, i32* %9
%32 = mul i32 %31, 2
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %30, i64 %33
%35 = load i32*, i32** %5
%36 = load i32, i32* %9
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = load i32*, i32** %6
%41 = load i32, i32* %9
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = call i32 @muldwu1(i32* %34, i32 %39, i32 %44)
br label %46
46: ; preds = %29
%47 = load i32, i32* %9
%48 = add i32 %47, 1
store i32 %48, i32* %9
br label %25
49: ; preds = %25
%50 = load i8*, i8** %8
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %51, i32** %11
%52 = load i32*, i32** %11
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %49
%58 = load i32*, i32** %11
%59 = load i32*, i32** %5
%60 = load i32*, i32** %6
%61 = load i32*, i32** %10
%62 = load i32, i32* %7
%63 = call i32 @write_data_as_json(i32* %58, i32* %59, i32* %60, i32* %61, i32 %62)
%64 = load i32*, i32** %11
%65 = call i32 @fclose(i32* %64)
%66 = load i32*, i32** %10
%67 = call i32 @free(i32* %66)
ret void
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@str = [20 x i8] c"Error opening file.\00"
@str.3 = [25 x i8] c"Error allocating memory.\00"
define void @generate(i32* %0, i32* %1, i32 %2, i8* nocapture %3) {
%5 = shl i32 %2, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32*
%8 = icmp eq i64 %6, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = icmp eq i32 %2, 0
br i1 %10, label %28, label %11
11: ; preds = %9
%12 = zext i32 %2 to i64
br label %16
13: ; preds = %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %11, %16
%17 = phi i64 [ 0, %11 ], [ %26, %16 ]
%18 = shl nuw i64 %17, 1
%19 = and i64 %18, 4294967294
%20 = getelementptr inbounds i32, i32* %7, i64 %19
%21 = getelementptr inbounds i32, i32* %0, i64 %17
%22 = load i32, i32* %21
%23 = getelementptr inbounds i32, i32* %1, i64 %17
%24 = load i32, i32* %23
%25 = tail call i32 @muldwu1(i32* %20, i32 %22, i32 %24)
%26 = add nuw nsw i64 %17, 1
%27 = icmp eq i64 %26, %12
br i1 %27, label %28, label %16
28: ; preds = %16, %9
%29 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %28
%35 = tail call i32 @write_data_as_json(i32* %29, i32* %0, i32* %1, i32* %7, i32 %2)
%36 = tail call i32 @fclose(i32* %29)
%37 = tail call i32 @free(i32* %7)
ret void
}