#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*/ FLine(int /*<<< orphan*/ *);
int /*<<< orphan*/ FLineSpace(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintfStr(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ getc(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printfStr(char *, int, int);
int /*<<< orphan*/ scale(int /*<<< orphan*/ *, char *, int, int);
int strtoi(int /*<<< orphan*/);
int main(void) {
  FILE *file = fopen("cowsignal.in", "r");
  FILE *fWrite = fopen("cowsignal.out", "w");
  int height = strtoi(FLineSpace(file));
  printf("Height: %d\n", height);
  int len = strtoi(FLineSpace(file));
  printf("Length: %d\n", len);
  int scl = strtoi(FLine(file));
  printf("Factor: %d\n", scl);
  char *line = malloc(sizeof(char) * scl * len);
  int lns;
  for (lns = 0; lns < height; lns++) {
    scale(file, line, len, scl);
    printf("Line: %s\n\n", line);
    printfStr(line, scl * len, scl);
    fprintfStr(fWrite, line, scl * len, scl);
    getc(file);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe4a(%rip),%rdi
lea    0xe50(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe42(%rip),%rdi
lea    0xe49(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <FLineSpace@plt>
mov    %eax,%edi
call   1040 <strtoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <FLineSpace@plt>
mov    %eax,%edi
call   1040 <strtoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <FLine@plt>
mov    %eax,%edi
call   1040 <strtoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12dd <main+0x13d>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1090 <scale@plt>
mov    -0x30(%rbp),%rsi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
imul   -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <printfStr@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
imul   -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1080 <fprintfStr@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <getc@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126b <main+0xcb>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe4e(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
lea    0xe47(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,(%rsp)
mov    %r12,%rdi
call   10b0 <FLineSpace@plt>
mov    %eax,%edi
call   1040 <strtoi@plt>
mov    %eax,%ebp
lea    0xe2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
call   10b0 <FLineSpace@plt>
mov    %eax,%edi
call   1040 <strtoi@plt>
mov    %eax,%r15d
lea    0xe19(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
call   1060 <FLine@plt>
mov    %eax,%edi
call   1040 <strtoi@plt>
mov    %eax,%ebx
lea    0xe04(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%r13d
imul   %r15d,%r13d
mov    %r13d,%edi
call   1070 <malloc@plt>
test   %ebp,%ebp
jle    12ac <main+0x10c>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
mov    %ebx,%ecx
call   1090 <scale@plt>
lea    0xdcc(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1050 <printfStr@plt>
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1080 <fprintfStr@plt>
mov    %r12,%rdi
call   10c0 <getc@plt>
add    $0xffffffff,%ebp
jne    1260 <main+0xc0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"cowsignal.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"cowsignal.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [12 x i8] c"Height: %d\0A\00"
@.str.5 = [12 x i8] c"Length: %d\0A\00"
@.str.6 = [12 x i8] c"Factor: %d\0A\00"
@.str.7 = [11 x i8] c"Line: %s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %2
%12 = call i32 @FLineSpace(i32* %11)
%13 = call i32 @strtoi(i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %2
%17 = call i32 @FLineSpace(i32* %16)
%18 = call i32 @strtoi(i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %2
%22 = call i32 @FLine(i32* %21)
%23 = call i32 @strtoi(i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = mul i64 1, %27
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = mul i64 %28, %30
%32 = trunc i64 %31 to i32
%33 = call i8* @malloc(i32 %32)
store i8* %33, i8** %7
store i32 0, i32* %8
br label %34
34: ; preds = %61, %0
%35 = load i32, i32* %8
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %64
38: ; preds = %34
%39 = load i32*, i32** %2
%40 = load i8*, i8** %7
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = call i32 @scale(i32* %39, i8* %40, i32 %41, i32 %42)
%44 = load i8*, i8** %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %7
%47 = load i32, i32* %6
%48 = load i32, i32* %5
%49 = mul nsw i32 %47, %48
%50 = load i32, i32* %6
%51 = call i32 @printfStr(i8* %46, i32 %49, i32 %50)
%52 = load i32*, i32** %3
%53 = load i8*, i8** %7
%54 = load i32, i32* %6
%55 = load i32, i32* %5
%56 = mul nsw i32 %54, %55
%57 = load i32, i32* %6
%58 = call i32 @fprintfStr(i32* %52, i8* %53, i32 %56, i32 %57)
%59 = load i32*, i32** %2
%60 = call i32 @getc(i32* %59)
br label %61
61: ; preds = %38
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %34
64: ; preds = %34
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str = [13 x i8] c"cowsignal.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"cowsignal.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [12 x i8] c"Height: %d\0A\00"
@.str.5 = [12 x i8] c"Length: %d\0A\00"
@.str.6 = [12 x i8] c"Factor: %d\0A\00"
@.str.7 = [11 x i8] c"Line: %s\0A\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call i32 @FLineSpace(i32* %1)
%4 = tail call i32 @strtoi(i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %4)
%6 = tail call i32 @FLineSpace(i32* %1)
%7 = tail call i32 @strtoi(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %7)
%9 = tail call i32 @FLine(i32* %1)
%10 = tail call i32 @strtoi(i32 %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %10)
%12 = mul i32 %10, %7
%13 = tail call i8* @malloc(i32 %12)
%14 = icmp sgt i32 %4, 0
br i1 %14, label %15, label %24
15: ; preds = %0, %15
%16 = phi i32 [ %22, %15 ], [ 0, %0 ]
%17 = tail call i32 @scale(i32* %1, i8* %13, i32 %7, i32 %10)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %13)
%19 = tail call i32 @printfStr(i8* %13, i32 %12, i32 %10)
%20 = tail call i32 @fprintfStr(i32* %2, i8* %13, i32 %12, i32 %10)
%21 = tail call i32 @getc(i32* %1)
%22 = add nuw nsw i32 %16, 1
%23 = icmp eq i32 %22, %4
br i1 %23, label %24, label %15
24: ; preds = %15, %0
ret i32 0
}