#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ line(int, char *, int);
scalar_t__ malloc(int);
void printLine(int nums[], int elements, FILE *fp) {
  for (int i = 0; i < 8; i++) {
    char *lineString = (char *)malloc(sizeof(char) * 8 * elements + 1);
    lineString[8 * elements] = '\0';
    for (int j = 0; j < elements; j++) {
      line(nums[i + j * 8], lineString, 8 * j);
    }
    fprintf(fp, "%s\n", lineString);
    free(lineString);
  }
}


x86 assembly (clang, -O0):
<printLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11fc <printLine+0xbc>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d1 <printLine+0x91>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    -0x2c(%rbp),%edx
shl    $0x3,%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
shl    $0x3,%edx
call   1060 <line@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1193 <printLine+0x53>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <printLine+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0x0(,%r15,8),%eax
lea    0x1(,%r15,8),%ecx
mov    %ecx,0x4(%rsp)
cltq
mov    %rax,0x8(%rsp)
mov    %esi,%r13d
shl    $0x3,%r13
xor    %r14d,%r14d
jmp    11aa <printLine+0x6a>
mov    0x10(%rsp),%rdi
lea    0xe74(%rip),%rsi
mov    %rbp,%rdx
call   1040 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
add    $0x1,%r14
add    $0x4,%rbx
cmp    $0x8,%r14
je     11ea <printLine+0xaa>
mov    0x4(%rsp),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rax
movb   $0x0,0x0(%rbp,%rax,1)
test   %r15d,%r15d
jle    1180 <printLine+0x40>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r12,4),%edi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1060 <line@plt>
add    $0x8,%r12
cmp    %r12,%r13
jne    11d0 <printLine+0x90>
jmp    1180 <printLine+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @printLine(i32* nocapture %0, i32 %1, i32* nocapture %2) {
%4 = shl i32 %1, 3
%5 = or i32 %4, 1
%6 = sext i32 %4 to i64
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %1 to i64
br label %10
9: ; preds = %15
ret void
10: ; preds = %3, %15
%11 = phi i64 [ 0, %3 ], [ %18, %15 ]
%12 = tail call i64 @malloc(i32 %5)
%13 = inttoptr i64 %12 to i8*
%14 = getelementptr inbounds i8, i8* %13, i64 %6
store i8 0, i8* %14
br i1 %7, label %20, label %15
15: ; preds = %20, %10
%16 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
%17 = tail call i32 @free(i8* %13)
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, 8
br i1 %19, label %9, label %10
20: ; preds = %10, %20
%21 = phi i64 [ %28, %20 ], [ 0, %10 ]
%22 = shl nsw i64 %21, 3
%23 = add nuw nsw i64 %22, %11
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = trunc i64 %22 to i32
%27 = tail call i32 @line(i32 %25, i8* %13, i32 %26)
%28 = add nuw nsw i64 %21, 1
%29 = icmp eq i64 %28, %8
br i1 %29, label %15, label %20
}