#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void get_name(const char *file, char *buf) {
  FILE *f;
  char tmpbuf[64];
  int rc;
  f = fopen(file, "r");
  if (!f) {
    sprintf(buf, "%c", '\0');
    return;
  }
  rc = fread(tmpbuf, 64, 1, f);
  fclose(f);
  if (!rc)
    sprintf(buf, "%s", tmpbuf);
}


x86 assembly (clang, -O0):
<get_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <get_name+0x48>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    11cb <get_name+0x8b>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x40,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x64(%rbp)
jne    11cb <get_name+0x8b>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_name>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     118f <get_name+0x4f>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x40,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %ebp,%ebp
jne    1195 <get_name+0x55>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
jmp    1195 <get_name+0x55>
movw   $0x0,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"%s\00"
define void @get_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [64 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = icmp ne i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %27
15: ; preds = %2
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%17 = load i32*, i32** %5
%18 = call i32 @fread(i8* %16, i32 64, i32 1, i32* %17)
store i32 %18, i32* %7
%19 = load i32*, i32** %5
%20 = call i32 @fclose(i32* %19)
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %15
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %12, %23, %15
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @get_name(i8* nocapture %0, i8* %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
store i8 0, i8* %1
%8 = getelementptr i8, i8* %1, i64 1
store i8 0, i8* %8
br label %15
9: ; preds = %2
%10 = call i32 @fread(i8* %4, i32 64, i32 1, i32* %5)
%11 = tail call i32 @fclose(i32* %5)
%12 = icmp eq i32 %10, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i8* @strcpy(i8* dereferenceable(1) %1, i8* %4)
br label %15
15: ; preds = %9, %13, %7
ret void
}