#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 fgetc(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
char *PText(FILE *f) {
  char c = fgetc(f);
  char str[255];
  int count = 0;
  while (c != '/') {
    str[count] = c;
    count++;
    c = fgetc(f);
  }
  str[count] = '\0';
  char *text = malloc(sizeof(char) * count);
  strcpy(text, str);
  return text;
}


x86 assembly (clang, -O0):
<PText>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x9(%rbp)
movl   $0x0,-0x114(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x2f,%eax
je     1193 <PText+0x63>
mov    -0x9(%rbp),%cl
movslq -0x114(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x9(%rbp)
jmp    1155 <PText+0x25>
movslq -0x114(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
movslq -0x114(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x120(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PText>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
call   1040 <fgetc@plt>
xor    %ebx,%ebx
cmp    $0x2f,%al
je     1163 <PText+0x33>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <fgetc@plt>
cmp    $0x2f,%al
jne    1150 <PText+0x20>
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @PText(i32* nocapture %0) {
%2 = alloca [255 x i8]
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = icmp eq i8 %3, 47
br i1 %5, label %15, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %10, %6 ], [ 0, %1 ]
%8 = phi i8 [ %11, %6 ], [ %3, %1 ]
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %7
store i8 %8, i8* %9
%10 = add nuw i64 %7, 1
%11 = tail call signext i8 @fgetc(i32* %0)
%12 = icmp eq i8 %11, 47
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = trunc i64 %10 to i32
br label %15
15: ; preds = %13, %1
%16 = phi i32 [ 0, %1 ], [ %14, %13 ]
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %17
store i8 0, i8* %18
%19 = tail call i8* @malloc(i32 %16)
%20 = call i32 @strcpy(i8* %19, i8* %4)
ret i8* %19
}