#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 */
struct udcFile {
  int dummy;
};
typedef int /*<<< orphan*/ bLen;

/* Variables and functions */
int /*<<< orphan*/ udcMustRead(struct udcFile *, char *, int);
int /*<<< orphan*/ udcRead(struct udcFile *, unsigned char *, int);
int udcFastReadString(struct udcFile *f, char buf[256]) {
  unsigned char bLen;
  int len;
  if (!udcRead(f, &(bLen), sizeof(bLen)))
    return 0;
  if ((len = bLen) > 0)
    udcMustRead(f, buf, len);
  buf[len] = 0;
  return 1;
}


x86 assembly (clang, -O0):
<udcFastReadString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <udcRead@plt>
cmp    $0x0,%eax
jne    1157 <udcFastReadString+0x37>
movl   $0x0,-0x4(%rbp)
jmp    118a <udcFastReadString+0x6a>
movzbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    1177 <udcFastReadString+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1040 <udcMustRead@plt>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udcFastReadString>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1030 <udcRead@plt>
test   %eax,%eax
je     1165 <udcFastReadString+0x45>
movzbl 0xf(%rsp),%ebp
test   %ebp,%ebp
je     1157 <udcFastReadString+0x37>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <udcMustRead@plt>
mov    %ebp,%eax
movb   $0x0,(%r14,%rax,1)
mov    $0x1,%eax
jmp    1167 <udcFastReadString+0x47>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.udcFile = type { i32 }
define i32 @udcFastReadString(%struct.udcFile* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.udcFile*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
store %struct.udcFile* %0, %struct.udcFile** %4
store i8* %1, i8** %5
%8 = load %struct.udcFile*, %struct.udcFile** %4
%9 = call i32 @udcRead(%struct.udcFile* %8, i8* %6, i32 1)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 0, i32* %3
br label %26
12: ; preds = %2
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
store i32 %14, i32* %7
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load %struct.udcFile*, %struct.udcFile** %4
%18 = load i8*, i8** %5
%19 = load i32, i32* %7
%20 = call i32 @udcMustRead(%struct.udcFile* %17, i8* %18, i32 %19)
br label %21
21: ; preds = %16, %12
%22 = load i8*, i8** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 0, i8* %25
store i32 1, i32* %3
br label %26
26: ; preds = %21, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.udcFile = type { i32 }
define i32 @udcFastReadString(%struct.udcFile* %0, i8* %1) {
%3 = alloca i8
%4 = call i32 @udcRead(%struct.udcFile* %0, i8* %3, i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = zext i8 %7 to i32
%11 = call i32 @udcMustRead(%struct.udcFile* %0, i8* %1, i32 %10)
br label %12
12: ; preds = %9, %6
%13 = zext i8 %7 to i64
%14 = getelementptr inbounds i8, i8* %1, i64 %13
store i8 0, i8* %14
br label %15
15: ; preds = %2, %12
%16 = phi i32 [ 1, %12 ], [ 0, %2 ]
ret i32 %16
}