#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*/ fread(char *, int, int, int /*<<< orphan*/ *);
char *malloc(int);
int trace_read_int(int /*<<< orphan*/ *);
char *task_name(FILE *f) {
  int size;
  char *name;
  size = trace_read_int(f);
  name = malloc(size + 1);
  if (name == NULL) {
    return name;
  }
  fread(name, size, 1, f);
  name[size] = 0;
  return name;
}


x86 assembly (clang, -O0):
<task_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <trace_read_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116f <task_name+0x3f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <task_name+0x68>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <trace_read_int@plt>
mov    %eax,%r15d
lea    0x1(%r15),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116b <task_name+0x3b>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
movslq %r15d,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @task_name(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @trace_read_int(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 1
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load i8*, i8** %5
store i8* %14, i8** %2
br label %25
15: ; preds = %1
%16 = load i8*, i8** %5
%17 = load i32, i32* %4
%18 = load i32*, i32** %3
%19 = call i32 @fread(i8* %16, i32 %17, i32 1, i32* %18)
%20 = load i8*, i8** %5
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %5
store i8* %24, i8** %2
br label %25
25: ; preds = %15, %13
%26 = load i8*, i8** %2
ret i8* %26
}

LLVM IR (-O2):
define noalias i8* @task_name(i32* %0) {
%2 = tail call i32 @trace_read_int(i32* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i32 @fread(i8* %4, i32 %2, i32 1, i32* %0)
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
store i8 0, i8* %9
br label %10
10: ; preds = %1, %6
ret i8* %4
}