#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*/ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long,
                           unsigned int, unsigned long);
unsigned int limit_within_bounds(unsigned int);
int convert_vertex(unsigned long int x, unsigned long int z, FILE *out,
                   const unsigned char *buf) {
  static const long double scale = 0.001L;
  unsigned int bx, by, bz;
  bx = limit_within_bounds((unsigned int)(buf[0] | (buf[1] << 8)));
  by = limit_within_bounds((unsigned int)(buf[2] | (buf[3] << 8)));
  bz = limit_within_bounds((unsigned int)(buf[4] | (buf[5] << 8)));
  fprintf(out, "v %.3Lf %.3Lf %.3Lf\n", (x + bx) * scale, by * scale,
          (z + bz) * scale);
  return !ferror(out);
}


x86 assembly (clang, -O0):
<convert_vertex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzwl (%rax),%edi
call   1050 <limit_within_bounds@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movzwl 0x2(%rax),%edi
call   1050 <limit_within_bounds@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movzwl 0x4(%rax),%edi
call   1050 <limit_within_bounds@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
sets   %al
movzbl %al,%eax
mov    %eax,%ecx
fildll -0x50(%rbp)
lea    0xe65(%rip),%rax
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
fldt   0xe6a(%rip)
fmul   %st,%st(1)
flds   0xe72(%rip)
fxch   %st(2)
fucomi %st(2),%st
fldz
fld    %st(0)
fcmovnb %st(4),%st
fsubrp %st,%st(2)
setae  %cl
fnstcw -0x62(%rbp)
movzwl -0x62(%rbp),%edx
or     $0xc00,%edx
mov    %dx,-0x64(%rbp)
fldcw  -0x64(%rbp)
fxch   %st(1)
fistpll -0x38(%rbp)
fldcw  -0x62(%rbp)
movzbl %cl,%ecx
shl    $0x3f,%rcx
mov    -0x38(%rbp),%rdx
xor    %rcx,%rdx
mov    -0x28(%rbp),%ecx
mov    %rcx,-0x60(%rbp)
fildll -0x60(%rbp)
fmul   %st(2),%st
fnstcw -0x66(%rbp)
movzwl -0x66(%rbp),%ecx
or     $0xc00,%ecx
mov    %cx,-0x68(%rbp)
fldcw  -0x68(%rbp)
fistpll -0x48(%rbp)
fldcw  -0x66(%rbp)
mov    -0x48(%rbp),%ecx
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%r8d
add    %r8,%rsi
mov    %rsi,-0x58(%rbp)
sets   %sil
movzbl %sil,%esi
fildll -0x58(%rbp)
flds   (%rax,%rsi,4)
faddp  %st,%st(1)
fmulp  %st,%st(2)
fxch   %st(1)
fucomi %st(2),%st
fxch   %st(1)
fcmovnb %st(2),%st
fstp   %st(2)
fsubp  %st,%st(1)
setae  %al
fnstcw -0x6a(%rbp)
movzwl -0x6a(%rbp),%esi
or     $0xc00,%esi
mov    %si,-0x6c(%rbp)
fldcw  -0x6c(%rbp)
fistpll -0x40(%rbp)
fldcw  -0x6a(%rbp)
movzbl %al,%eax
shl    $0x3f,%rax
mov    -0x40(%rbp),%r8
xor    %rax,%r8
lea    0xdd1(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_vertex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
movzwl (%rcx),%edi
call   1050 <limit_within_bounds@plt>
mov    %eax,%ebp
movzwl 0x2(%rbx),%edi
call   1050 <limit_within_bounds@plt>
mov    %eax,%r12d
movzwl 0x4(%rbx),%edi
call   1050 <limit_within_bounds@plt>
mov    %ebp,%ecx
xor    %edx,%edx
add    %r13,%rcx
mov    %rcx,0x20(%rsp)
sets   %dl
fildll 0x20(%rsp)
lea    0xe7d(%rip),%rsi
fadds  (%rsi,%rdx,4)
fldt   0xe84(%rip)
fmul   %st,%st(1)
flds   0xe8c(%rip)
xor    %edx,%edx
fxch   %st(2)
fucomi %st(2),%st
fldz
fld    %st(0)
fcmovnb %st(4),%st
fsubrp %st,%st(2)
setae  %dl
fnstcw 0x10(%rsp)
movzwl 0x10(%rsp),%ecx
or     $0xc00,%ecx
mov    %cx,0x16(%rsp)
fldcw  0x16(%rsp)
fxch   %st(1)
fistpll 0x28(%rsp)
fldcw  0x10(%rsp)
shl    $0x3f,%rdx
xor    0x28(%rsp),%rdx
mov    %r12d,%ecx
mov    %rcx,0x18(%rsp)
fildll 0x18(%rsp)
fmul   %st(2),%st
fnstcw 0xe(%rsp)
movzwl 0xe(%rsp),%ecx
or     $0xc00,%ecx
mov    %cx,0x14(%rsp)
fldcw  0x14(%rsp)
fistpll 0x30(%rsp)
fldcw  0xe(%rsp)
mov    0x30(%rsp),%ecx
mov    %eax,%eax
xor    %edi,%edi
add    %r14,%rax
mov    %rax,0x38(%rsp)
sets   %dil
fildll 0x38(%rsp)
fadds  (%rsi,%rdi,4)
fmulp  %st,%st(2)
xor    %r8d,%r8d
fxch   %st(1)
fucomi %st(2),%st
fxch   %st(1)
fcmovnb %st(2),%st
fstp   %st(2)
fsubp  %st,%st(1)
setae  %r8b
fnstcw 0xc(%rsp)
movzwl 0xc(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x12(%rsp)
fldcw  0x12(%rsp)
fistpll 0x40(%rsp)
fldcw  0xc(%rsp)
shl    $0x3f,%r8
xor    0x40(%rsp),%r8
lea    0xdc7(%rip),%rsi
mov    %r15,%rdi
call   1040 <fprintf@plt>
mov    %r15,%rdi
call   1030 <ferror@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@convert_vertex.scale = internal constant x86_fp80 0xK3FF583126E978D4FDF3B
@.str = [21 x i8] c"v %.3Lf %.3Lf %.3Lf\0A\00"
define i32 @convert_vertex(i64 %0, i64 %1, i32* %2, i8* %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32* %2, i32** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %8
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = load i8*, i8** %8
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl i32 %19, 8
%21 = or i32 %15, %20
%22 = call i32 @limit_within_bounds(i32 %21)
store i32 %22, i32* %9
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = shl i32 %30, 8
%32 = or i32 %26, %31
%33 = call i32 @limit_within_bounds(i32 %32)
store i32 %33, i32* %10
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i64 4
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 5
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = shl i32 %41, 8
%43 = or i32 %37, %42
%44 = call i32 @limit_within_bounds(i32 %43)
store i32 %44, i32* %11
%45 = load i32*, i32** %7
%46 = load i64, i64* %5
%47 = load i32, i32* %9
%48 = zext i32 %47 to i64
%49 = add i64 %46, %48
%50 = uitofp i64 %49 to x86_fp80
%51 = fmul x86_fp80 %50, 0xK3FF583126E978D4FDF3B
%52 = fptoui x86_fp80 %51 to i64
%53 = load i32, i32* %10
%54 = uitofp i32 %53 to x86_fp80
%55 = fmul x86_fp80 %54, 0xK3FF583126E978D4FDF3B
%56 = fptoui x86_fp80 %55 to i32
%57 = load i64, i64* %6
%58 = load i32, i32* %11
%59 = zext i32 %58 to i64
%60 = add i64 %57, %59
%61 = uitofp i64 %60 to x86_fp80
%62 = fmul x86_fp80 %61, 0xK3FF583126E978D4FDF3B
%63 = fptoui x86_fp80 %62 to i64
%64 = call i32 @fprintf(i32* %45, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %52, i32 %56, i64 %63)
%65 = load i32*, i32** %7
%66 = call i32 @ferror(i32* %65)
%67 = icmp ne i32 %66, 0
%68 = xor i1 %67, true
%69 = zext i1 %68 to i32
ret i32 %69
}

LLVM IR (-O2):
@.str = [21 x i8] c"v %.3Lf %.3Lf %.3Lf\0A\00"
define i32 @convert_vertex(i64 %0, i64 %1, i32* nocapture %2, i8* nocapture %3) {
%5 = load i8, i8* %3
%6 = zext i8 %5 to i32
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = shl nuw nsw i32 %9, 8
%11 = or i32 %10, %6
%12 = tail call i32 @limit_within_bounds(i32 %11)
%13 = getelementptr inbounds i8, i8* %3, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = getelementptr inbounds i8, i8* %3, i64 3
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl nuw nsw i32 %18, 8
%20 = or i32 %19, %15
%21 = tail call i32 @limit_within_bounds(i32 %20)
%22 = getelementptr inbounds i8, i8* %3, i64 4
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = getelementptr inbounds i8, i8* %3, i64 5
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = shl nuw nsw i32 %27, 8
%29 = or i32 %28, %24
%30 = tail call i32 @limit_within_bounds(i32 %29)
%31 = zext i32 %12 to i64
%32 = add i64 %31, %0
%33 = uitofp i64 %32 to x86_fp80
%34 = fmul x86_fp80 %33, 0xK3FF583126E978D4FDF3B
%35 = fptoui x86_fp80 %34 to i64
%36 = uitofp i32 %21 to x86_fp80
%37 = fmul x86_fp80 %36, 0xK3FF583126E978D4FDF3B
%38 = fptoui x86_fp80 %37 to i32
%39 = zext i32 %30 to i64
%40 = add i64 %39, %1
%41 = uitofp i64 %40 to x86_fp80
%42 = fmul x86_fp80 %41, 0xK3FF583126E978D4FDF3B
%43 = fptoui x86_fp80 %42 to i64
%44 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %35, i32 %38, i64 %43)
%45 = tail call i32 @ferror(i32* %2)
%46 = icmp eq i32 %45, 0
%47 = zext i1 %46 to i32
ret i32 %47
}