#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 */
char getc(int /*<<< orphan*/ *);
void scale(FILE *file, char *outputStr, int length, int factor) {
  char out;
  int scns;
  int j;
  int len = 0;
  for (scns = 0; scns < length; scns++) {
    out = getc(file);
    for (j = 0; j < factor; j++) {
      *(outputStr + len) = out;
      len++;
    }
  }
}


x86 assembly (clang, -O0):
<scale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1197 <scale+0x87>
mov    -0x8(%rbp),%rdi
call   1030 <getc@plt>
mov    %al,-0x19(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1184 <scale+0x74>
mov    -0x19(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1153 <scale+0x43>
jmp    1189 <scale+0x79>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1134 <scale+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
test   %edx,%edx
jle    1179 <scale+0x59>
mov    %ecx,%r13d
mov    %edx,%ebp
mov    %rdi,%r15
mov    %ecx,%r12d
xor    %ebx,%ebx
test   %ecx,%ecx
mov    $0x0,%r14d
cmovg  %ecx,%r14d
jmp    1158 <scale+0x38>
xchg   %ax,%ax
add    %r14d,%ebx
add    $0xffffffff,%ebp
je     1179 <scale+0x59>
mov    %r15,%rdi
call   1040 <getc@plt>
test   %r13d,%r13d
jle    1150 <scale+0x30>
movslq %ebx,%rdi
add    (%rsp),%rdi
movzbl %al,%esi
mov    %r12,%rdx
call   1030 <memset@plt>
jmp    1150 <scale+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @scale(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %12
store i32 0, i32* %10
br label %13
13: ; preds = %36, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = load i32*, i32** %5
%19 = call signext i8 @getc(i32* %18)
store i8 %19, i8* %9
store i32 0, i32* %11
br label %20
20: ; preds = %32, %17
%21 = load i32, i32* %11
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i8, i8* %9
%26 = load i8*, i8** %6
%27 = load i32, i32* %12
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
%30 = load i32, i32* %12
%31 = add nsw i32 %30, 1
store i32 %31, i32* %12
br label %32
32: ; preds = %24
%33 = load i32, i32* %11
%34 = add nsw i32 %33, 1
store i32 %34, i32* %11
br label %20
35: ; preds = %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %13
39: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @scale(i32* nocapture %0, i8* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %21
6: ; preds = %4
%7 = icmp sgt i32 %3, 0
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %6, %17
%10 = phi i32 [ 0, %6 ], [ %18, %17 ]
%11 = phi i32 [ 0, %6 ], [ %19, %17 ]
%12 = tail call signext i8 @getc(i32* %0)
br i1 %7, label %13, label %17
13: ; preds = %9
%14 = sext i32 %10 to i64
%15 = getelementptr i8, i8* %1, i64 %14
%16 = add i32 %10, %3
br label %17
17: ; preds = %13, %9
%18 = phi i32 [ %10, %9 ], [ %16, %13 ]
%19 = add nuw nsw i32 %11, 1
%20 = icmp eq i32 %19, %2
br i1 %20, label %21, label %9
21: ; preds = %17, %4
ret void
}