#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 *CreateString(int);
char fgetc(int /*<<< orphan*/ *);
char *ConvertToString(FILE *origin, int NumberOfCharacters) {
  FILE *fp;
  fp = origin;
  char *NumberString;
  NumberString = CreateString(NumberOfCharacters + 1);
  for (int counter = 0; counter < NumberOfCharacters; counter++)
    *(NumberString + counter) = fgetc(fp);
  *(NumberString + NumberOfCharacters) = '\0';
  return NumberString;
}


x86 assembly (clang, -O0):
<ConvertToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1040 <CreateString@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117d <ConvertToString+0x5d>
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <ConvertToString+0x2d>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertToString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r15
lea    0x1(%r14),%edi
call   1040 <CreateString@plt>
mov    %rax,%r12
test   %r14d,%r14d
jle    1165 <ConvertToString+0x45>
mov    %r14d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    %al,(%r12,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <ConvertToString+0x30>
movslq %r14d,%rax
movb   $0x0,(%r12,%rax,1)
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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